surfer.Brain

class surfer.Brain(subject_id, hemi, surf, title=None, cortex='classic', alpha=1.0, size=800, background='black', foreground=None, figure=None, subjects_dir=None, views=['lat'], offset=True, show_toolbar=False, offscreen='auto', interaction='trackball', units='mm')[source]

Class for visualizing a brain using multiple views in mlab

Parameters
subject_idstr

subject name in Freesurfer subjects dir

hemistr

hemisphere id (ie ‘lh’, ‘rh’, ‘both’, or ‘split’). In the case of ‘both’, both hemispheres are shown in the same window. In the case of ‘split’ hemispheres are displayed side-by-side in different viewing panes.

surfstr

freesurfer surface mesh name (ie ‘white’, ‘inflated’, etc.)

titlestr

title for the window

cortexstr, tuple, dict, or None

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.

alphafloat in [0, 1]

Alpha level to control opacity of the cortical surface.

sizefloat or pair of floats

the size of the window, in pixels. can be one number to specify a square window, or the (width, height) of a rectangular window.

backgroundmatplotlib color

Color of the background.

foregroundmatplotlib color

Color of the foreground (will be used for colorbars and text). None (default) will use black or white depending on the value of background.

figurelist of mayavi.core.scene.Scene | None | int

If None (default), a new window will be created with the appropriate views. For single view plots, the figure can be specified as int to retrieve the corresponding Mayavi window.

subjects_dirstr | None

If not None, this directory will be used as the subjects directory instead of the value set using the SUBJECTS_DIR environment variable.

viewslist | str

views to use

offsetbool

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

show_toolbarbool

If True, toolbars will be shown for each view.

offscreenbool | str

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. Can be “auto” (default) to use mlab.options.offscreen.

interactionstr

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

unitsstr

Can be ‘m’ or ‘mm’ (default).

Attributes
annotlist

List of annotations.

brainslist

List of the underlying brain instances.

contourlist

List of the contours.

focifoci

The foci.

labelsdict

The labels.

overlaysdict

The overlays.

textsdict

The text objects.

__hash__(self, /)

Return hash(self).

add_annotation(self, annot, borders=True, alpha=1, hemi=None, remove_existing=True, color=None, **kwargs)[source]

Add an annotation file.

Parameters
annotstr | tuple

Either path to annotation file or annotation name. Alternatively, the annotation can be specified as a (labels, ctab) tuple per hemisphere, i.e. annot=(labels, ctab) for a single hemisphere or annot=((lh_labels, lh_ctab), (rh_labels, rh_ctab)) for both hemispheres. labels and ctab should be arrays as returned by nibabel.freesurfer.io.read_annot().

bordersbool | int

Show only label borders. If int, specify the number of steps (away from the true border) along the cortical mesh to include as part of the border definition.

alphafloat in [0, 1]

Alpha level to control opacity.

hemistr | None

If None, it is assumed to belong to the hemipshere being shown. If two hemispheres are being shown, data must exist for both hemispheres.

remove_existingbool

If True (default), remove old annotations.

colormatplotlib-style color code

If used, show all annotations in the same (specified) color. Probably useful only when showing annotation borders.

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.pipeline.surface call.

add_contour_overlay(self, source, min=None, max=None, n_contours=7, line_width=1.5, colormap='YlOrRd_r', hemi=None, remove_existing=True, colorbar=True, **kwargs)[source]

Add a topographic contour overlay of the positive data.

Note: This visualization will look best when using the “low_contrast” cortical curvature colorscheme.

Parameters
sourcestr or array

path to the overlay file or numpy array

minfloat

threshold for overlay display

maxfloat

saturation point for overlay display

n_contoursint

number of contours to use in the display

line_widthfloat

width of contour lines

colormapstring, list of colors, or array

name of matplotlib colormap to use, a list of matplotlib colors, or a custom look up table (an n x 4 array coded with RBGA values between 0 and 255).

hemistr | None

If None, it is assumed to belong to the hemipshere being shown. If two hemispheres are being shown, an error will be thrown.

remove_existingbool

If there is an existing contour overlay, remove it before plotting.

colorbarbool

If True, show the colorbar for the scalar value.

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.pipeline.contour_surface call.

add_data(self, array, min=None, max=None, thresh=None, colormap='auto', alpha=1, vertices=None, smoothing_steps=20, time=None, time_label='time index=%d', colorbar=True, hemi=None, remove_existing=False, time_label_size=14, initial_time=None, scale_factor=None, vector_alpha=None, mid=None, center=None, transparent=False, verbose=None, **kwargs)[source]

