SourceMorph
Namespace: INVLIB · Library: Inverse Library
mne.SourceMorph in MNE-Python.
#include <inv/source_morph.h>
class INVLIB::SourceMorph
Morphs source estimates from one subject's source space to another.
Usage:
// Morph the 70 V1 sources onto 35 targets by averaging neighbouring pairs (a sphere-based morph map in practice).
SparseMatrix<double> pairAverage(35, 70);
for (int i = 0; i < 35; ++i) {
pairAverage.insert(i, 2 * i) = 0.5;
pairAverage.insert(i, 2 * i + 1) = 0.5;
}
SourceMorph morph;
morph.compute(stc.vertices, VectorXi::LinSpaced(35, 0, 34), pairAverage);
const InvSourceEstimate morphed = morph.apply(stc);
Public Methods
SourceMorph()
compute(verticesFrom, verticesTo, morphMap)
Compute the morphing transformation.
Builds a sparse interpolation matrix that maps source estimate data from one vertex set to another using nearest-neighbor interpolation.
Parameters:
-
verticesFrom : const Eigen::VectorXi & Source vertices in the "from" subject's source space.
-
verticesTo : const Eigen::VectorXi & Target vertices in the "to" subject's source space.
-
morphMap : const Eigen::SparseMatrix< double > & Sparse interpolation matrix (nTo x nFrom), e.g. MNEMorphMap::toEigen().
apply(stcFrom)
Apply the morphing to a source estimate.
Parameters:
- stcFrom : const InvSourceEstimate & Source estimate in the "from" subject's space.
Returns:
- InvSourceEstimate — Morphed source estimate in the "to" subject's space.
isComputed()
Check if the morph has been computed.
Returns:
- bool — True if the morph matrix is available for
apply().
nVerticesTo()
Get the number of target vertices.
Returns:
- int — Number of vertices in the target subject's source space.
Example
- Full source:
src/examples/ex_inv_api/main.cpp - Build target:
ex_inv_api(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_inv_api
Inverse library: minimum-norm estimates, resolution matrices, label time courses, sparse solvers.
SourceMorph morph;
morph.compute(stc.vertices, VectorXi::LinSpaced(35, 0, 34), pairAverage);
const InvSourceEstimate morphed = morph.apply(stc);
ok &= expect(morph.isComputed() && morphed.data.rows() == 35 && near(morphed.data(3, 200), 0.5 * (stc.data(6, 200) + stc.data(7, 200)), 1e-12),
"SourceMorph: the morph matrix maps every time sample");
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>