Skip to main content

MNEMneData

Namespace: MNELIB  ·  Library: MNE Library

Python equivalent

mne.minimum_norm.estimate_snr in MNE-Python.

#include <mne/mne_mne_data.h>

class MNELIB::MNEMneData

Implements MNE Mne Data (Replaces *mneMneData,mneMneDataRec; struct of MNE-C mne_types.h).

Data associated with MNE computations for each mneMeasDataSet

src/examples/ex_inv_api/main.cpp
const MNEMneData perTime = dspm.mneData(evoked); // lambda2 estimated per time point (MNE-C mne_analyze)
const MNEMneData atSnr3 = dspm.mneData(evoked, 9.0); // power SNR 9: lambda2 = mean(sing^2) / 9
const VectorXd amplitudeSnr = perTime.SNR.cwiseSqrt(); // == mne.minimum_norm.estimate_snr's snr
const MatrixXd residual = evoked.pick_channels(inverse.noise_cov->names).data - atSnr3.predicted;

Public Methods​

MNEMneData()​

Constructs the MNEMneData.


~MNEMneData()​

Destroys the MNEMneData.


computeRegularization(inv, data)​

Projects the whitened data on the eigenfields (MNE-C mne_project_to_eigen_fields) and estimates SNR and lambda2_est per time point (MNE-C compute_regularization, noise method).

SNR is the power of the whitened data per non-zero noise eigenvalue (the square of mne.minimum_norm.estimate_snr's snr). lambda2_est is 100 where SNR < 1; elsewhere it starts at 10 and shrinks by 0.9 until the squared prediction error of the whitened data falls below the chi^2 point at p = 0.001 with one degree of freedom less than the components used.

Parameters:

  • inv : const MNEInverseOperator & A prepared inverse operator.

  • data : const Eigen::MatrixXd & Measured data, one row per channel of inv, one column per time.


selectRegularization(inv, snr)​

Selects lambda2 per time point (MNE-C select_regularization): trace_ratio / snr for a positive power SNR, lambda2_est otherwise.

trace_ratio is the mean squared singular value.

Parameters:

  • inv : const MNEInverseOperator & The prepared inverse operator used for computeRegularization.

  • snr : double Power SNR, <= 0 to use lambda2_est.


computePredicted(inv)​

Computes the data the minimum-norm estimate predicts with the selected lambda2, colored back to the sensors (MNE-C compute_predicted_data; the data part of mne.minimum_norm.apply_inverse's residual).

Parameters:

  • inv : const MNEInverseOperator & The prepared inverse operator used for computeRegularization.

Static Methods​

compute(inv, data, snr)​

Fills all fields for one data set: projects it on the eigenfields, estimates the SNR and lambda2 per time point, selects the lambda2 to use and computes the predicted data.

Parameters:

  • inv : const MNEInverseOperator & An inverse operator prepared with MNEInverseOperator::prepare_inverse_operator.

  • data : const Eigen::MatrixXd & Measured data, one row per channel of inv in its order, one column per time.

  • snr : double Power SNR for a fixed lambda2 (see selectRegularization), <= 0 to use lambda2_est.

Returns:


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 131
const MNEMneData perTime = dspm.mneData(evoked); // lambda2 estimated per time point (MNE-C mne_analyze)
const MNEMneData atSnr3 = dspm.mneData(evoked, 9.0); // power SNR 9: lambda2 = mean(sing^2) / 9
const VectorXd amplitudeSnr = perTime.SNR.cwiseSqrt(); // == mne.minimum_norm.estimate_snr's snr
const MatrixXd residual = evoked.pick_channels(inverse.noise_cov->names).data - atSnr3.predicted;
// SNR = sum(whitened^2) / rank, the lambda2 search = MNE-C noise_regularization (both in numpy);
// predicted = data - apply_inverse(evoked, inv, mean(sing**2) / 9, "MNE", return_residual=True)[1]
ok &= expect(near(perTime.SNR.sum(), 146652.3428555677, 1e-6) && near(amplitudeSnr(100), std::sqrt(354.67510619465145), 1e-6) && near(perTime.lambda2.sum(), 3.26430206181887e-11, 1e-6) && near(atSnr3.lambda2(0), 0.19047619047619055, 1e-9) && near(atSnr3.predicted.cwiseAbs().sum(), 0.047335931752795365, 1e-6) && residual.rows() == 364,
"MNEMneData: SNR, lambda2 and predicted data match mne.minimum_norm.estimate_snr / apply_inverse");

Authors of this file​