mne.label.select_sources#

mne.label.select_sources(subject, label, location='center', extent=0.0, grow_outside=True, subjects_dir=None, name=None, surf='white', *, rng=None, random_state=None)[source]#

Select sources from a label.

Parameters:
subjectstr

The FreeSurfer subject name.

labelinstance of Label | str

Define where the seed will be chosen. If str, can be ‘lh’ or ‘rh’, which correspond to left or right hemisphere, respectively.

location‘random’ | ‘center’ | int

Location to grow label from. If the location is an int, it represents the vertex number in the corresponding label. If it is a str, it can be either ‘random’ or ‘center’.

extentfloat

Extents (radius in mm) of the labels, i.e. maximum geodesic distance on the white matter surface from the seed. If 0, the resulting label will contain only one vertex.

grow_outsidebool

Let the region grow outside the original label where location was defined.

subjects_dirpath-like | None

The path to the directory containing the FreeSurfer subjects reconstructions. If None, defaults to the SUBJECTS_DIR environment variable.

nameNone | str

Assign name to the new label.

surfstr

The surface used to simulated the label, defaults to the white surface.

rngNone | int | instance of Generator | RandomState

The random number generator (RNG). If None (default), a new numpy.random.Generator seeded from entropy is used. Pass an int or a numpy.random.Generator for reproducible results, or a legacy RandomState to control the random-number stream or for interoperability with third-party code such as scikit-learn that does not accept generators. An integer seed uses numpy.random.default_rng() and therefore produces a different stream than the same integer passed to a legacy random_state or seed parameter.

New in v1.13.

random_stateNone | int | instance of RandomState

Supported for compatibility. New code should use rng. If None, NumPy’s global RandomState is used.

Returns:
labelinstance of Label

The label that contains the selected sources.

Notes

This function selects a region of interest on the cortical surface based on a label (or a hemisphere). The sources are selected by growing a region around a seed which is selected randomly, is the center of the label, or is a specific vertex. The selected vertices can extend beyond the initial provided label. This can be prevented by setting grow_outside to False.

The selected sources are returned in the form of a new Label object. The values of the label contain the distance from the seed in millimeters.

New in v0.18.

Examples using mne.label.select_sources#

Compare simulated and estimated source activity

Compare simulated and estimated source activity

Generate simulated source data

Generate simulated source data