Display data from a numpy array on the surface.

This provides a similar interface to surfer.Brain.add_overlay(), but it displays it with a single colormap. It offers more flexibility over the colormap, and provides a way to display four-dimensional data (i.e., a timecourse) or five-dimensional data (i.e., a vector-valued timecourse).

Note

min sets the low end of the colormap, and is separate from thresh (this is a different convention from surfer.Brain.add_overlay()).

Parameters
arraynumpy array, shape (n_vertices[, 3][, n_times])

Data array. For the data to be understood as vector-valued (3 values per vertex corresponding to X/Y/Z surface RAS), then array must be have all 3 dimensions. If vectors with no time dimension are desired, consider using a singleton (e.g., np.newaxis) to create a “time” dimension and pass time_label=None.

minfloat

min value in colormap (uses real min if None)

midfloat

intermediate value in colormap (middle between min and max if None)

maxfloat

max value in colormap (uses real max if None)

threshNone or float

if not None, values below thresh will not be visible

centerfloat or None

if not None, center of a divergent colormap, changes the meaning of min, max and mid, see scale_data_colormap() for further info.

transparentbool

if True: use a linear transparency between fmin and fmid and make values below fmin fully transparent (symmetrically for divergent colormaps)

colormapstring, list of colors, or array

name of matplotlib colormap to use, a list of matplotlib colors, or a custom look up table (an n x 4 array coded with RBGA values between 0 and 255), the default “auto” chooses a default divergent colormap, if “center” is given (currently “icefire”), otherwise a default sequential colormap (currently “rocket”).

alphafloat in [0, 1]

alpha level to control opacity of the overlay.

verticesnumpy array

vertices for which the data is defined (needed if len(data) < nvtx)

smoothing_stepsint | str | None

Number of smoothing steps (if data come from surface subsampling). Can be None to use the fewest steps that result in all vertices taking on data values, or “nearest” such that each high resolution vertex takes the value of the its nearest (on the sphere) low-resolution vertex. Default is 20.

timenumpy array

time points in the data array (if data is 2D or 3D)

time_labelstr | callable | None

format of the time label (a format string, a function that maps floating point time values to strings, or None for no label)

colorbarbool

whether to add a colorbar to the figure

hemistr | None

If None, it is assumed to belong to the hemisphere being shown. If two hemispheres are being shown, an error will be thrown.

remove_existingbool

Remove surface added by previous “add_data” call. Useful for conserving memory when displaying different data in a loop.

time_label_sizeint

Font size of the time label (default 14)

initial_timefloat | None

Time initially shown in the plot. None to use the first time sample (default).

scale_factorfloat | None (default)

The scale factor to use when displaying glyphs for vector-valued data.

vector_alphafloat | None

alpha level to control opacity of the arrows. Only used for vector-valued data. If None (default), alpha is used.

verbosebool, str, int, or None

If not None, override default verbose level (see surfer.verbose).

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.pipeline.surface call.

Notes

If the data is defined for a subset of vertices (specified by the “vertices” parameter), a smoothing method is used to interpolate the data onto the high resolution surface. If the data is defined for subsampled version of the surface, smoothing_steps can be set to None, in which case only as many smoothing steps are applied until the whole surface is filled with non-zeros.

Due to a Mayavi (or VTK) alpha rendering bug, vector_alpha is clamped to be strictly < 1.

add_foci(self, coords, coords_as_verts=False, map_surface=None, scale_factor=1, color='white', alpha=1, name=None, hemi=None, **kwargs)[source]

Add spherical foci, possibly mapping to displayed surf.

The foci spheres can be displayed at the coordinates given, or mapped through a surface geometry. In other words, coordinates from a volume-based analysis in MNI space can be displayed on an inflated average surface by finding the closest vertex on the white surface and mapping to that vertex on the inflated mesh.

Parameters
coordsnumpy array

x, y, z coordinates in stereotaxic space (default) or array of vertex ids (with coord_as_verts=True)

coords_as_vertsbool

whether the coords parameter should be interpreted as vertex ids

map_surfaceFreesurfer surf or None

surface to map coordinates through, or None to use raw coords

scale_factorfloat

Controls the size of the foci spheres (relative to 1cm).

colormatplotlib color code

HTML name, RBG tuple, or hex code

alphafloat in [0, 1]

opacity of focus gylphs

namestr

internal name to use

