mne.channels.DigMontage

class mne.channels.DigMontage(dev_head_t=None, dig=None, ch_names=None)[source]

Montage for digitized electrode and headshape position data.

Warning

Montages are typically created using one of the helper functions in the See Also section below instead of instantiating this class directly.

Parameters
dev_head_tarray, shape (4, 4)

A Device-to-Head transformation matrix.

diglist of dict

The object containing all the dig points.

ch_nameslist of str

The names of the EEG channels.

Notes

New in version 0.9.0.

Methods

__add__(other)

Add two DigMontages.

__hash__(/)

Return hash(self).

add_estimated_fiducials(subject[, …])

Estimate fiducials based on FreeSurfer fsaverage subject.

copy()

Copy the DigMontage object.

get_positions()

Get all channel and fiducial positions.

plot([scale_factor, show_names, kind, show, …])

Plot a montage.

rename_channels(mapping[, allow_duplicates])

Rename the channels.

save(fname)

Save digitization points to FIF.

__add__(other)[source]

Add two DigMontages.

add_estimated_fiducials(subject, subjects_dir=None, verbose=None)[source]

Estimate fiducials based on FreeSurfer fsaverage subject.

This takes a montage with the mri coordinate frame, corresponding to the FreeSurfer RAS (xyz in the volume) T1w image of the specific subject. It will call mne.coreg.get_mni_fiducials() to estimate LPA, RPA and Nasion fiducial points.

Parameters
subjectstr

The FreeSurfer subject name.

subjects_dirstr | None

The path to the FreeSurfer subjects reconstructions. It corresponds to FreeSurfer environment variable SUBJECTS_DIR.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.

Returns
instinstance of DigMontage

The instance, modified in-place.

Notes

Since MNE uses the FIF data structure, it relies on the head coordinate frame. Any coordinate frame can be transformed to head if the fiducials (i.e. LPA, RPA and Nasion) are defined. One can use this function to estimate those fiducials and then use montage.get_native_head_t() to get the head <-> MRI transform.

copy()[source]

Copy the DigMontage object.

Returns
diginstance of DigMontage

The copied DigMontage instance.

get_positions()[source]

Get all channel and fiducial positions.

Returns
positionsdict

A dictionary of the positions for channels (ch_pos), coordinate frame (coord_frame), nasion (nasion), left preauricular point (lpa), right preauricular point (rpa), Head Shape Polhemus (hsp), and Head Position Indicator(hpi). E.g.:

{
    'ch_pos': {'EEG061': [0, 0, 0]},
    'nasion': [0, 0, 1],
    'coord_frame': 'mni_tal',
    'lpa': [0, 1, 0],
    'rpa': [1, 0, 0],
    'hsp': None,
    'hpi': None
}

Examples using get_positions:

plot(scale_factor=20, show_names=True, kind='topomap', show=True, sphere=None, verbose=None)[source]

Plot a montage.

Parameters
scale_factorfloat

Determines the size of the points.

show_namesbool

Whether to show the channel names.

kindstr

Whether to plot the montage as ‘3d’ or ‘topomap’ (default).

showbool

Show figure if True.

spherefloat | array_like | str | None

The sphere parameters to use for the cartoon head. Can be array-like of shape (4,) to give the X/Y/Z origin and radius in meters, or a single float to give the radius (origin assumed 0, 0, 0). Can also be a spherical ConductorModel, which will use the origin and radius. Can be “auto” to use a digitization-based fit. Can also be None (default) to use ‘auto’ when enough extra digitization points are available, and 0.095 otherwise. Currently the head radius does not affect plotting.

New in version 0.20.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.

Returns
figinstance of matplotlib.figure.Figure

The figure object.

Examples using plot:

rename_channels(mapping, allow_duplicates=False)[source]

Rename the channels.

Parameters
mappingdict | callable()

A dictionary mapping the old channel to a new channel name e.g. {‘EEG061’ : ‘EEG161’}. Can also be a callable function that takes and returns a string.

Changed in version 0.10.0: Support for a callable function.

allow_duplicatesbool

If True (default False), allow duplicates, which will automatically be renamed with -N at the end.

New in version 0.22.0.

Returns
instinstance of DigMontage

The instance. Operates in-place.

Examples using rename_channels:

save(fname)[source]

Save digitization points to FIF.

Parameters
fnamestr

The filename to use. Should end in .fif or .fif.gz.

Examples using save: