mne.
Label
(vertices, pos=None, values=None, hemi=None, comment=”, name=None, filename=None, subject=None, color=None, verbose=None)[source]¶A FreeSurfer/MNE label with vertices restricted to one hemisphere.
Labels can be combined with the +
operator:
- Duplicate vertices are removed.
- If duplicate vertices have conflicting position values, an error is raised.
- Values of duplicate vertices are summed.
Parameters: | vertices : array (length N)
pos : array (N by 3) | None
values : array (length N) | None
hemi : ‘lh’ | ‘rh’
comment : str
name : str
filename : str
subject : str | None
color : None | matplotlib color
verbose : bool, str, int, or None
|
---|
Attributes
color | (None | tuple) Default label color, represented as RGBA tuple with values between 0 and 1. |
comment | (str) Comment from the first line of the label file. |
hemi | (‘lh’ | ‘rh’) Hemisphere. |
name | (None | str) A name for the label. It is OK to change that attribute manually. |
pos | (array, shape = (n_pos, 3)) Locations in meters. |
subject | (str | None) Subject name. It is best practice to set this to the proper value on initialization, but it can also be set manually. |
values | (array, len = n_pos) Values at the vertices. |
verbose | (bool, str, int, or None) See above. |
vertices | (array, len = n_pos) Vertex indices (0 based) |
Methods
__add__ (other) |
Add BiHemiLabels. |
__hash__ () <==> hash(x) |
|
__len__ () |
Return the number of vertices. |
__sub__ (other) |
Subtract BiHemiLabels. |
center_of_mass ([subject, restrict_vertices, …]) |
Compute the center of mass of the label. |
copy () |
Copy the label instance. |
fill (src[, name]) |
Fill the surface between sources for a source space label. |
get_tris (tris[, vertices]) |
Get the source space’s triangles inside the label. |
get_vertices_used ([vertices]) |
Get the source space’s vertices inside the label. |
morph ([subject_from, subject_to, smooth, …]) |
Morph the label. |
save (filename) |
Write to disk as FreeSurfer *.label file. |
smooth ([subject, smooth, grade, …]) |
Smooth the label. |
split ([parts, subject, subjects_dir, freesurfer]) |
Split the Label into two or more parts. |
__hash__
() <==> hash(x)¶center_of_mass
(subject=None, restrict_vertices=False, subjects_dir=None, surf=’sphere’)[source]¶Compute the center of mass of the label.
This function computes the spatial center of mass on the surface as in [R15].
Parameters: | subject : string | None
restrict_vertices : bool | array of int | instance of SourceSpaces
subjects_dir : str, or None
surf : str
|
---|---|
Returns: | vertex : int
|
See also
Notes
References
[R15] | (1, 2) Larson and Lee, “The cortical dynamics underlying effective switching of auditory spatial attention”, NeuroImage 2012. |
fill
(src, name=None)[source]¶Fill the surface between sources for a source space label.
Parameters: | src : SourceSpaces
name : None | str
|
---|---|
Returns: | label : Label
|
get_tris
(tris, vertices=None)[source]¶Get the source space’s triangles inside the label.
Parameters: | tris : ndarray of int, shape (n_tris, 3)
vertices : ndarray of int, shape (n_vertices,) | None
|
---|---|
Returns: | label_tris : ndarray of int, shape (n_tris, 3)
|
get_vertices_used
(vertices=None)[source]¶Get the source space’s vertices inside the label.
Parameters: | vertices : ndarray of int, shape (n_vertices,) | None
|
---|---|
Returns: | label_verts : ndarray of in, shape (n_label_vertices,)
|
morph
(subject_from=None, subject_to=None, smooth=5, grade=None, subjects_dir=None, n_jobs=1, verbose=None)[source]¶Morph the label.
Useful for transforming a label from one subject to another.
Parameters: | subject_from : str | None
subject_to : str
smooth : int
grade : int, list (of two arrays), array, or None
subjects_dir : string, or None
n_jobs : int
verbose : bool, str, int, or None
|
---|---|
Returns: | label : instance of Label
|
Notes
This function will set label.pos to be all zeros. If the positions on the new surface are required, consider using mne.read_surface with label.vertices.
save
(filename)[source]¶Write to disk as FreeSurfer *.label file.
Parameters: | filename : string
|
---|
Notes
Note that due to file specification limitations, the Label’s subject and color attributes are not saved to disk.
smooth
(subject=None, smooth=2, grade=None, subjects_dir=None, n_jobs=1, verbose=None)[source]¶Smooth the label.
Useful for filling in labels made in a decimated source space for display.
Parameters: | subject : str | None
smooth : int
grade : int, list (of two arrays), array, or None
subjects_dir : string, or None
n_jobs : int
verbose : bool, str, int, or None
|
---|---|
Returns: | label : instance of Label
|
Notes
This function will set label.pos to be all zeros. If the positions on the new surface are required, consider using mne.read_surface with label.vertices.
split
(parts=2, subject=None, subjects_dir=None, freesurfer=False)[source]¶Split the Label into two or more parts.
Parameters: | parts : int >= 2 | tuple of str | str
subject : None | str
subjects_dir : None | str
freesurfer : bool
|
---|---|
Returns: | labels : list of Label (len = n_parts)
|
Notes
If using ‘contiguous’ split, you must ensure that the label being split
uses the same triangular resolution as the surface mesh files in
subjects_dir
Also, some small fringe labels may be returned that
are close (but not connected) to the large components.
The spatial split finds the label’s principal eigen-axis on the spherical surface, projects all label vertex coordinates onto this axis, and divides them at regular spatial intervals.