Exemple #1
0
def load(site, boxload=True, **kwargs):

    # defaults
    options = {'batch': 316,
               'cellid': site,
               'stimfmt': 'envelope',
               'rasterfs': 100,
               'recache': False,
               'runclass': 'CPN',
               'stim': False}

    options.update(**kwargs)

    if boxload is True:
        toname = options.copy()
        del toname['recache']
        filename = pl.Path(config['paths']['recording_cache']) / set_name(toname)

        if not filename.parent.exists():
            filename.parent.mkdir()

        if filename.exists() and options['recache'] is False:
            print('loading recording from box')
            loaded_rec = jl.load(filename)

        elif filename.exists() is False or options['recache'] is True:
            load_URI, _ = nb.baphy_load_recording_uri(**options)
            loaded_rec = recording.load_recording(load_URI)
            print('cacheing recoring in box')
            jl.dump(loaded_rec, filename)
        else:
            raise SystemError('WTF?')

    elif boxload is False:
        load_URI, _ = nb.baphy_load_recording_uri(**options)
        loaded_rec = recording.load_recording(load_URI)

    else:
        raise ValueError('boxload must be boolean')

    CPN_rec = cpe.set_recording_subepochs(loaded_rec)

    recordings  = split_recording(CPN_rec)
    return recordings
Exemple #2
0
}

rec_recache = False

region_map = dict(
    zip([
        'AMT028b', 'AMT029a', 'AMT030a', 'AMT031a', 'AMT032a', 'DRX008b',
        'DRX021a', 'ley070a', 'ley072b'
    ], ['PEG', 'PEG', 'PEG', 'PEG', 'PEG', 'A1', 'A1', 'A1', 'A1']))

all_probes = [2, 3, 5, 6]

# load the calculated dprimes and montecarlo shuffling/simulations
# the loadede dictionary has 3 layers, analysis, value type and cell/site
batch_dprimes_file = pl.Path(
    config['paths']['analysis_cache']) / 'batch_dprimes' / set_name(meta)
batch_dprimes = jl.load(batch_dprimes_file)

sites = set(batch_dprimes['dPCA']['dprime'].keys())
all_cells = set(batch_dprimes['SC']['dprime'].keys())

########################################################################################################################
# defines a significant threshold and transform the pvalues into boolean (significant vs nonsignificant)
threshold = 0.01
for analysis_name, mid_dict in batch_dprimes.items():
    mid_dict['shuffled_significance'] = {
        key: (val <= threshold)
        for key, val in mid_dict['shuffled_pvalue'].items()
    }
    if analysis_name != 'SC':
        mid_dict['simulated_significance'] = {
Exemple #3
0
# transferable plotting parameters
plt.rcParams['svg.fonttype'] = 'none'
sup_title_size = 30
sub_title_size = 20
ax_lab_size = 15
ax_val_size = 11
full_screen = [19.2, 9.83]
sns.set_style("ticks")

########################################################################################################################
########################################################################################################################
# data frame containing all the important summary data, i.e. exponential decay fits for dprime and significance, for
# all combinations of transition pairs, and probes,  for the means across probes, transitions pairs or for both, and
# for the single cell analysis or the dPCA projections
summary_DF_file = pl.Path(
    config['paths']['analysis_cache']) / 'DF_summary' / set_name(meta)
print('loading cached summary DataFrame')
DF = jl.load(summary_DF_file)

########################################################################################################################
# SC
########################################################################################################################
# compare parameters between different probes or transitions pairs

analyses = ['SC', 'dPCA']
sources = ['dprime', 'significance']
parameters = ['tau', 'r0']
comparisons = ['probe', 'transition_pair']

good_thresh = 0.1
Exemple #4
0
# transferable plotting parameters
plt.rcParams['svg.fonttype'] = 'none'
sup_title_size = 30
sub_title_size = 20
ax_lab_size = 15
ax_val_size = 11
full_screen = [19.2, 9.83]
sns.set_style("ticks")

########################################################################################################################
########################################################################################################################
# data frame containing all the important summary data, i.e. exponential decay fits for dprime and significance, for
# all combinations of transition pairs, and probes,  for the means across probes, transitions pairs or for both, and
# for the single cell analysis or the dPCA projections
summary_DF_file = pl.Path(config['paths']['analysis_cache']) / 'DF_summary' / set_name(meta)
print('loading cached summary DataFrame')
DF = jl.load(summary_DF_file)

########################################################################################################################
# SC
########################################################################################################################
# compare tau between different probe means
ff_anal = DF.analysis == 'SC'
ff_probe = DF.probe != 'mean'
ff_trans = DF.transition_pair == 'mean'
ff_param = DF.parameter == 'tau'
ff_source = DF.source == 'significance'
ff_outliers = DF.value < 1000

filtered = DF.loc[ff_anal & ff_probe & ff_trans & ff_param & ff_source & ff_outliers,
Exemple #5
0
    barax.tick_params(axis='y', labelcolor=barkwargs['color'])
    lineax.tick_params(axis='y', labelcolor=linekwargs['color'])

    return barax, lineax

meta = {'reliability': 0.1,  # r value
        'smoothing_window': 0,  # ms
        'raster_fs': 30,
        'transitions': ['silence', 'continuous', 'similar', 'sharp'],
        'montecarlo': 1000,
        'zscore': True,
        'dprime_absolute': None}

# load the calculated dprimes and montecarlo shuffling/simulations
# the loadede dictionary has 3 layers, analysis, value type and cell/site
batch_dprimes_file = pl.Path(config['path']['analysis_cache']) / 'batch_dprimes' / set_name(meta)
batch_dprimes = jl.load(batch_dprimes_file)
########################################################################################################################
# set up the time bin labels in milliseconds, this is critical for plotting and calculating the tau
nbin = np.max([value.shape[-1] for value in batch_dprimes['SC']['dprime'].values()])
fs = meta['raster_fs']
times = np.linspace(0, nbin / fs, nbin, endpoint=False) * 1000

bar_width = 1 / fs * 1000
fig_root = 'single_cell_context_dprime'


def compare_plot(cell):
    site = cell[0:7]

    SC_hist = np.nanmean(batch_dprimes['SC']['shuffled_significance'][cell], axis=(0, 1))