hemistr | None

If None, it is assumed to belong to the hemipshere being shown. If two hemispheres are being shown, an error will be thrown.

**kwargsadditional keyword arguments
These are passed to the underlying

mayavi.mlab.points3d() call.

add_label(self, label, color=None, alpha=1, scalar_thresh=None, borders=False, hemi=None, subdir=None, **kwargs)[source]

Add an ROI label to the image.

Parameters
labelstr | instance of Label

label filepath or name. Can also be an instance of an object with attributes “hemi”, “vertices”, “name”, and optionally “color” and “values” (if scalar_thresh is not None).

colormatplotlib-style color | None

anything matplotlib accepts: string, RGB, hex, etc. (default “crimson”)

alphafloat in [0, 1]

alpha level to control opacity

scalar_threshNone or number

threshold the label ids using this value in the label file’s scalar field (i.e. label only vertices with scalar >= thresh)

bordersbool | int

Show only label borders. If int, specify the number of steps (away from the true border) along the cortical mesh to include as part of the border definition.

hemistr | None

If None, it is assumed to belong to the hemipshere being shown. If two hemispheres are being shown, an error will be thrown.

subdirNone | str

If a label is specified as name, subdir can be used to indicate that the label file is in a sub-directory of the subject’s label directory rather than in the label directory itself (e.g. for $SUBJECTS_DIR/$SUBJECT/label/aparc/lh.cuneus.label brain.add_label('cuneus', subdir='aparc')).

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.pipeline.surface call.

Notes

To remove previously added labels, run Brain.remove_labels().

add_morphometry(self, measure, grayscale=False, hemi=None, remove_existing=True, colormap=None, min=None, max=None, colorbar=True, **kwargs)[source]

Add a morphometry overlay to the image.

Parameters
measure{‘area’ | ‘curv’ | ‘jacobian_white’ | ‘sulc’ | ‘thickness’}

which measure to load

grayscalebool

whether to load the overlay with a grayscale colormap

hemistr | None

If None, it is assumed to belong to the hemipshere being shown. If two hemispheres are being shown, data must exist for both hemispheres.

remove_existingbool

If True (default), remove old annotations.

colormapstr

Mayavi colormap name, or None to use a sensible default.

min, maxfloats

Endpoints for the colormap; if not provided the robust range of the data is used.

colorbarbool

If True, show a colorbar corresponding to the overlay data.

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.pipeline.surface call.

add_overlay(self, source, min=2, max='robust_max', sign='abs', name=None, hemi=None, **kwargs)[source]

Add an overlay to the overlay dict from a file or array.

Parameters
sourcestr or numpy array

path to the overlay file or numpy array with data

minfloat

threshold for overlay display

maxfloat

saturation point for overlay display

sign{‘abs’ | ‘pos’ | ‘neg’}

whether positive, negative, or both values should be displayed

namestr

name for the overlay in the internal dictionary

hemistr | None

If None, it is assumed to belong to the hemipshere being shown. If two hemispheres are being shown, an error will be thrown.

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.pipeline.surface call.

add_text(self, x, y, text, name, color=None, opacity=1.0, row=-1, col=-1, font_size=None, justification=None, **kwargs)[source]

Add a text to the visualization

Parameters
xFloat

x coordinate

yFloat

y coordinate

textstr

Text to add

namestr

Name of the text (text label can be updated using update_text())

colorTuple

Color of the text. Default is the foreground color set during initialization (default is black or white depending on the background color).

opacityFloat

Opacity of the text. Default: 1.0

rowint

Row index of which brain to use

colint

Column index of which brain to use

**kwargsadditional keyword arguments

These are passed to the underlying mayavi.mlab.text3d() call.

animate(self, views, n_steps=180.0, fname=None, use_cache=False, row=-1, col=-1)[source]

Animate a rotation.

Currently only rotations through the axial plane are allowed.

Parameters
views: sequence

views to animate through

n_steps: float

number of steps to take in between

fname: string

If not None, it saves the animation as a movie. fname should end in ‘.avi’ as only the AVI format is supported

use_cache: bool

Use previously generated images in ./.tmp/

rowint

Row index of the brain to use

colint

Column index of the brain to use

close(self)[source]

Close all figures and cleanup data structure.

property data_dict

For backwards compatibility

property data_time_index

Retrieve the currently displayed data time index

Returns
time_idxint

Current time index.

Notes

Raises a RuntimeError if the Brain instance has not data overlay.

get_data_properties(self)[source]

