mne.Forward#

class mne.Forward[source]#

Forward class to represent info from forward solution.

Like mne.Info, this data structure behaves like a dictionary. It contains all metadata necessary for a forward solution.

Warning

This class should not be modified or created by users. Forward objects should be obtained using mne.make_forward_solution() or mne.read_forward_solution().

Attributes:
ch_nameslist of str

A convenience wrapper accessible as fwd.ch_names which wraps fwd['info']['ch_names'].

Methods

copy()

Copy the Forward instance.

pick_channels(ch_names[, ordered])

Pick channels from this forward operator.

save(fname, *[, overwrite, verbose])

Save the forward solution.

Notes

Forward data is accessible via string keys using standard dict access (e.g., fwd['nsource'] == 4096):

source_oriint

The source orientation, either FIFF.FIFFV_MNE_FIXED_ORI or FIFF.FIFFV_MNE_FREE_ORI.

coord_frameint

The coordinate frame of the forward solution, usually FIFF.FIFFV_COORD_HEAD.

nsourceint

The number of source locations.

nchanint

The number of channels.

soldict

The forward solution, with entries:

'data'ndarray, shape (n_channels, nsource * n_ori)

The forward solution data. The shape will be (n_channels, nsource) for a fixed-orientation forward and (n_channels, nsource * 3) for a free-orientation forward.

'row_names'list of str

The channel names.

mri_head_tinstance of Transform

The mri ↔ head transformation that was used.

infoinstance of Info

The measurement information (with contents reduced compared to that of the original data).

srcinstance of SourceSpaces

The source space used during forward computation. This can differ from the original source space as:

  1. Source points are removed due to proximity to (or existing outside) the inner skull surface.

  2. The source space will be converted to the coord_frame of the forward solution, which typically means it gets converted from MRI to head coordinates.

source_rrndarray, shape (n_sources, 3)

The source locations.

source_nnndarray, shape (n_sources, 3)

The source normals. Will be all +Z ((0, 0, 1.)) for volume source spaces. For surface source spaces, these are normal to the cortical surface.

surf_oriint

Whether sol is surface-oriented with the surface normal in the Z component (FIFF.FIFFV_MNE_FIXED_ORI) or +Z in the given coord_frame in the Z component (FIFF.FIFFV_MNE_FREE_ORI).

Forward objects also have some attributes that are accessible via . access, like fwd.ch_names.

copy()[source]#

Copy the Forward instance.

pick_channels(ch_names, ordered=False)[source]#

Pick channels from this forward operator.

Parameters:
ch_nameslist of str

List of channels to include.

orderedbool

If true (default False), treat include as an ordered list rather than a set.

Returns:
fwdinstance of Forward.

The modified forward model.

Notes

Operates in-place.

New in v0.20.0.

save(fname, *, overwrite=False, verbose=None)[source]#

Save the forward solution.

Parameters:
fnamepath-like

File name to save the forward solution to. It should end with -fwd.fif or -fwd.fif.gz to save to FIF, or -fwd.h5 to save to HDF5.

overwritebool

If True (default False), overwrite the destination file if it exists.

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.

Examples using mne.Forward#

Getting started with mne.Report

Getting started with mne.Report