Пример #1
0
def test_brain_colorbar(orientation, diverging, lims):
    """Test brain colorbar plotting."""
    _, ax = plt.subplots()
    clim = dict(kind='value')
    if diverging:
        clim['pos_lims'] = lims
    else:
        clim['lims'] = lims
    plot_brain_colorbar(ax, clim, orientation=orientation)
    if orientation == 'vertical':
        have, empty = ax.get_yticklabels, ax.get_xticklabels
    else:
        have, empty = ax.get_xticklabels, ax.get_yticklabels
    if diverging:
        if lims[0] == 0:
            ticks = list(-np.array(lims[1:][::-1])) + lims
        else:
            ticks = list(-np.array(lims[::-1])) + [0] + lims
    else:
        ticks = lims
    plt.draw()
    # old mpl always spans 0->1 for the actual ticks, so we need to
    # look at the labels
    assert_array_equal([float(h.get_text().replace('−', '-')) for h in have()],
                       ticks)
    assert_array_equal(empty(), [])
    plt.close('all')
Пример #2
0
def test_brain_colorbar(orientation, diverging, lims):
    """Test brain colorbar plotting."""
    _, ax = plt.subplots()
    clim = dict(kind='value')
    if diverging:
        clim['pos_lims'] = lims
    else:
        clim['lims'] = lims
    cbar = plot_brain_colorbar(ax, clim, orientation=orientation)
    ax = cbar.ax  # in newer mpl this can be inset axes relative to the orig
    if orientation == 'vertical':
        have, empty = ax.get_yticklabels, ax.get_xticklabels
    else:
        have, empty = ax.get_xticklabels, ax.get_yticklabels
    if diverging:
        if lims[0] == 0:
            ticks = list(-np.array(lims[1:][::-1])) + lims
        else:
            ticks = list(-np.array(lims[::-1])) + [0] + lims
    else:
        ticks = lims
    ax.figure.canvas.draw_idle()
    assert_array_equal([float(h.get_text().replace('−', '-')) for h in have()],
                       ticks)
    assert_array_equal(empty(), [])
img = peak_stc.as_volume(src_fs, mri_resolution=False)

fig = plt.figure(figsize=(6, 2.5))
axes = [
    plt.subplot2grid((4, 16), (0, 0), rowspan=4, colspan=14),
    plt.subplot2grid((4, 16), (1, 15), rowspan=2, colspan=1)
]

plot_glass_brain(img,
                 title='t = 0.50s, Cue = A',
                 draw_cross=False,
                 annotate=True,
                 colorbar=False,
                 cmap=colormap,
                 threshold=lims[0],
                 vmax=lims[-1],
                 axes=axes[0])
plot_brain_colorbar(axes[1],
                    clim,
                    'magma_r',
                    label='Activation (NAI)',
                    bgcolor='white')
fig.subplots_adjust(left=0.05,
                    right=0.9,
                    bottom=0.01,
                    top=0.9,
                    wspace=0.5,
                    hspace=0.1)
fig.savefig(fname.figures + '/lcmv_A_500ms_lower.pdf', dpi=300)
    plt.subplot2grid((6, 23), (0, 15), rowspan=6, colspan=3),
    plt.subplot2grid((6, 23), (0, 18), rowspan=6, colspan=3),
    plt.subplot2grid((6, 23), (1, 22), rowspan=4, colspan=1)
]
for ti, t in enumerate(ttp):
    ab_diff.plot_topomap(times=t,
                         average=0.05,
                         vmin=-4,
                         vmax=4,
                         extrapolate='head',
                         colorbar=False,
                         axes=axes[ti],
                         show=False)
plot_brain_colorbar(axes[-1],
                    clim,
                    'RdBu_r',
                    label='Difference Cue B - Cue A',
                    bgcolor='darkblue')
fig.savefig(fname.figures + '/Diff_Topomaps.pdf', dpi=300)

###############################################################################
# 7) Plot ERPs for individual electrodes of interest
cis = within_subject_cis([a_erps, b_erps])

for electrode in [
        'FCz', 'FC1', 'FC3', 'Cz', 'C1', 'C3', 'Pz', 'Oz', 'PO8', 'PO7'
]:
    pick = ga_a_cue.ch_names.index(electrode)

    fig, ax = plt.subplots(figsize=(8, 4))
    plot_compare_evokeds(