visbrain.objects.BrainObj¶
- class visbrain.objects.BrainObj(name, vertices=None, faces=None, normals=None, lr_index=None, hemisphere='both', translucent=True, sulcus=False, invert_normals=False, transform=None, parent=None, verbose=None, _scale=1.0, **kw)[source][source]¶
Create a brain object.
- Parameters:
- namestring
Name of the brain object. If brain is ‘B1’ or ‘B2’ or ‘B3’ use a default brain template. If name is ‘white’, ‘inflated’ or ‘sphere’ download the template (if needed). Otherwise, at least vertices and faces must be defined. The name parameter can also be the path to a file with one the following extensions :
By default, visbrain includes six human brain templates (‘B1’, ‘B2’, ‘B3’ and three coming from freesurfer ‘inflated’, ‘white’ and ‘sphere’). If name is one of those, the template is downloaded
x3d (XML files)
gii (Gifti files, require nibabel)
obj (wavefront files)
Freesurfer files. For example, you can provide ‘lf.inflated’ if you only want one hemisphere or [‘lh.inflated’, ‘rh.inflated’] for both
- verticesarray_like | None
Mesh vertices to use for the brain. Must be an array of shape (n_vertices, 3).
- facesarray_like | None
Mesh faces of shape (n_faces, 3).
- normalsarray_like | None
Normals to each vertex. If None, the program will try to compute it. Must be an array with the same shape as vertices.
- lr_indexarray_like | None
Left / Right index for hemispheres. Must be a vector of length n_vertices. This vector must be a boolean array where True refer to vertices that belong to the left hemisphere and False, the right hemisphere.
- hemisphere{‘left’, ‘both’, ‘right’}
The hemisphere to plot.
- translucentbool | True
Use translucent (True) or opaque (False) brain.
- transformVisPy.visuals.transforms | None
VisPy transformation to set to the parent node.
- parentVisPy.parent | None
Brain object parent.
- verbosestring
Verbosity level.
- kwdict | {}
Optional arguments are used to control the colorbar (See
ColorbarObj
).
Notes
List of supported shortcuts :
s : save the figure
<delete> : reset camera
Examples
>>> from visbrain.objects import BrainObj >>> # Use one of default human brain template. >>> b = BrainObj('white', hemisphere='right', translucent=False) >>> b.preview() >>> # Alternatively, you can also provide path to a file. For example : >>> files = ['lh.inflated', 'rh.inflated'] # freesurfer files >>> b2 = BrainObj(files) >>> b2.preview(is_freesurfer_mesh_file, )
Methods
__init__
(name[, vertices, faces, normals, ...])Init.
add_activation
([data, vertices, ...])Add activation to the brain template.
animate
([step, interval, iterations])Animate the object.
clean
()Clean brain object.
copy
()Get a copy of the object.
Tree description.
get_parcellates
(file)Get the list of supported parcellates names and index.
list
([file])Get the list of all installed templates.
parcellize
(file[, select, hemisphere, data, ...])Parcellize the brain surface using a .annot file.
preview
([bgcolor, axis, xyz, show, obj, ...])Previsualize the result.
project_sources
(s_obj[, project, radius, ...])Project source's activity or repartition onto the brain object.
record_animation
(name[, n_pic, bgcolor])Record an animated object and save as a *.gif file.
remove
()Remove a brain template.
render
()Render the canvas.
Reset the camera.
rotate
([fixed, scale_factor, custom, margin])Rotate the brain using predefined rotations or a custom one.
save
([tmpfile])Save the brain template (if not already saved).
screenshot
(saveas[, print_size, dpi, unit, ...])Take a screeshot of the scene.
set_data
([name, vertices, faces, normals, ...])Load a brain template.
set_shortcuts_to_canvas
(canvas)Set shortcuts to a VisbrainCanvas.
slice
([xmin, xmax, ymin, ymax, zmin, zmax])Take a slice of the brain.
to_dict
()Return a dictionary of all colorbar args.
to_kwargs
([addisminmax])Return a dictionary for input arguments.
update
()Fonction to run when an update is needed.
update_from_dict
(kwargs)Update attributes from a dictionary.
Examples using visbrain.objects.BrainObj
¶

Connectivity object (ConnectObj) : complete tutorial

Region Of Interest object (RoiObj) : complete tutorial