mne.setup_volume_source_space#

mne.setup_volume_source_space(subject=None, pos=5.0, mri=None, sphere=None, bem=None, surface=None, mindist=5.0, exclude=0.0, subjects_dir=None, volume_label=None, add_interpolator=True, sphere_units='m', single_volume=False, *, n_jobs=None, verbose=None)[source]#

Set up a volume source space with grid spacing or discrete source space.

Parameters:
subjectstr | None

Subject to process. If None, the path to the MRI volume must be absolute to get a volume source space. If a subject name is provided the T1.mgz file will be found automatically. Defaults to None.

posfloat | dict

Positions to use for sources. If float, a grid will be constructed with the spacing given by pos in mm, generating a volume source space. If dict, pos['rr'] and pos['nn'] will be used as the source space locations (in meters) and normals, respectively, creating a discrete source space.

Note

For a discrete source space (pos is a dict), mri must be None.

mripath-like | None

The filename of an MRI volume (mgh or mgz) to create the interpolation matrix over. Source estimates obtained in the volume source space can then be morphed onto the MRI volume using this interpolator. If pos is a dict, this cannot be None. If subject name is provided, pos is a float or volume_label are not provided then the mri parameter will default to 'T1.mgz' or aseg.mgz, respectively, else it will stay None.

spherendarray, shape (4,) | ConductorModel | None

Define spherical source space bounds using origin and radius given by (Ox, Oy, Oz, rad) in sphere_units. Only used if bem and surface are both None. Can also be a spherical ConductorModel, which will use the origin and radius. None (the default) uses a head-digitization fit.

bempath-like | None | ConductorModel

Define source space bounds using a BEM file (specifically the inner skull surface) or a ConductorModel for a 1-layer of 3-layers BEM. See make_bem_model() and make_bem_solution() to create a ConductorModel. If provided, surface must be None.

surfacepath-like | dict | None

Define source space bounds using a FreeSurfer surface file. Can also be a dictionary with entries 'rr' and 'tris', such as those returned by mne.read_surface(). If provided, bem must be None.

mindistfloat

Exclude points closer than this distance (mm) to the bounding surface.

excludefloat

Exclude points closer than this distance (mm) from the center of mass of the bounding surface.

subjects_dirpath-like | None

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

volume_labelstr | dict | list | None

Region(s) of interest to use. None (default) will create a single whole-brain source space. Otherwise, a separate source space will be created for each entry in the list or dict (str will be turned into a single-element list). If list of str, standard Freesurfer labels are assumed. If dict, should be a mapping of region names to atlas id numbers, allowing the use of other atlases.

Changed in version 0.21.0: Support for dict added.

add_interpolatorbool

If True and mri is not None, then an interpolation matrix will be produced.

sphere_unitsstr

Defaults to "m".

New in v0.20.

single_volumebool

If True, multiple values of volume_label will be merged into a a single source space instead of occupying multiple source spaces (one for each sub-volume), i.e., len(src) will be 1 instead of len(volume_label). This can help conserve memory and disk space when many labels are used.

New in v0.21.

n_jobsint | None

The number of jobs to run in parallel. If -1, it is set to the number of CPU cores. Requires the joblib package. None (default) is a marker for ‘unset’ that will be interpreted as n_jobs=1 (sequential execution) unless the call is performed under a joblib.parallel_config context manager that sets another value for n_jobs.

New in v1.6.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns:
srcSourceSpaces

A SourceSpaces object containing one source space for each entry of volume_labels, or a single source space if volume_labels was not specified.

Notes

Volume source spaces are related to an MRI image such as T1 and allow to visualize source estimates overlaid on MRIs and to morph estimates to a template brain for group analysis. Discrete source spaces don’t allow this. If you provide a subject name the T1 MRI will be used by default.

When you work with a source space formed from a grid you need to specify the domain in which the grid will be defined. There are three ways of specifying this: (i) sphere, (ii) bem model, and (iii) surface. The default behavior is to use sphere model (sphere=(0.0, 0.0, 0.0, 90.0)) if bem or surface is not None then sphere is ignored. If you’re going to use a BEM conductor model for forward model it is recommended to pass it here.

To create a discrete source space, pos must be a dict, mri must be None, and volume_label must be None. To create a whole brain volume source space, pos must be a float and ‘mri’ must be provided.

To create a volume source space from label, pos must be a float, volume_label must be provided, and ‘mri’ must refer to a .mgh or .mgz file with values corresponding to the freesurfer lookup-table (typically aseg.mgz).

Examples using mne.setup_volume_source_space#

Setting the EEG reference

Setting the EEG reference

Source alignment and coordinate frames

Source alignment and coordinate frames

Head model and forward computation

Head model and forward computation

Generate a left cerebellum volume source space

Generate a left cerebellum volume source space

Compute MNE inverse solution on evoked data with a mixed source space

Compute MNE inverse solution on evoked data with a mixed source space

Plot point-spread functions (PSFs) for a volume

Plot point-spread functions (PSFs) for a volume