Skip to main content

InvResolutionMatrix

Namespace: INVLIB  ·  Library: Inverse Library

Python equivalent

mne.minimum_norm.make_inverse_resolution_matrix in MNE-Python.

#include <inv/inv_resolution_matrix.h>

class INVLIB::InvResolutionMatrix

Resolution matrix analysis for linear inverse operators.

The resolution matrix R = K · L, where K is the inverse operator (kernel) and L is the lead field (forward operator). Columns of R are point-spread functions (PSFs) and rows are cross-talk functions (CTFs).

src/examples/ex_inv_api/main.cpp
InvMinimumNorm mne(inverse, lambda2, "MNE");
mne.doInverseSetup(evoked.nave);
const MatrixXd& kernel = mne.getKernel(); // 210 source components x 364 good channels
const MNEForwardSolution goodFwd = fwd.pick_channels(inverse.noise_cov->names);
const MatrixXd resolution = InvResolutionMatrix::compute(kernel, goodFwd.sol->data);

Static Methods​

compute(matInverseKernel, matLeadField)​

Compute the resolution matrix R = inverseKernel × leadField.

Parameters:

  • matInverseKernel : const Eigen::MatrixXd & Inverse operator matrix (n_sources × n_channels).

  • matLeadField : const Eigen::MatrixXd & Forward operator / lead field (n_channels × n_sources).

Returns:

  • Eigen::MatrixXd — Resolution matrix (n_sources × n_sources).

getPsf(matResolution, iSourceIdx)​

Extract the point-spread function (PSF) for a given source index.

The PSF is the column of the resolution matrix at the source index.

Parameters:

  • matResolution : const Eigen::MatrixXd & Resolution matrix (n_sources × n_sources).

  • iSourceIdx : int Source index.

Returns:

  • Eigen::VectorXd — PSF vector (n_sources).

getCtf(matResolution, iSourceIdx)​

Extract the cross-talk function (CTF) for a given source index.

The CTF is the row of the resolution matrix at the source index.

Parameters:

  • matResolution : const Eigen::MatrixXd & Resolution matrix (n_sources × n_sources).

  • iSourceIdx : int Source index.

Returns:

  • Eigen::VectorXd — CTF vector (n_sources).

getPsfs(matResolution, vecSourceIdx)​

Extract PSFs for multiple source indices.

Parameters:

  • matResolution : const Eigen::MatrixXd & Resolution matrix.

  • vecSourceIdx : const Eigen::VectorXi & Source indices.

Returns:

  • Eigen::MatrixXd — Matrix where each column is a PSF (n_sources × n_indices).

getCtfs(matResolution, vecSourceIdx)​

Extract CTFs for multiple source indices.

Parameters:

  • matResolution : const Eigen::MatrixXd & Resolution matrix.

  • vecSourceIdx : const Eigen::VectorXi & Source indices.

Returns:

  • Eigen::MatrixXd — Matrix where each row is a CTF (n_indices × n_sources).

spatialSpread(matResolution, matPositions)​

Compute spatial spread (peak-width) metric for each source.

The spatial deviation "sd_ext" of mne.minimum_norm.resolution_metrics: the root-mean-square distance from the true source, weighted by the squared PSF. Pass the transposed resolution matrix for the CTF metric. Distances are in the units of matPositions (mne reports cm).

Parameters:

  • matResolution : const Eigen::MatrixXd & Resolution matrix (n_sources × n_sources).

  • matPositions : const Eigen::MatrixX3d & Source positions (n_sources × 3).

Returns:

  • Eigen::VectorXd — Spatial spread per source (n_sources).

peakLocalisationError(matResolution, matPositions)​

Compute peak localisation error for each source.

Distance between true source location and the location of the maximum of the PSF ("peak_err" of mne.minimum_norm.resolution_metrics; pass the transposed resolution matrix for the CTF metric).

Parameters:

  • matResolution : const Eigen::MatrixXd & Resolution matrix (n_sources × n_sources).

  • matPositions : const Eigen::MatrixX3d & Source positions (n_sources × 3).

Returns:

  • Eigen::VectorXd — Peak localisation error per source (n_sources).

Example​

Used in examples​

ex_inv_api​

Inverse library: minimum-norm estimates, resolution matrices, label time courses, sparse solvers.

src/examples/ex_inv_api/main.cpp, line 143
mne.doInverseSetup(evoked.nave);
const MatrixXd& kernel = mne.getKernel(); // 210 source components x 364 good channels
const MNEForwardSolution goodFwd = fwd.pick_channels(inverse.noise_cov->names);
const MatrixXd resolution = InvResolutionMatrix::compute(kernel, goodFwd.sol->data);
// mne.minimum_norm.make_inverse_resolution_matrix(fwd, inv, "MNE", 1/9): 210 x 210, Frobenius norm 6.13353
ok &= expect(resolution.rows() == 210 && resolution.cols() == 210 && near(resolution.norm(), 6.13352636100184, 1e-4),
"InvResolutionMatrix: MNE resolution matrix matches mne.minimum_norm.make_inverse_resolution_matrix");

Authors of this file​