v2.0.0
Loading...
Searching...
No Matches
INVLIB::InvCMNE Class Reference

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 Eigen::MatrixXd applyLstmCorrection (const Eigen::MatrixXd &matDspmData, const QString &onnxModelPath, int lookBack)
static UTILSLIB::PythonRunnerResult trainLstm (const QString &fwdPath, const QString &covPath, const QString &epochsPath, const QString &outOnnxPath, const InvCMNESettings &settings, const QString &gtStcPrefix={}, int hiddenSize=256, int numLayers=1, int trainEpochs=50, double learningRate=1e-3, int batchSize=64, const QString &finetuneOnnxPath={}, const QString &pythonExe=QStringLiteral("python3"))

Detailed Description

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.

Member Function Documentation

◆ applyLstmCorrection()

MatrixXd InvCMNE::applyLstmCorrection ( const Eigen::MatrixXd & matDspmData,
const QString & onnxModelPath,
int lookBack )
static

Apply LSTM-based temporal correction to z-scored rectified dSPM data.

Parameters
[in]matDspmDataZ-scored rectified dSPM data (n_sources x n_times).
[in]onnxModelPathPath to ONNX model file.
[in]lookBackNumber of past time steps (k).
Returns
Corrected source data (n_sources x n_times).

Definition at line 234 of file inv_cmne.cpp.

◆ compute()

InvCMNEResult InvCMNE::compute ( const Eigen::MatrixXd & matEvoked,
const Eigen::MatrixXd & matGain,
const Eigen::MatrixXd & matNoiseCov,
const Eigen::MatrixXd & matSrcCov,
const InvCMNESettings & settings )
static

Compute CMNE inverse solution.

Parameters
[in]matEvokedEvoked data (n_channels x n_times).
[in]matGainForward gain matrix (n_channels x n_sources).
[in]matNoiseCovNoise covariance (n_channels x n_channels).
[in]matSrcCovSource covariance (n_sources x n_sources, diagonal).
[in]settingsCMNE settings.
Returns
InvCMNEResult containing dSPM and CMNE source estimates.

Definition at line 77 of file inv_cmne.cpp.

◆ trainLstm()

UTILSLIB::PythonRunnerResult InvCMNE::trainLstm ( const QString & fwdPath,
const QString & covPath,
const QString & epochsPath,
const QString & outOnnxPath,
const InvCMNESettings & settings,
const QString & gtStcPrefix = {},
int hiddenSize = 256,
int numLayers = 1,
int trainEpochs = 50,
double learningRate = 1e-3,
int batchSize = 64,
const QString & finetuneOnnxPath = {},
const QString & pythonExe = QStringLiteral("python3") )
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.

Parameters
[in]fwdPathPath to forward solution FIFF file.
[in]covPathPath to noise covariance FIFF file.
[in]epochsPathPath to epochs FIFF file.
[in]outOnnxPathDesired output path for the ONNX model.
[in]settingsCMNE settings (look-back, method, SNR are forwarded).
[in]gtStcPrefixGround-truth STC prefix (optional; empty = simulation mode).
[in]hiddenSizeLSTM hidden dimension (default 256).
[in]numLayersLSTM layers (default 1).
[in]trainEpochsNumber of training epochs (default 50).
[in]learningRateLearning rate (default 1e-3).
[in]batchSizeBatch size (default 64).
[in]finetuneOnnxPathExisting ONNX model to fine-tune from (optional).
[in]pythonExePython interpreter (default "python3").
Returns
PythonRunnerResult with exit code, captured output and progress.

Definition at line 329 of file inv_cmne.cpp.


The documentation for this class was generated from the following files: