mne.viz.plot_alignment#

mne.viz.plot_alignment(info=None, trans=None, subject=None, subjects_dir=None, surfaces='auto', coord_frame='auto', meg=None, eeg='original', fwd=None, dig=False, ecog=True, src=None, mri_fiducials=False, bem=None, seeg=True, fnirs=True, show_axes=False, dbs=True, fig=None, interaction='terrain', sensor_colors=None, *, sensor_scales=None, verbose=None)[source]#

Plot head, sensor, and source space alignment in 3D.

Parameters:
infomne.Info | None

The mne.Info object with information about the sensors and methods of measurement. If None (default), no sensor information will be shown.

transpath-like | dict | instance of Transform | "fsaverage" | None

If str, the path to the head<->MRI transform *-trans.fif file produced during coregistration. Can also be 'fsaverage' to use the built-in fsaverage transformation. If trans is None, an identity matrix is assumed. “auto” will load trans from the FreeSurfer directory specified by subject and subjects_dir parameters.

Changed in version 0.19: Support for ‘fsaverage’ argument.

subjectstr

The FreeSurfer subject name. Can be omitted if src is provided.

subjects_dirpath-like | None

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

surfacesstr | list | dict

Surfaces to plot. Supported values:

  • scalp: one of ‘head’, ‘outer_skin’ (alias for ‘head’), ‘head-dense’, or ‘seghead’ (alias for ‘head-dense’)

  • skull: ‘outer_skull’, ‘inner_skull’, ‘brain’ (alias for ‘inner_skull’)

  • brain: one of ‘pial’, ‘white’, ‘inflated’, or ‘brain’ (alias for ‘pial’).

Can be dict to specify alpha values for each surface. Use None to specify default value. Specified values must be between 0 and 1. for example:

surfaces=dict(brain=0.4, outer_skull=0.6, head=None)

Defaults to ‘auto’, which will look for a head surface and plot it if found.

Note

For single layer BEMs it is recommended to use 'brain'.

coord_frame‘auto’ | ‘head’ | ‘meg’ | ‘mri’

The coordinate frame to use. If 'auto' (default), chooses 'mri' if trans was passed, and 'head' otherwise.

Changed in version 1.0: Defaults to 'auto'.

megstr | list | dict | bool | None

Can be “helmet”, “sensors” or “ref” to show the MEG helmet, sensors or reference sensors respectively, or a combination like ('helmet', 'sensors') (same as None, default). True translates to ('helmet', 'sensors', 'ref'). Can also be a dict to specify alpha values, e.g. {"helmet": 0.1, "sensors": 0.8}.

Changed in version 1.6: Added support for specifying alpha values as a dict.

eegbool | str | list | dict

String options are:

  • “original” (default; equivalent to True)

    Shows EEG sensors using their digitized locations (after transformation to the chosen coord_frame)

  • “projected”

    The EEG locations projected onto the scalp, as is done in forward modeling

Can also be a list of these options, or a dict to specify the alpha values to use, e.g. dict(original=0.2, projected=0.8).

Changed in version 1.6: Added support for specifying alpha values as a dict.

fwdinstance of Forward

The forward solution. If present, the orientations of the dipoles present in the forward solution are displayed.

digbool | ‘fiducials’

If True, plot the digitization points; ‘fiducials’ to plot fiducial points only.

ecogbool

If True (default), show ECoG sensors.

srcinstance of SourceSpaces | None

If not None, also plot the source space points.

mri_fiducialsbool | str | path-like

Plot MRI fiducials (default False). If True, look for a file with the canonical name (bem/{subject}-fiducials.fif). If str, it can be 'estimated' to use mne.coreg.get_mni_fiducials(), otherwise it should provide the full path to the fiducials file.

New in v0.22: Support for 'estimated'.

bemlist of dict | instance of ConductorModel | None

Can be either the BEM surfaces (list of dict), a BEM solution or a sphere model. If None, we first try loading '$SUBJECTS_DIR/$SUBJECT/bem/$SUBJECT-$SOURCE.fif', and then look for '$SUBJECT*$SOURCE.fif' in the same directory. For 'outer_skin', the subjects bem and bem/flash folders are searched. Defaults to None.

seegbool

If True (default), show sEEG electrodes.

fnirsstr | list | dict | bool | None

Can be “channels”, “pairs”, “detectors”, and/or “sources” to show the fNIRS channel locations, optode locations, or line between source-detector pairs, or a combination like ('pairs', 'channels'). True translates to ('pairs',). A dict can also be used to specify alpha values (but only “channels” and “pairs” will be used), e.g. dict(channels=0.2, pairs=0.7).

