eelbrain.plot._brain_object.Brain

class eelbrain.plot._brain_object.Brain(subject, hemi, surf='inflated', title=None, cortex='classic', alpha=1.0, background='white', foreground='black', subjects_dir=None, views='lat', offset=True, show_toolbar=False, offscreen=False, interaction='trackball', w=None, h=None, axw=None, axh=None, name=None, pos=None, source_space=None, show=True, run=None)[source]

PySurfer surfer.Brain subclass returned by plot.brain functions

PySurfer surfer.Brain subclass adding Eelbrain GUI integration and methods to visualize data in NDVar format.

Parameters:
  • subject (str) – Subject name.

  • hemi (Literal['lh', 'rh', 'both', 'split']) – ‘both’: both hemispheres are shown in the same window; ‘split’: hemispheres are displayed side-by-side in different viewing panes.

  • surf (str) – Freesurfer surface mesh name (ie ‘white’, ‘inflated’, etc.).

  • title (str) – Title for the window.

  • cortex (str | tuple | dict) –

    Specifies how the cortical surface is rendered. Options:

    1. The name of one of the preset cortex styles: 'classic' (default), 'high_contrast', 'low_contrast', or 'bone'.

    2. A color-like argument to render the cortex as a single color, e.g. 'red' or (0.1, 0.4, 1.). Setting this to None is equivalent to (0.5, 0.5, 0.5).

    3. The name of a colormap used to render binarized curvature values, e.g., Grays.

    4. A list of colors used to render binarized curvature values. Only the first and last colors are used. E.g., [‘red’, ‘blue’] or [(1, 0, 0), (0, 0, 1)].

    5. A container with four entries for colormap (string specifiying the name of a colormap), vmin (float specifying the minimum value for the colormap), vmax (float specifying the maximum value for the colormap), and reverse (bool specifying whether the colormap should be reversed. E.g., ('Greys', -1, 2, False).

    6. A dict of keyword arguments that is passed on to the call to surface.

  • alpha (float) – Alpha level to control opacity of the cortical surface (0 <= alpha <= 1).

  • background (ColorArg) – color of the background and foreground of the display window

  • foreground (ColorArg) – color of the background and foreground of the display window

  • subjects_dir (PathArg) – If not None, this directory will be used as the subjects directory instead of the value set using the SUBJECTS_DIR environment variable.

  • views (str | Sequence[str]) – views to use

  • offset (bool) – If True, aligs origin with medial wall. Useful for viewing inflated surface where hemispheres typically overlap (Default: True)

  • show_toolbar (bool) – If True, toolbars will be shown for each view.

  • offscreen (bool) – If True, rendering will be done offscreen (not shown). Useful mostly for generating images or screenshots, but can be buggy. Use at your own risk.

  • interaction (str) – Can be “trackball” (default) or “terrain”, i.e. a turntable-style camera.

  • w (float) – Figure width and height.

  • h (float) – Figure width and height.

  • axw (float) – Width and height of the individual viewing panes.

  • axh (float) – Width and height of the individual viewing panes.

  • name (str) – Window title (alternative to title for consistency with other Eelbrain figures).

  • pos (tuple[int, int]) – Position of the new window on the screen.

  • show (bool) – Currently meaningless due to limitation in VTK that does not allow hidden plots.

  • run (bool) – Run the Eelbrain GUI app (default is True for interactive plotting and False in scripts).

  • source_space (SourceSpace)

Notes

The documentation lists only the methods that Eelbrain adds to or overrides from the PySurfer Brain super-class. For complete PySurfer functionality see te PySurfer documentation.

Initializing a Brain object is expensive. When plotting multiple overlays on the same brain, it is more economical to initialize only one Brain object and adding/removing the data layers in a loop. Pseudo-code for an example adding images to a table:

table = fmtxt.Table('ll')
b = brain(source_space, hemi=hemi, …)
for data_layer in data_layers:
    table.cell(data_layer.name)
    b.add_ndvar(data_layer, ...)
    im = b.image()
    table.cell(im)
    b.remove_data()
    b.remove_labels()

For another example see the implementation of SequencePlotter.

Methods

add_label(label[, color, alpha, ...])

add_mask(source[, color, smoothing_steps, ...])

Add a mask shading areas that are not included in an NDVar

add_ndvar(ndvar[, cmap, vmin, vmax, ...])

Add data layer form an NDVar

add_ndvar_annotation(ndvar[, colors, ...])

Add annotation from labels in an NDVar

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

Draw a boolean NDVar as label.

add_ndvar_p_map(p_map[, param_map, p0, p1, ...])

Add a map of p-values as data-layer

close()

Close the figure window

copy_screenshot()

Copy the currently shown image to the clipboard

enable_vertex_selection([color])

Find source space vertice by right-clicking on the brain

get_time()

Retrieve the current time

get_vlim()

(vmin, vmax) for the most recently added data layer

image([name, format, alt, mode])

Create an FMText Image from a screenshot

link_time_axis(other)

Link the time axis of this figure with another figure

play_movie([tstart, tstop, fps])

Play an animation by setting time

plot_colorbar([label, label_position, ...])

Plot a colorbar corresponding to the displayed data

plot_legend(*args, **kwargs)

Plot legend for parcellation

remove_data([hemi])

Remove data shown with Brain.add_ndvar

remove_labels([labels, mask])

Remove labels shown with Brain.add_ndvar_label

save_image(filename[, mode, antialiased, ...])

Save view from all panels to disk

set_parallel_view([forward, up, scale])

Set view to parallel projection

set_size(width, height)

Set image size in pixels

set_surf(surf)

set_time(time)

Set the time point to display

set_title(title)

Set the window title

set_vlim([v, vmax])

Change the colormap limits