InvBeamformer
Namespace: INVLIB · Library: Inverse Library
#include <inv/inv_beamformer.h>
class INVLIB::InvBeamformer
Stores pre-computed beamformer spatial filter weights and associated metadata.
For LCMV: weights is a single matrix (n_sources * n_orient, n_channels). For DICS: weights is a vector of matrices, one per frequency bin.
This class is the C++ equivalent of MNE-Python's Beamformer dict.
Computed beamformer spatial filter container.
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
Public Methods
InvBeamformer()
Default constructor — produces an empty (invalid) beamformer.
isValid()
Returns true if this beamformer contains valid filter weights.
Returns:
- bool — True if filter weights are present, false for a default-constructed beamformer.
nSources()
Returns the number of source points.
Returns:
- int — Number of source points covered by the filter weights.
nChannels()
Returns the number of channels.
Returns:
- int — Number of sensor channels the filter weights apply to.
nOrient()
Returns the number of orientations per source (1 or 3).
Returns:
- int — 1 for fixed or max-power orientation, 3 for free orientation.
nFreqs()
Returns the number of frequency bins (1 for LCMV, >= 1 for DICS).
Returns:
- int — Number of frequency bins with separate filter weights.
Example
- Full source:
src/examples/ex_inv_beamformer/main.cpp - Build target:
ex_inv_beamformer(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_inv_beamformer
Inverse library: LCMV and DICS beamformers and the RAP-MUSIC family of dipole scanners.
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
- Christoph Dinh <christoph.dinh@mne-cpp.org>