eelbrain.plot.brain.SequencePlotter

class eelbrain.plot.brain.SequencePlotter(subject=None, subjects_dir=None)

Grid of anatomical images in one figure

Notes

For plots with multiple layers, layers are added to the brain in the order they were added to the SequencePlotter.

Examples

Plot an evoked response or TRF (i.e., a time by source NDVar) in 50 ms bins between 0 and 300 ms. Use the extrema() method to plot peak activity in each time bin. This will plot the most extreme value including its sign, and thus show positive and negative effects:

# Bin the data
ndvar_binned = ndvar.bin(step=0.050, start=0, stop=0.3, func='extrema')
# Initialize the SequencePlotter and set parameters for visualizing the brain
sp = plot.brain.SequencePlotter()
sp.set_brain_args(surf='smoothwm')
# Add the data to be plotted
sp.add_ndvar(ndvar_binned)
# Generate the figure with multiple brain plots
p = sp.plot_table(view='lateral')
# Save as you would normally
p.save('Figure.pdf')

Plot specific time points in an evoked response or TRF (ndvar). To do this, simply add mutiple data objects. Make sure to pass a colormap or vmax parameter to make the color-scale consistent between plots:

cmap = plot.soft_threshold_colormap('xpolar-a', 0.0001, 0.010)
sp = plot.brain.SequencePlotter()
sp.set_brain_args(surf='smoothwm')
for t in [0.050, 0.100, 0.200]:
    sp.add_ndvar(ndvar.sub(time=t), cmap=cmap, label=f'{int(t*1000)} ms')
p = sp.plot_table(view='lateral', orientation='vertical')

Visualize a test result, by separately adding condition means and a difference map that is masked by significance:

res = testnd.TTestRelated('srcm', 'condition', 'a', 'b', match='subject', data=data)
vmax = 3  # explicitly set vmax to make sure that the color-maps agree
sp = plot.brain.SequencePlotter()
sp.set_brain_args(surf='inflated')
sp.add_ndvar(res.c1_mean, vmax=vmax, label='a')
sp.add_ndvar(res.c0_mean, vmax=vmax, label='b')
sp.add_ndvar(res.masked_difference(), vmax=vmax, label='a - b')
p = sp.plot_table(view='lateral', orientation='vertical')

Plot a source by time test result, showing how a difference map evolves over time:

res = testnd.TTestRelated('srcm', 'condition', 'a', 'b', match='subject', data=data)
difference = res.masked_difference()
binned = difference.bin(step=0.200, start=0.200, stop=1.00, func='extrema')
sp = plot.brain.SequencePlotter()
sp.add_ndvar(binned)
p = sp.plot_table(view='lateral', title='a = b')
Parameters:

Methods

add_function(func[, label, overlay])

Custom modification of the brain object (calls func(brain))

add_label(mne_label, *[, overlay, index, label])

add_ndvar(ndvar, *args[, static, index, label])

Add a data layer to the brain plot

add_ndvar_label(ndvar[, color, borders, ...])

Add a boolean label to the brain plot

add_pmap(res[, label])

See add_ndvar_p_map()

plot_table([hemi, view, orientation, ...])

Create a figure with the images

set_brain([source, subject, subjects_dir])

Set the brain model on which to plot

set_brain_args([surf, foreground, ...])

Set parameters for anatomical plot (see brain())

set_frame_order(order)

Set the order in which frames are plotted

set_parallel_view([forward, up, scale])

Set view for all plots (see set_parallel_view()