Beispiel #1
0
sig = rec['resp']
eps = sig.epochs

cellorder = sig.chans
# map of transitin types, which change form probe to probe. the outer key is probe, the inner key is transition type
# the value is context identity
transitions = {6: {'silence': 0,'continuous': 5,'similar': 7,'sharp': 10},
               7: {'silence': 0,'continuous': 6,'similar': 5,'sharp': 9},
               9: {'silence': 0,'continuous': 8,'similar': 10,'sharp': 7},
               10: {'silence': 0,'continuous': 9,'similar': 8,'sharp': 6}}

########################################################################################################################

# check integrity of the data
# test plot
fig, axes = cplot.hybrid(sig, ['C0_P6', 'C0_P7', 'C0_P9', 'C0_P10'])
fig, axes = cplot.hybrid(sig, epoch_names = ['REFERENCE'])
fig, axes = cplot.hybrid(sig, epoch_names = ['REFERENCE'], channels=goodcells)

# data plots withe this approach corresponds with that plotted with baphy_remote. It seems that the epoch naming is
# properly aligned.
epoch_names = nep.epoch_names_matching(sig.epochs, r'\ASTIM_Tsequence.*')
fig, axes = cplot.hybrid(sig, epoch_names=epoch_names, channels=goodcells)
fig, axes = cplot.hybrid(sig, epoch_names='C7_P9', channels=goodcells)
fig, axes = cplot.hybrid(sig, epoch_names='C0_P9', channels=goodcells)

# for good cells, all the relevant probes after silence
fig, axes = cplot.hybrid(sig, epoch_names=r'\AC0_P([679]|10)\Z', channels=goodcells)
fig, axes = cplot.hybrid(sig, epoch_names=r'\AC0_P([679]|10)\Z', channels=best_cell)

# best cell, best probe, all the contexts
Beispiel #2
0
    # raw raster
    epoch_names = [
        f"C{transitions[f'P{probe}'][trans]}_P{probe}"
        for trans in meta['transitions']
    ]
    topcell_idx = np.argmax(np.abs(weights[:, 0, topDbin]))
    topcell = goodcells[topcell_idx]
    trans_colors = [trans_color_map[trans] for trans in meta['transitions']]

    raster_ax = axes[2]
    cplt.hybrid(sig,
                epoch_names,
                channels=topcell,
                psth_fs=meta['raster_fs'],
                time_strech=[start, end],
                time_offset=offset,
                axes=[raster_ax],
                legend=True,
                labels=meta['transitions'],
                colors=trans_colors)
    raster_ax.axvline(0, linestyle=':', color='gray')
    raster_ax.axvline(topDtime, linestyle='--', color='black')

    # horizonta line in weightplot indicating most weighted cell
    trans_ax.axhline(topcell_idx + 0.5, linestyle='--', color='Black')

    # Formatting

    for ax in [trans_ax, dprime_ax, raster_ax]:
        ax.tick_params(labelsize=ax_val_size)
        ax.spines['right'].set_visible(False)
Beispiel #3
0
        '/home/mateo/Pictures/DAC1/181205_pvalue_min_{}.png'.format(site_ID),
        dpi=100)
    fig.savefig(
        '/home/mateo/Pictures/DAC1/181205_pvalue_min_{}.svg'.format(site_ID))
plt.close('all')

################################################
# plots examples of calculation Process
best_site = 'BRT056b'
best_cell = 'BRT056b-58-1'
best_voc = None
best_cont = None

# full population, stim_num independent PSTH vocalization
sig = pop_sigs[best_site]['resp']
fig, axes = cplot.hybrid(sig, scatter_kws={'alpha': 0.1})
mng = plt.get_current_fig_manager()
mng.resize(*mng.window.maxsize())
fig.suptitle(
    'stim_num independent vocalizations PSTH\nsite {}'.format(best_site))
fig.savefig(
    '/home/mateo/Pictures/DAC1/181205_voc_psth_all_cells_{}.png'.format(
        best_site),
    dpi=100)
fig.savefig(
    '/home/mateo/Pictures/DAC1/181205_voc_psth_all_cells_{}.svg'.format(
        best_site))

# single cell, all vocalizations, all contexts
cpp_eps = nep.epoch_names_matching(sig.epochs, r'\AC\d_P\d$')
Beispiel #4
0
        cpp_rec = cep.set_recording_subepochs(rec, set_pairs=True)
        pop_sigs[site_key][modelname] = cpp_rec['pred'].rasterize()
    pop_sigs[site_key]['resp'] = cpp_rec['resp'].rasterize()

del (pop_sigs['BRT057b'])

########################################################################################################################
# cleaner version of example for wip talk.... something broke this plotting function down the road, not on my code

