mvpure_py.utils#

mvpure_py.utils.algebra#

Functions for computing algebraic expressions.

mvpure_py.utils.algebra.get_pinv_RN_eigenvals(R: ndarray, N: ndarray)[source]#

mvpure_py.utils.translation#

Operations on mne.Forward, mne.SourceSpaces and mapping between vertices and leadfield indices.

mvpure_py.utils.translation.map_vertices_to_fsaverage(locs, hemi: list[str] | str, surf: str = 'white')[source]#

Map vertices from subject-specific surface to fsaverage coordinates for one or both hemispheres. This function wraps _map_vertices_to_fsaverage_for_hemi and allows mapping vertices for either a single hemisphere (‘lh’ or ‘rh’) or both hemispheres simultaneously.

Parameters:
  • locs (mvpure_py.Localized) – mvpure_py.Localized object to map vertices from. After mapping, each vertex in the specified hemisphere(s) will have a new key "morphed_to_fs" storing the corresponding fsaverage vertex index.

  • hemi (list[str] | str) – Which hemisphere to map.

  • surf (str (Default: 'white')) – Surface which coordinates use during mapping.

Raises:

ValueError – If hemi is not one of [‘lh’, ‘rh’, ‘both’].

mvpure_py.utils.translation.subset_forward(old_fwd: Forward, localized, vertices: list[int] = None, hemi: str = 'both') Forward[source]#

Subset old_fwd (mne.Forward) for it to contain information only for certain vertices’ numbers.

Parameters:
  • old_fwd (mne.Forward) – mne.Forward to get subset from

  • hemi (str) – hemisphere(s) containing the dipoles that are expected to be present in mne.Forward subset

Returns:

mne.Forward

Return type:

subset of mne.Forward for given vertices

mvpure_py.utils.translation.transform_leadfield_indices_to_vertices(lf_idx, src: SourceSpaces, hemi: str = 'both', include_mapping: bool = True)[source]#

Transform leadfield 1-axis indices into vertices number using mne.SourceSpaces

Parameters:
  • lf_idx (iterable) – iterable with leadfield indices

  • src (mne.SourceSpace) – source space from forward with corresponding leadfield

  • hemi (str (Default to "both")) – vertices from which hemisphere should be returned. Options are: ‘lh’, ‘rh’ and ‘both’.

Returns:

vertices – markings of vertices which correspond to leadfield matrices

Return type:

list | tuple(list, list)

mvpure_py.utils.translation.transform_vertices_to_leadfield_indices(vertices: list, src: SourceSpaces) list[source]#

Transform vertices numbers (from mne.SourceSpace) to leadfield 1-axis indices.

Parameters:
  • vertices (list) – Markings of vertices which correspond to leadfield indices.

  • src (mne.SourceSpace) – Source space from forward with corresponding leadfield.

Returns:

lf_idx – iterable with leadfield indices

Return type:

list

Module contents#