Skip to main content

InvLCMV

Namespace: INVLIB  ·  Library: Inverse Library

Python equivalent

mne.beamformer.make_lcmv / apply_lcmv in MNE-Python.

#include <inv/inv_lcmv.h>

class INVLIB::InvLCMV

Linearly Constrained Minimum Variance (LCMV) beamformer for MEG/EEG source localization.

Typical workflow:

LCMV beamformer (time-domain).

src/examples/ex_inv_beamformer/main.cpp
FiffCov dataCov = noiseCov; // noise plus the two sources
dataCov.data += g1 * g1.transpose() + g2 * g2.transpose();
const InvBeamformer lcmv = InvLCMV::makeLCMV(info, fwd, dataCov, 0.05, noiseCov,
BeamformerPickOri::MaxPower, BeamformerWeightNorm::UnitNoiseGain);
const VectorXd lcmvPower = InvLCMV::applyLCMVCov(dataCov, lcmv).data.col(0); // one value per source

Static Methods​

makeLCMV(info, forward, dataCov, reg, noiseCov, pickOri, weightNorm, reduceRank, invMethod)​

Compute LCMV beamformer spatial filters.

Parameters:

  • info : const FiffInfo & Measurement info (for channel matching).

  • forward : const MNEForwardSolution & Forward solution containing the leadfield.

  • dataCov : const FiffCov & Data covariance matrix (from recording epoch).

  • reg : double Regularization parameter (default 0.05 = 5% of trace).

  • noiseCov : const FiffCov & Noise covariance for whitening. If empty, identity whitening.

  • pickOri : BeamformerPickOri Orientation selection mode (default: None = keep all).

  • weightNorm : BeamformerWeightNorm Weight normalization (default: UnitNoiseGain).

  • reduceRank : bool Reduce leadfield rank by 1 (default: false).

  • invMethod : BeamformerInversion Inversion method for denominator (default: Matrix).

Returns:

  • InvBeamformer — The computed beamformer containing spatial filter weights.

applyLCMV(evoked, filters)​

Apply LCMV beamformer to evoked data to produce source time courses.

stc = W @ (whitener @ proj @ evoked.data)

Parameters:

  • evoked : const FiffEvoked & Evoked data (averaged, channel x time).

  • filters : const InvBeamformer & Pre-computed LCMV beamformer from makeLCMV().

Returns:


applyLCMVRaw(data, tmin, tstep, filters)​

Apply LCMV beamformer to raw data matrix.

Parameters:

  • data : const Eigen::MatrixXd & Data matrix (n_channels, n_times).

  • tmin : float Start time in seconds.

  • tstep : float Time step in seconds.

  • filters : const InvBeamformer & Pre-computed LCMV beamformer from makeLCMV().

Returns:


applyLCMVCov(dataCov, filters)​

Apply LCMV beamformer to a data covariance to produce a source power map.

power_i = trace(W_i @ Cm @ W_i^T)

Parameters:

  • dataCov : const FiffCov & Data covariance matrix.

  • filters : const InvBeamformer & Pre-computed LCMV beamformer from makeLCMV().

Returns:

  • InvSourceEstimate — Source estimate where data column 0 contains power at each source.

applyLCMVEpochs(epochs, tmin, tstep, filters)​

Apply LCMV beamformer to a list of epochs.

Parameters:

  • epochs : const QList< Eigen::MatrixXd > & List of epoch data matrices (n_channels x n_times each).

  • tmin : float Start time of each epoch (seconds).

  • tstep : float Time step (1/sfreq).

  • filters : const InvBeamformer & Pre-computed LCMV beamformer from makeLCMV().

Returns:


makeLCMVResolutionMatrix(forward, info, dataCov, reg, noiseCov)​

Compute the LCMV resolution matrix: R = W @ G.

The resolution matrix describes the point-spread function of the beamformer. Each row shows how a unit source at one location maps through the forward model and back through the beamformer. Ideally R = I (perfect resolution).

Parameters:

  • forward : const MNEForwardSolution & Forward solution with leadfield.

  • info : const FiffInfo & Measurement info.

  • dataCov : const FiffCov & Data covariance.

  • reg : double Regularization (default 0.05).

  • noiseCov : const FiffCov & Noise covariance for whitening (optional).

Returns:

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

Example​

Used in examples​

ex_inv_beamformer​

Inverse library: LCMV and DICS beamformers and the RAP-MUSIC family of dipole scanners.

src/examples/ex_inv_beamformer/main.cpp, line 126
FiffCov dataCov = noiseCov; // noise plus the two sources
dataCov.data += g1 * g1.transpose() + g2 * g2.transpose();
const InvBeamformer lcmv = InvLCMV::makeLCMV(info, fwd, dataCov, 0.05, noiseCov,
BeamformerPickOri::MaxPower, BeamformerWeightNorm::UnitNoiseGain);
const VectorXd lcmvPower = InvLCMV::applyLCMVCov(dataCov, lcmv).data.col(0); // one value per source
// mne.beamformer.make_lcmv(..., pick_ori="max-power", weight_norm="unit-noise-gain") + apply_lcmv_cov:
// sum 117.705, source 10 16.5306, source 50 3.92173
Index lcmvBest = 0;
lcmvPower.maxCoeff(&lcmvBest);
ok &= expect(lcmv.isValid() && lcmvPower.size() == 70 && lcmvBest == 10 && near(lcmvPower.sum(), 117.70495401512653, 1e-5) && near(lcmvPower(10), 16.530644994286707, 1e-5) && near(lcmvPower(50), 3.9217347708280537, 1e-5),
"InvLCMV/InvBeamformer: max-power LCMV power on V1 matches mne.beamformer.apply_lcmv_cov");

Authors of this file​