CMNE inverse solver. More...
#include <inv_cmne.h>
Static Public Member Functions | |
| static InvCMNEResult | compute (const Eigen::MatrixXd &matEvoked, const Eigen::MatrixXd &matGain, const Eigen::MatrixXd &matNoiseCov, const Eigen::MatrixXd &matSrcCov, const InvCMNESettings &settings) |
| static bool | applyCmne (const Eigen::MatrixXd &matDspmData, const QString &onnxModelPath, Eigen::MatrixXd &sensing, Eigen::MatrixXd &prediction, Eigen::MatrixXd &cmne) |
| static Eigen::MatrixXd | controlEstimate (const Eigen::MatrixXd &matDspmData, int lookBack) |
| static Eigen::MatrixXd | zScoreRectify (const Eigen::MatrixXd &matStcData) |
| static UTILSLIB::PythonRunnerResult | trainLstm (const QString &fwdPath, const QString &covPath, const QString &epochsPath, const QString &outOnnxPath, const InvCMNESettings &settings, const QString >StcPrefix={}, int hiddenSize=256, int numLayers=1, int trainEpochs=50, double learningRate=1e-3, int batchSize=64, const QString &finetuneOnnxPath={}, const QString &pythonExe=QStringLiteral("python3")) |
CMNE inverse solver.
Contextual Minimum Norm Estimate (CMNE) inverse solver.
Implements the algorithm from: Dinh et al. "Contextual Minimum-Norm Estimates (CMNE): A Deep Learning Method for Source Estimation in Neuroimaging", 2021.
Definition at line 92 of file inv_cmne.h.
|
static |
Contextual estimate of Eqs. 9-13, as cmne.apply_cmne with normalised weights.
The model must be exported by cmne.export_onnx: look-back, source count and rectification are read from its cmne_config metadata.
| [in] | matDspmData | Signed dSPM estimate (n_sources x n_times). |
| [in] | onnxModelPath | Path to the ONNX model. |
| [out] | sensing | q_t (Eq. 9). |
| [out] | prediction | LSTM prediction (q_t for the first k samples). |
| [out] | cmne | Contextual estimate b_t. |
Definition at line 197 of file inv_cmne.cpp.
|
static |
Compute CMNE inverse solution.
| [in] | matEvoked | Evoked data (n_channels x n_times). |
| [in] | matGain | Forward gain matrix (n_channels x n_sources). |
| [in] | matNoiseCov | Noise covariance (n_channels x n_channels). |
| [in] | matSrcCov | Source covariance (n_sources x n_sources, diagonal). |
| [in] | settings | CMNE settings. |
Definition at line 68 of file inv_cmne.cpp.
|
static |
Control estimate of the paper (cmne.control_estimate): q_t times the mean of q over the previous lookBack samples, without an LSTM.
| [in] | matDspmData | Signed dSPM estimate (n_sources x n_times). |
| [in] | lookBack | Window length k. |
Definition at line 185 of file inv_cmne.cpp.
|
static |
Train the CMNE LSTM model by invoking the Python training script.
This is a convenience wrapper that calls scripts/ml/training/train_cmne_lstm.py via UTILSLIB::PythonRunner. The heavy lifting (PyTorch LSTM training + ONNX export) happens in Python; C++ only launches the process and streams its output.
| [in] | fwdPath | Path to forward solution FIFF file. |
| [in] | covPath | Path to noise covariance FIFF file. |
| [in] | epochsPath | Path to epochs FIFF file. |
| [in] | outOnnxPath | Desired output path for the ONNX model. |
| [in] | settings | CMNE settings (look-back, method, SNR are forwarded). |
| [in] | gtStcPrefix | Ground-truth STC prefix (optional; empty = simulation mode). |
| [in] | hiddenSize | LSTM hidden dimension (default 256). |
| [in] | numLayers | LSTM layers (default 1). |
| [in] | trainEpochs | Number of training epochs (default 50). |
| [in] | learningRate | Learning rate (default 1e-3). |
| [in] | batchSize | Batch size (default 64). |
| [in] | finetuneOnnxPath | Existing ONNX model to fine-tune from (optional). |
| [in] | pythonExe | Python interpreter (default "python3"). |
Definition at line 245 of file inv_cmne.cpp.
|
static |
Rectify and z-score each source over time (Eq. 9).
| [in] | matStcData | Source data (n_sources x n_times). |
Definition at line 178 of file inv_cmne.cpp.