# mne.SourceMorph¶

class mne.SourceMorph(subject_from, subject_to, kind, zooms, niter_affine, niter_sdr, spacing, smooth, xhemi, morph_mat, vertices_to, shape, affine, pre_affine, sdr_morph, src_data, vol_morph_mat, verbose=None)[source]

Morph source space data from one subject to another.

Note

This class should not be instantiated directly. Use mne.compute_source_morph() instead.

Parameters
subject_from

Name of the subject from which to morph as named in the SUBJECTS_DIR.

subject_to

Name of the subject on which to morph as named in the SUBJECTS_DIR. The default is ‘fsaverage’. If morphing a volume source space, subject_to can be the path to a MRI volume. Can also be a list of two arrays if morphing to hemisphere surfaces.

kind

Kind of source estimate. E.g. ‘volume’ or ‘surface’.

zooms
niter_affine

Number of levels (len(niter_affine)) and number of iterations per level - for each successive stage of iterative refinement - to perform the affine transform.

niter_sdr

Number of levels (len(niter_sdr)) and number of iterations per level - for each successive stage of iterative refinement - to perform the Symmetric Diffeomorphic Registration (sdr) transform 1.

spacing
smooth
xhemibool

Morph across hemisphere.

morph_matscipy.sparse.csr_matrix

The sparse surface morphing matrix for spherical surface based morphing 2.

vertices_to

The destination surface vertices.

shapetuple

The volume MRI shape.

affinendarray

The volume MRI affine.

pre_affineinstance of dipy.align.imaffine.AffineMap

The dipy.align.imaffine.AffineMap transformation that is applied before the before sdr_morph.

sdr_morphinstance of dipy.align.imwarp.DiffeomorphicMap

The dipy.align.imwarp.DiffeomorphicMap that applies the the symmetric diffeomorphic registration (SDR) morph.

src_datadict

Additional source data necessary to perform morphing.

vol_morph_mat

The volumetric morph matrix, if compute_vol_morph_mat() was used.

verbose

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.

Notes

New in version 0.17.

References

1

Brian B. Avants, Charles L. Epstein, Murray C. Grossman, and James C. Gee. Symmetric diffeomorphic image registration with cross-correlation: evaluating automated labeling of elderly and neurodegenerative brain. Medical Image Analysis, 12(1):26–41, 2008. doi:10.1016/j.media.2007.06.004.

2

Douglas N. Greve, Lise Van der Haegen, Qing Cai, Steven Stufflebeam, Mert R. Sabuncu, Bruce Fischl, and Marc Brysbaert. A surface-based analysis of language lateralization and cortical asymmetry. Journal of Cognitive Neuroscience, 25(9):1477–1492, 2013. doi:10.1162/jocn_a_00405.

Methods

 __hash__(/) Return hash(self). apply(stc_from[, output, mri_resolution, …]) Morph source space data. compute_vol_morph_mat(*[, verbose]) Compute the sparse matrix representation of the volumetric morph. save(fname[, overwrite, verbose]) Save the morph for source estimates to a file.
apply(stc_from, output='stc', mri_resolution=False, mri_space=None, verbose=None)[source]

Morph source space data.

Parameters
stc_from

The source estimate to morph.

outputstr

Can be ‘stc’ (default) or possibly ‘nifti1’, or ‘nifti2’ when working with a volume source space defined on a regular grid.

mri_resolution

If True the image is saved in MRI resolution. Default False. WARNING: if you have many time points the file produced can be huge. The default is mri_resolution=False.

mri_space

Whether the image to world registration should be in mri space. The default (None) is mri_space=mri_resolution.

verbose

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. Defaults to self.verbose.

Returns
stc_to

The morphed source estimates.

Examples using apply:

compute_vol_morph_mat(*, verbose=None)[source]

Compute the sparse matrix representation of the volumetric morph.

Parameters
verbose

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. Defaults to self.verbose.

Returns
morphinstance of SourceMorph

The instance (modified in-place).

Notes

For a volumetric morph, this will compute the morph for an identity source volume, i.e., with one source vertex active at a time, and store the result as a sparse morphing matrix. This takes a long time (minutes) to compute initially, but drastically speeds up apply() for STCs, so it can be beneficial when many time points or many morphs (i.e., greater than the number of volumetric src_from vertices) will be performed.

When calling save(), this sparse morphing matrix is saved with the instance, so this only needs to be called once. This function does nothing if the morph matrix has already been computed, or if there is no volume morphing necessary.

New in version 0.22.

Examples using compute_vol_morph_mat:

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

Save the morph for source estimates to a file.

Parameters
fnamestr

The stem of the file name. ‘-morph.h5’ will be added if fname does not end with ‘.h5’.

overwritebool

If True, overwrite existing file.

verbose

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. Defaults to self.verbose.