# </editor-fold>
# ----------------------------------------------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------------------------------------------
# <editor-fold desc = VISUALISE

template_all = most_common_template_pair[1]
template_desi = most_common_template_pair[0]

template_all = template_info_all_nonMUA.iloc[19]['template number']

# Make topoplot of desimated probe
topoplot_desi = np.flipud(
    np.reshape(
        sh.peaktopeak(avg_templates_bs_desi[template_desi, :, :],
                      window_size=40)[4], (4, 4)))

# Make topoplot of interpolated full probe
interpolated_topoplot_all = sh.create_heatmap_image(
    interpolated_avg_templates_all[template_all, :, :],
    const_all.prb_file,
    window_size=40,
    bad_channels=None,
    num_of_shanks=1,
    rotate_90=False,
    flip_lr=False,
    flip_ud=False,
    gridscale=10,
    width=10,
    height=10)[0]
min = data_used[template_all, :, :].min()
max = data_used[template_all, :, :].max()
for c in np.arange(data_used.shape[1]):
    w = probe_all[c][1] / 155 + 0.35 / 15
    h = probe_all[c][0] / 170 + 0.4 / 17
    inset_axis.append(a3.inset_axes([w, h - 0.025 * h, 1 / 15, 1 / 17]))
    inset_axis[-1].axis('off')
    inset_axis[-1].set_ylim(min, max)
    if c != 31:
        inset_axis[-1].plot(data_used[template_all, c, :], c='k')

decimated_data_used = np.zeros((16, data_used.shape[2]))
for g in np.arange(len(const_deci.group_channels)):
    decimated_data_used[g, :] = np.mean(
        data_used[template_all, const_deci.group_channels[g], :], axis=0)
p2p_from_decimated_data_used = sh.peaktopeak(decimated_data_used, 40)[4]
reshaped_from_decimated_p2p = np.flipud(
    np.reshape(p2p_from_decimated_data_used, (4, 4)))

f4 = plt.figure(4)
a4 = f4.add_subplot(111)
_ = a4.imshow(reshaped_from_decimated_p2p,
              interpolation='bicubic',
              vmin=reshaped_from_decimated_p2p.min(),
              vmax=reshaped_from_decimated_p2p.max())
prb_file = join(const_deci.probe_layout_folder,
                'probe_imec_256channels_decimated_file.txt')
probe_desi = sh.get_probe_geometry_from_prb_file(prb_file)[0]['geometry']

inset_axis = []
min = decimated_data_used.min()
# </editor-fold>
# ----------------------------------------------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------------------------------------------
# <editor-fold desc = VISUALISE

template_all = most_common_template_pair[1]
template_desi = most_common_template_pair[0]

template_all = template_info_all_nonMUA.iloc[36]['template number']

# Make topoplot of desimated probe
topoplot_desi = np.flipud(
    np.reshape(
        sh.peaktopeak(avg_templates_bs_desi[template_desi, :, :],
                      window_size=40)[4], (4, 4)))

# Make topoplot of interpolated full probe
interpolated_topoplot_all = sh.create_heatmap_image(
    interpolated_avg_templates_all[template_all, :, :],
    const_all.prb_file,
    window_size=40,
    bad_channels=None,
    num_of_shanks=1,
    rotate_90=False,
    flip_lr=False,
    flip_ud=False,
    gridscale=10,
    width=10,
    height=10)[0]
def plot_timesries_superimposed_full_and_desi(template_index):
    a3.cla()
    a4.cla()

    template_all = template_info_all_nonMUA.iloc[template_index][
        'template number']

    cmap = cm_adj.cmap_center_point_adjust(cm.jet, [
        smoothed_avg_templates_all[template_all, :, :].min(),
        smoothed_avg_templates_all[template_all, :, :].max()
    ], -100)

    smoothed_topoplot_all = sh.create_heatmap_image(
        smoothed_avg_templates_all[template_all, :, :],
        const_all.prb_file,
        window_size=40,
        bad_channels=None,
        num_of_shanks=1,
        rotate_90=False,
        flip_lr=False,
        flip_ud=False,
        gridscale=10,
        width=10,
        height=10,
        cmap=cmap)[0]
    _ = a3.imshow(smoothed_topoplot_all)

    inset_axis = []
    min = data_used[template_all, :, :].min()
    max = data_used[template_all, :, :].max()
    for c in np.arange(data_used.shape[1]):
        w = probe_all[c][1] / 155 + 0.35 / 15
        h = probe_all[c][0] / 170 + 0.4 / 17
        inset_axis.append(a3.inset_axes([w, h - 0.025 * h, 1 / 15, 1 / 17]))
        inset_axis[-1].axis('off')
        inset_axis[-1].set_ylim(min, max)
        if c != 31:
            inset_axis[-1].plot(data_used[template_all, c, :], c='k')

    decimated_data_used = np.zeros((16, data_used.shape[2]))
    for g in np.arange(len(const_deci.group_channels)):
        decimated_data_used[g, :] = np.mean(
            data_used[template_all, const_deci.group_channels[g], :], axis=0)
    p2p_from_decimated_data_used = sh.peaktopeak(decimated_data_used, 40)[4]
    reshaped_from_decimated_p2p = np.flipud(
        np.reshape(p2p_from_decimated_data_used, (4, 4)))

    _ = a4.imshow(reshaped_from_decimated_p2p,
                  interpolation='bicubic',
                  vmin=reshaped_from_decimated_p2p.min(),
                  vmax=reshaped_from_decimated_p2p.max(),
                  cmap=cmap)

    inset_axis = []
    min = data_used[template_all, channels_to_keep, :].min()
    max = data_used[template_all, channels_to_keep, :].max()
    for c in np.arange(len(channels_to_keep)):
        w = probe_desi[c][1] / 4
        h = probe_desi[c][0] / 4
        inset_axis.append(a4.inset_axes([w, h, 1 / 4, 1 / 4]))
        inset_axis[-1].axis('off')
        inset_axis[-1].set_ylim(min, max)
        inset_axis[-1].plot(decimated_data_used[c, :], c='k')
示例#5
0
# </editor-fold>
# ----------------------------------------------------------------------------------------------------------------------


# ----------------------------------------------------------------------------------------------------------------------
# <editor-fold desc = VISUALISE BEST PEAK TO PEAK HEATMAPS

template_all = most_common_template_pair[1]
template_desi = most_common_template_pair[0]

template_all = template_info_all_nonMUA.iloc[44]['template number']


# Make topoplot of desimated probe
topoplot_desi = np.flipud(np.reshape(sh.peaktopeak(avg_templates_bs_desi[template_desi, :, :], window_size=40)[4], (4,4)))


# Make topoplot of interpolated full probe
interpolated_topoplot_all = sh.create_heatmap_image(interpolated_avg_templates_all[template_all, :, :], const_all.prb_file,
                                                    window_size=40, bad_channels=None, num_of_shanks=1, rotate_90=False,
                                                    flip_lr=False, flip_ud=False, gridscale=10, width=10, height=10)[0]

# Make topoplot of interpolated full probe smoothed
smoothed_topoplot_all = sh.create_heatmap_image(smoothed_avg_templates_all[template_all, :, :], const_all.prb_file,
                                                window_size=40, bad_channels=None, num_of_shanks=1, rotate_90=False,
                                                flip_lr=False, flip_ud=False, gridscale=10, width=10, height=10)[0]

# Show
f0 = plt.figure(0)
f0.add_subplot()