Get properties of the data shown

Returns
propsdict

Dictionary with data properties

props[“fmin”] : minimum colormap props[“fmid”] : midpoint colormap props[“fmax”] : maximum colormap props[“transparent”] : lower part of colormap transparent? props[“time”] : time points props[“time_idx”] : current time index props[“smoothing_steps”] : number of smoothing steps

hide_colorbar(self, row=-1, col=-1)[source]

Hide colorbar(s) for given plot

Parameters
rowint

Row index of which brain to use

colint

Column index of which brain to use

index_for_time(self, time, rounding='closest')[source]

Find the data time index closest to a specific time point.

Parameters
timescalar

Time.

rounding‘closest’ | ‘up’ | ‘down’

How to round if the exact time point is not an index.

Returns
indexint

Data time index closest to time.

property labels_dict

For backwards compatibility

remove_data(self, hemi=None)[source]

Remove data shown with Brain.add_data().

Parameters
hemistr | None

Hemisphere from which to remove data (default is all shown hemispheres).

remove_foci(self, name=None)[source]

Remove foci added with Brain.add_foci().

Parameters
namestr | list of str | None

Names of the foci to remove (if None, remove all).

Notes

Only foci added with a unique names can be removed.

remove_labels(self, labels=None, hemi=None)[source]

Remove one or more previously added labels from the image.

Parameters
labelsNone | str | list of str

Labels to remove. Can be a string naming a single label, or None to remove all labels. Possible names can be found in the Brain.labels attribute.

hemiNone

Deprecated parameter, do not use.

reset_view(self)[source]

Orient camera to display original view

save_image(self, filename, mode='rgb', antialiased=False)[source]

Save view from all panels to disk