best_site = 'BRT056b'
best_cell = 'BRT056b-58-1'

sig = pop_sigs[best_site]['resp']
fig, axes = cplot.hybrid(sig,
                         epoch_names=r'\AC\d_P3',
                         start=3,
                         end=6,
                         scatter_kws={'alpha': 0.1})
mng = plt.get_current_fig_manager()
mng.resize(*mng.window.maxsize())
plt.tight_layout()
for ax in axes:
    ax.axis('off')
fig.suptitle('')
# fig.suptitle('stim_num independent vocalizations PSTH\nsite {}'.format(best_site))
# fig.savefig('/home/mateo/Pictures/WIP2/181207_eg_cpp_all_cells_{}.png'.format(best_site), dpi=100)
# fig.savefig('/home/mateo/Pictures/WIP2/181207_eg_cpp_all_cells_{}.svg'.format(best_site))

# single cell, one prb, all contexts
goodprobe = 3
goodcell = 'BRT056b-58-1'
Beispiel #5
0
    png = root.joinpath(f'dPCA_{site}_P{probe}').with_suffix('.png')
    fig.savefig(png, transparent=True, dpi=100)
    svg = png = root.joinpath(f'dPCA_{site}_P{probe}').with_suffix('.svg')
    fig.savefig(svg, transparent=True)


    if site == 'AMT029a':
                        #  blue,   brown   orange     green
        CB_color_cycle = ['#377eb8','#a65628',  '#ff7f00', '#4daf4a', ]

    else:
                        #  blue,      orange     green      brown
        CB_color_cycle = ['#377eb8', '#ff7f00', '#4daf4a', '#a65628']


    fig, ax = plots.hybrid(sig, f'\AC\d_P{probe}\Z', channels=topcell, time_strech=[1,2], colors=CB_color_cycle)
    ax = ax[0]
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.tick_params(labelsize=15)
    ax.title.set_size(20)
    ax.xaxis.label.set_size(20)
    ax.yaxis.label.set_size(20)

    fig.set_size_inches([4.83, 4.2 ])


    if save_img:
        root = pl.Path(f'/home/mateo/Pictures/DAC2')
        if not root.exists(): root.mkdir(parents=True, exist_ok=True)
        png = root.joinpath(f'raster_{site}_P{probe}').with_suffix('.png')
Beispiel #6
0
    # variance explained by PCs

    for sig_name, pca in pca_stats.items():
        fig, ax = plt.subplots()
        toplot = np.cumsum(pca.explained_variance_ratio_)
        ax.plot(toplot, '.-')
        ax.set_xlabel('number of components')
        ax.set_ylabel('cumulative explained variance')
        ax.set_title('PCA: fraction of variance explained')

    # selects most responsive celll
    scat_key = {'s': 5, 'alpha': 0.5}
    cplt.hybrid(
        sig,
        epoch_names='single',
        channels='all',
        start=0,
        end=3,
        scatter_kws=scat_key,
    )

    good_cell_index = [5, 7, 8, 10, 11, 14]

    # selects the stimulus generating the highest response
    cplt.hybrid(sig,
                epoch_names='single',
                channels=good_cell_index,
                start=0,
                end=3,
                scatter_kws=scat_key)
    # vocalization 3 generates the clearest response
Beispiel #7
0
    var_ax.title.set_size(20)
    var_ax.xaxis.label.set_size(20)
    var_ax.yaxis.label.set_size(20)

    # plots example raster
    epoch_names = [
        f"C{transitions[f'P{probe}'][trans]}_P{probe}"
        for trans in meta['transitions']
    ]
    topcell = goodcells[np.argmax(np.abs(dpca.D['ct'][:, 0]))]
    colors = [trans_color_map[trans] for trans in meta['transitions']]

    raster_ax = plt.subplot2grid((2, 2), (1, 0), 1, 1, fig=fig)
    cplt.hybrid(sig,
                epoch_names=epoch_names,
                channels=topcell,
                time_strech=[1, 2],
                colors=colors,
                axes=[raster_ax])
    raster_ax = raster_ax
    raster_ax.spines['right'].set_visible(False)
    raster_ax.spines['top'].set_visible(False)
    raster_ax.tick_params(labelsize=15)
    raster_ax.title.set_size(20)
    raster_ax.xaxis.label.set_size(20)
    raster_ax.yaxis.label.set_size(20)

    suptitle = f"{site} probe {probe} dPCA zscore-{meta['zscore']}"
    fig.suptitle(suptitle, fontsize=20)

    analysis = f"dPCA_examples_{meta['raster_fs']}Hz_zscore-{meta['zscore']}"