Changed in version 1.6: Added support for specifying alpha values as a dict.

New in v0.20.

show_axesbool

If True (default False), coordinate frame axis indicators will be shown:

  • head in pink.

  • MRI in gray (if trans is not None).

  • MEG in blue (if MEG sensors are present).

New in v0.16.

dbsbool

If True (default), show DBS (deep brain stimulation) electrodes.

figFigure3D | None

PyVista scene in which to plot the alignment. If None, creates a new 600x600 pixel figure with black background.

New in v0.16.

interaction‘trackball’ | ‘terrain’

How interactions with the scene via an input device (e.g., mouse or trackpad) modify the camera position. If 'terrain', one axis is fixed, enabling “turntable-style” rotations. If 'trackball', movement along all axes is possible, which provides more freedom of movement, but you may incidentally perform unintentional rotations along some axes.

New in v0.16.

Changed in version 1.0: Defaults to 'terrain'.

sensor_colorsarray_like of color | dict | None

Colors to use for the sensor glyphs. Can be None (default) to use default colors. A dict should provide the colors (values) for each channel type (keys), e.g.:

dict(eeg=eeg_colors)

Where the value (eeg_colors above) can be broadcast to an array of colors with length that matches the number of channels of that type, i.e., is compatible with matplotlib.colors.to_rgba_array(). A few examples of this for the case above are the string "k", a list of n_eeg color strings, or an NumPy ndarray of shape (n_eeg, 3) or (n_eeg, 4).

Changed in version 1.6: Support for passing a dict was added.

sensor_scalesint | float | array_like | dict | None

Scale to use for the sensor glyphs. Can be None (default) to use default scale. A dict should provide the Scale (values) for each channel type (keys), e.g.:

dict(eeg=eeg_scales)

Where the value (eeg_scales above) can be broadcast to an array of values with length that matches the number of channels of that type. A few examples of this for the case above are the value 10e-3, a list of n_eeg values, or an NumPy ndarray of shape (n_eeg,).

New in v1.9.

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:
figinstance of Figure3D

The figure.

See also

mne.viz.plot_bem

Notes

This function serves the purpose of checking the validity of the many different steps of source reconstruction:

  • Transform matrix (keywords trans, meg and mri_fiducials),

  • BEM surfaces (keywords bem and surfaces),

  • sphere conductor model (keywords bem and surfaces) and

  • source space (keywords surfaces and src).

New in v0.15.

Examples using mne.viz.plot_alignment#

Working with sensor locations

Working with sensor locations

Preprocessing optically pumped magnetometer (OPM) MEG data

Preprocessing optically pumped magnetometer (OPM) MEG data

Source alignment and coordinate frames

Source alignment and coordinate frames

Using an automated approach to coregistration

Using an automated approach to coregistration

Head model and forward computation

Head model and forward computation

EEG forward operator with a template MRI

EEG forward operator with a template MRI

The role of dipole orientations in distributed source localization

The role of dipole orientations in distributed source localization

EEG source localization given electrode locations on an MRI

EEG source localization given electrode locations on an MRI

Brainstorm Elekta phantom dataset tutorial

Brainstorm Elekta phantom dataset tutorial

Brainstorm CTF phantom dataset tutorial

Brainstorm CTF phantom dataset tutorial

4D Neuroimaging/BTi phantom dataset tutorial

4D Neuroimaging/BTi phantom dataset tutorial

KIT phantom dataset tutorial

KIT phantom dataset tutorial

Working with sEEG data

Working with sEEG data

Working with ECoG data

Working with ECoG data

Annotate movement artifacts and reestimate dev_head_t

Annotate movement artifacts and reestimate dev_head_t

How to convert 3D electrode positions to a 2D image

How to convert 3D electrode positions to a 2D image

Plotting EEG sensors on the scalp

Plotting EEG sensors on the scalp

Plotting sensor layouts of MEG systems

Plotting sensor layouts of MEG systems

Plot the MNE brain and helmet

Plot the MNE brain and helmet

Plotting sensor layouts of EEG systems

Plotting sensor layouts of EEG systems

Compute source power spectral density (PSD) of VectorView and OPM data

Compute source power spectral density (PSD) of VectorView and OPM data

Generate a left cerebellum volume source space

Generate a left cerebellum volume source space

Reading an inverse operator

Reading an inverse operator

Kernel OPM phantom data

Kernel OPM phantom data

Optically pumped magnetometer (OPM) data

Optically pumped magnetometer (OPM) data