Only mayavi image types are supported: (png jpg bmp tiff ps eps pdf rib oogl iv vrml obj

Parameters
filename: string

path to new image file

modestring

Either ‘rgb’ (default) to render solid background, or ‘rgba’ to include alpha channel for transparent background.

antialiasedbool

Antialias the image (see mayavi.mlab.screenshot() for details; see default False).

Notes

Due to limitations in TraitsUI, if multiple views or hemi=’split’ is used, there is no guarantee painting of the windows will complete before control is returned to the command line. Thus we strongly recommend using only one figure window (which uses a Mayavi figure to plot instead of TraitsUI) if you intend to script plotting commands.

save_image_sequence(self, time_idx, fname_pattern, use_abs_idx=True, row=-1, col=-1, montage='single', border_size=15, colorbar='auto', interpolation='quadratic')[source]

Save a temporal image sequence

The files saved are named fname_pattern % pos where pos is a relative or absolute index (controlled by use_abs_idx).

Parameters
time_idxarray_like

Time indices to save. Non-integer values will be displayed using interpolation between samples.

fname_patternstr

Filename pattern, e.g. ‘movie-frame_%0.4d.png’.

use_abs_idxbool

If True the indices given by time_idx are used in the filename if False the index in the filename starts at zero and is incremented by one for each image (Default: True).

rowint

Row index of the brain to use.

colint

Column index of the brain to use.

montage‘current’ | ‘single’ | list

Views to include in the images: ‘current’ uses the currently displayed image; ‘single’ (default) uses a single view, specified by the row and col parameters; a 1 or 2 dimensional list can be used to specify a complete montage. Examples: ['lat', 'med'] lateral and ventral views ordered horizontally; [['fro'], ['ven']] frontal and ventral views ordered vertically.

border_sizeint

Size of image border (more or less space between images).

colorbar‘auto’ | int | list of int | None

For ‘auto’, the colorbar is shown in the middle view (default). For int or list of int, the colorbar is shown in the specified views. For None, no colorbar is shown.

interpolationstr

Interpolation method (scipy.interpolate.interp1d parameter, one of ‘linear’ | ‘nearest’ | ‘zero’ | ‘slinear’ | ‘quadratic’ | ‘cubic’, default ‘quadratic’). Interpolation is only used for non-integer indexes.

Returns
images_writtenlist

All filenames written.

save_imageset(self, prefix, views, filetype='png', colorbar='auto', row=-1, col=-1)[source]

Convenience wrapper for save_image

Files created are prefix+’_$view’+filetype

Parameters
prefix: string | None

filename prefix for image to be created. If None, a list of arrays representing images is returned (not saved to disk).

views: list

desired views for images

filetype: string

image type

colorbar: ‘auto’ | int | list of int | None

For ‘auto’, the colorbar is shown in the middle view (default). For int or list of int, the colorbar is shown in the specified views. For None, no colorbar is shown.

rowint

row index of the brain to use

colint

column index of the brain to use

Returns
images_written: list

all filenames written

save_montage(self, filename, order=['lat', 'ven', 'med'], orientation='h', border_size=15, colorbar='auto', row=-1, col=-1)[source]

Create a montage from a given order of images

Parameters
filename: string | None

path to final image. If None, the image will not be saved.

order: list

list of views: order of views to build montage (default ['lat', 'ven', 'med']; nested list of views to specify views in a 2-dimensional grid (e.g, [['lat', 'ven'], ['med', 'fro']])

orientation: {‘h’ | ‘v’}

montage image orientation (horizontal of vertical alignment; only applies if order is a flat list)

border_size: int

Size of image border (more or less space between images)

colorbar: ‘auto’ | int | list of int | None

For ‘auto’, the colorbar is shown in the middle view (default). For int or list of int, the colorbar is shown in the specified views. For None, no colorbar is shown.

rowint

row index of the brain to use

colint

column index of the brain to use

Returns
outarray

The montage image, usable with matplotlib.pyplot.imshow().

save_movie(self, fname, time_dilation=4.0, tmin=None, tmax=None, framerate=24, interpolation='quadratic', codec=None, bitrate=None, **kwargs)[source]

Save a movie (for data with a time axis)

The movie is created through the imageio module. The format is determined by the extension, and additional options can be specified through keyword arguments that depend on the format. For available formats and corresponding parameters see the imageio documentation: http://imageio.readthedocs.io/en/latest/formats.html#multiple-images

Warning

This method assumes that time is specified in seconds when adding data. If time is specified in milliseconds this will result in movies 1000 times longer than expected.

Parameters
fnamestr

Path at which to save the movie. The extension determines the format (e.g., ‘*.mov’, ‘*.gif’, …; see the imageio documenttion for available formats).

time_dilationfloat

Factor by which to stretch time (default 4). For example, an epoch from -100 to 600 ms lasts 700 ms. With time_dilation=4 this would result in a 2.8 s long movie.

tminfloat

First time point to include (default: all data).

tmaxfloat

Last time point to include (default: all data).

frameratefloat

Framerate of the movie (frames per second, default 24).

interpolationstr

Interpolation method (scipy.interpolate.interp1d parameter, one of ‘linear’ | ‘nearest’ | ‘zero’ | ‘slinear’ | ‘quadratic’ | ‘cubic’, default ‘quadratic’).

**kwargs :

Specify additional options for imageio.

Notes

Requires imageio package, which can be installed together with PySurfer with:

$ pip install -U pysurfer[save_movie]
save_single_image(self, filename, row=-1, col=-1)[source]

Save view from one panel to disk

Only mayavi image types are supported: (png jpg bmp tiff ps eps pdf rib oogl iv vrml obj

Parameters
filename: string

path to new image file

rowint

row index of the brain to use

colint

column index of the brain to use

Due to limitations in TraitsUI, if multiple views or hemi=’split’
is used, there is no guarantee painting of the windows will
complete before control is returned to the command line. Thus
we strongly recommend using only one figure window (which uses
a Mayavi figure to plot instead of TraitsUI) if you intend to
script plotting commands.
scale_data_colormap(self, fmin, fmid, fmax, transparent, center=None, alpha=1.0, data=None, hemi=None, verbose=None)[source]

Scale the data colormap.

The colormap may be sequential or divergent. When the colormap is divergent indicate this by providing a value for ‘center’. The meanings of fmin, fmid and fmax are different for sequential and divergent colormaps. For sequential colormaps the colormap is characterised by:

[fmin, fmid, fmax]

where fmin and fmax define the edges of the colormap and fmid will be the value mapped to the center of the originally chosen colormap. For divergent colormaps the colormap is characterised by:

[center-fmax, center-fmid, center-fmin, center,
 center+fmin, center+fmid, center+fmax]

i.e., values between center-fmin and center+fmin will not be shown while center-fmid will map to the middle of the first half of the original colormap and center-fmid to the middle of the second half.

Parameters
fminfloat

minimum value for colormap

fmidfloat

value corresponding to color midpoint

fmaxfloat

maximum value for colormap

transparentboolean

if True: use a linear transparency between fmin and fmid and make values below fmin fully transparent (symmetrically for divergent colormaps)

centerfloat

if not None, gives the data value that should be mapped to the center of the (divergent) colormap

alphafloat

sets the overall opacity of colors, maintains transparent regions

datadict | None

The data entry for which to scale the colormap. If None, will use the data dict from either the left or right hemisphere (in that order).

hemistr | None

If None, all hemispheres will be scaled.

verbosebool, str, int, or None

If not None, override default verbose level (see surfer.verbose).

screenshot(self, mode='rgb', antialiased=False)[source]

Generate a screenshot of current view.

Wraps to mayavi.mlab.screenshot() for ease of use.

Parameters
modestring

Either ‘rgb’ or ‘rgba’ for values to return.

antialiasedbool

Antialias the image (see mayavi.mlab.screenshot() for details; default False).

Returns
screenshotarray

Image pixel values.

Notes

Due to limitations in TraitsUI, if multiple views or hemi='split' is used, there is no guarantee painting of the windows will complete before control is returned to the command line. Thus we strongly recommend using only one figure window (which uses a Mayavi figure to plot instead of TraitsUI) if you intend to script plotting commands.

screenshot_single(self, mode='rgb', antialiased=False, row=-1, col=-1)[source]

Generate a screenshot of current view from a single panel.

Wraps to mayavi.mlab.screenshot() for ease of use.

Parameters
mode: string

Either ‘rgb’ or ‘rgba’ for values to return

antialiased: bool

Antialias the image (see mayavi.mlab.screenshot() for details).

rowint

row index of the brain to use

colint

column index of the brain to use

Returns
screenshot: array

Image pixel values

Notes

Due to limitations in TraitsUI, if multiple views or hemi=’split’ is used, there is no guarantee painting of the windows will complete before control is returned to the command line. Thus we strongly recommend using only one figure window (which uses a Mayavi figure to plot instead of TraitsUI) if you intend to script plotting commands.

set_data_smoothing_steps(self, smoothing_steps=20, verbose=None)[source]

Set the number of smoothing steps

Parameters
smoothing_stepsint | str | None

Number of smoothing steps (if data come from surface subsampling). Can be None to use the fewest steps that result in all vertices taking on data values, or “nearest” such that each high resolution vertex takes the value of the its nearest (on the sphere) low-resolution vertex. Default is 20.

verbosebool, str, int, or None

If not None, override default verbose level (see surfer.verbose).

set_data_time_index(self, time_idx, interpolation='quadratic')[source]

Set the data time index to show

Parameters
time_idxint | float

Time index. Non-integer values will be displayed using interpolation between samples.

interpolationstr

Interpolation method (scipy.interpolate.interp1d parameter, one of ‘linear’ | ‘nearest’ | ‘zero’ | ‘slinear’ | ‘quadratic’ | ‘cubic’, default ‘quadratic’). Interpolation is only used for non-integer indexes.

set_distance(self, distance=None)[source]

Set view distances for all brain plots to the same value

Parameters
distancefloat | None

Distance to use. If None, brains are set to the farthest “best fit” distance across all current views; note that the underlying “best fit” function can be buggy.

Returns
distancefloat

The distance used.

set_surf(self, surf)[source]

Change the surface geometry

Parameters
surfstr

freesurfer surface mesh name (ie ‘white’, ‘inflated’, etc.)

set_time(self, time)[source]

Set the data time index to the time point closest to time

Parameters
timescalar

Time.

show_colorbar(self, row=-1, col=-1)[source]

Show colorbar(s) for given plot

Parameters
rowint

Row index of which brain to use

colint

Column index of which brain to use

show_view(self, view=None, roll=None, distance=None, row=-1, col=-1)[source]

Orient camera to display view

Parameters
viewstr | dict

brain surface to view (one of ‘lateral’, ‘medial’, ‘rostral’, ‘caudal’, ‘dorsal’, ‘ventral’, ‘frontal’, ‘parietal’) or kwargs to pass to mayavi.mlab.view().

rollfloat

camera roll

distancefloat | ‘auto’ | None

distance from the origin

rowint

Row index of which brain to use

colint

Column index of which brain to use

Returns
viewtuple

tuple returned from mlab.view

rollfloat

camera roll returned from mlab.roll

toggle_toolbars(self, show=None)[source]

Toggle toolbar display

Parameters
showbool | None

If None, the state is toggled. If True, the toolbar will be shown, if False, hidden.

update_text(self, text, name, row=-1, col=-1)[source]

Update text label

Parameters
textstr

New text for label

namestr

Name of text label