mne.viz.LayeredMesh#
- class mne.viz.LayeredMesh(renderer, vertices, triangles, normals)[source]#
A mesh with support for layered RGBA overlays and optional smoothing.
This class manages a single brain-surface mesh and composites multiple named overlays (e.g., curvature, data, labels) on top of each other using alpha blending. It is the object stored in
Brain.layered_meshes.Warning
This class is not meant to be instantiated directly, and the initialization API could change at any time! Use
mne.viz.Brain.add_data()to create instances.- Parameters:
- Attributes:
- smooth_mat
scipy.sparse.csr_arrayorNone Optional spatial smoother / upsampler applied to scalar data before rendering. When set (e.g., by
set_data_smoothing()), every call toupdate_overlay()will multiply the incoming scalars by this matrix before storing them. Shape must be(n_surface_vertices, n_source_vertices).
- smooth_mat
Methods
add_overlay(scalars, colormap, rng, opacity, ...)Add a named overlay to the mesh.
remove_overlay(names)Remove one or more overlays by name.
update([colors])Recompose all overlays and refresh the mesh texture.
update_overlay(name[, scalars, colormap, ...])Update an existing overlay in-place.
Notes
New in v1.13.
- add_overlay(scalars, colormap, rng, opacity, name, smooth=False)[source]#
Add a named overlay to the mesh.
- Parameters:
- scalars
array, shape (n_vertices,) Scalar values to display. If
smooth=Trueandsmooth_matis set, shape must be(n_src_vertices,).- colormap
array, shape (n_colors, 4) RGBA colormap table (values in
[0, 255]).- rngarray_like, shape (2,)
[min, max]range for colormap mapping.- opacity
float|None Overlay opacity in
[0, 1].Nonekeeps the existing value.- name
str Unique key identifying this overlay.
- smoothbool
If
Trueandsmooth_matis set, multiplyscalarsbysmooth_matbefore rendering. UseTrueonly for source-space data; surface-space overlays (curvature, labels, annotations) should use the defaultFalse.
- scalars
- update(colors=None)[source]#
Recompose all overlays and refresh the mesh texture.
- Parameters:
- colorsarray_like of shape (n_triangles, 4) |
None Pre-composited RGBA colors to blend over the cached layer stack. If
None, all overlays are recomposed from scratch.
- colorsarray_like of shape (n_triangles, 4) |
Examples using
update:
- update_overlay(name, scalars=None, colormap=None, opacity=None, rng=None)[source]#
Update an existing overlay in-place.
- Parameters:
- name
str Key of the overlay to update (must already exist).
- scalars
array, shape (n_vertices,) |None New scalar values. If
None, scalars are unchanged. Ifsmooth_matis set, smoothing is applied automatically (matching the behaviour of the originaladd_data()call that created the overlay).- colormap
array, shape (n_colors, 4) |None New RGBA colormap table. If
None, colormap is unchanged.- opacity
float|None New opacity in
[0, 1]. IfNone, opacity is unchanged.- rngarray_like, shape (2,) |
None New
[min, max]colormap range. IfNone, range is unchanged.
- name
Examples using
update_overlay: