v2.0.0
Loading...
Searching...
No Matches
inv_dipole_fit_data.h
Go to the documentation of this file.
1//=============================================================================================================
23
24#ifndef INV_DIPOLE_FIT_DATA_H
25#define INV_DIPOLE_FIT_DATA_H
26
27//=============================================================================================================
28// INCLUDES
29//=============================================================================================================
30
31#include "../inv_global.h"
32
33#include <fiff/fiff_types.h>
34#include <fwd/fwd_types.h>
36#include <fwd/fwd_bem_model.h>
37#include "inv_dipole_forward.h"
38
39//=============================================================================================================
40// EIGEN INCLUDES
41//=============================================================================================================
42
43#include <Eigen/Core>
44
45//=============================================================================================================
46// QT INCLUDES
47//=============================================================================================================
48
49#include <QSharedPointer>
50
51#include <memory>
52
53namespace FIFFLIB { class FiffCoordTrans; }
54namespace MNELIB { class MNEMeasData; }
55
56constexpr int COLUMN_NORM_NONE = 0;
57constexpr int COLUMN_NORM_COMP = 1;
58constexpr int COLUMN_NORM_LOC = 2;
59
60//=============================================================================================================
61// DEFINE NAMESPACE INVLIB
62//=============================================================================================================
63
64namespace INVLIB
65{
66
67// (Replaces *dipoleFitFuncs,dipoleFitFuncsRec struct of MNE-C fit_types.h).
68
89
94
99 float limit;
101 float *B;
102 double B2;
104};
105
106//=============================================================================================================
107// FORWARD DECLARATIONS
108//=============================================================================================================
109
110class InvGuessData;
111class InvEcd;
112
113//=============================================================================================================
128{
129public:
130 typedef QSharedPointer<InvDipoleFitData> SPtr;
131 typedef QSharedPointer<const InvDipoleFitData> ConstSPtr;
132
133 //=========================================================================================================
137 explicit InvDipoleFitData();
138
139 //=========================================================================================================
144 virtual ~InvDipoleFitData();
145
146 //=========================================================================================================
162
163 //=========================================================================================================
180 static std::unique_ptr<MNELIB::MNECovMatrix> ad_hoc_noise(FWDLIB::FwdCoilSet* meg,
182 float grad_std,
183 float mag_std,
184 float eeg_std);
185
186 //=========================================================================================================
199 static int scale_noise_cov(InvDipoleFitData* f, int nave);
200
201 //=========================================================================================================
215
216 //=========================================================================================================
238 int nave,
239 const int* sels);
240
241 //=========================================================================================================
272 const QString& mriname,
273 const QString& measname,
274 const QString& bemname,
275 Eigen::Vector3f *r0,
277 int accurate_coils,
278 const QString& badname,
279 const QString& noisename,
280 float grad_std,
281 float mag_std,
282 float eeg_std,
283 float mag_reg,
284 float grad_reg,
285 float eeg_reg,
286 int diagnoise,
287 const QList<QString>& projnames,
288 int include_meg,
289 int include_eeg);
290
291 //=========================================================================================================
306 static bool fit_one(InvDipoleFitData* fit, InvGuessData* guess, float time, Eigen::Ref<Eigen::VectorXf> B, int verbose, InvEcd& res);
307
308 //=========================================================================================================
324 static int compute_dipole_field(InvDipoleFitData& d, const Eigen::Vector3f& rd, int whiten, Eigen::Ref<Eigen::MatrixXf> fwd);
325
326 //=========================================================================================================
343 const Eigen::Vector3f& rd,
344 InvDipoleForward* old);
345
346public:
347 std::unique_ptr<FIFFLIB::FiffCoordTrans> mri_head_t;
348 std::unique_ptr<FIFFLIB::FiffCoordTrans> meg_head_t;
350 QList<FIFFLIB::FiffChInfo> chs;
351 int nmeg;
352 int neeg;
353 QStringList ch_names;
354 std::unique_ptr<FIFFLIB::FiffSparseMatrix> pick;
355 std::unique_ptr<FWDLIB::FwdCoilSet> meg_coils;
356 std::unique_ptr<FWDLIB::FwdCoilSet> eeg_els;
357 Eigen::Vector3f r0;
358 QString bemname;
359
360 std::unique_ptr<FWDLIB::FwdEegSphereModel> eeg_model;
361 std::unique_ptr<FWDLIB::FwdBemModel> bem_model;
362
363 std::unique_ptr<dipoleFitFuncsRec> sphere_funcs;
364 std::unique_ptr<dipoleFitFuncsRec> bem_funcs;
366 std::unique_ptr<dipoleFitFuncsRec> mag_dipole_funcs;
367
369 std::unique_ptr<MNELIB::MNECovMatrix> noise_orig;
370 std::unique_ptr<MNELIB::MNECovMatrix> noise;
371 int nave;
372 std::unique_ptr<MNELIB::MNEProjOp> proj;
376};
377
378//=============================================================================================================
379// INLINE DEFINITIONS
380//=============================================================================================================
381} //NAMESPACE
382
383#endif // INV_DIPOLE_FIT_DATA_H
std::function aliases for the generic dipole field / potential / field-gradient callbacks driving the...
std::function< int(const Eigen::Vector3f &rd, FWDLIB::FwdCoilSet &coils, Eigen::Ref< Eigen::MatrixXf > res, void *client)> fwdVecFieldFunc
Definition fwd_types.h:49
std::function< int(const Eigen::Vector3f &rd, const Eigen::Vector3f &Q, FWDLIB::FwdCoilSet &coils, Eigen::Ref< Eigen::VectorXf > res, void *client)> fwdFieldFunc
Definition fwd_types.h:47
Multi-shell spherical head model with Berg-Scherg equivalent-source approximation for fast EEG forwar...
Boundary Element Method (BEM) volume-conductor model — layered triangulated surfaces,...
Primitive scalar typedefs and forward-compatible aliases backing the FIFF type system.
Per-iteration forward-field cache (forward matrix, SVD, column normalisation) used by the dipole-fit ...
constexpr int COLUMN_NORM_NONE
constexpr int COLUMN_NORM_COMP
constexpr int COLUMN_NORM_LOC
INVLIB library export/import macros, build-info accessors, and namespace docstring for the inverse-so...
#define INVSHARED_EXPORT
Definition inv_global.h:38
Core MNE data structures (source spaces, source estimates, hemispheres).
void(* mneUserFreeFunc)(void *)
Generic destructor callback for user-attached data.
Definition mne_types.h:68
FIFF file I/O, in-memory data structures and high-level readers/writers.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
dipoleFitFuncsRec * dipoleFitFuncs
Pointer alias for dipoleFitFuncsRec, used throughout the dipole fitting module.
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
Container of FwdCoil instances acting both as the in-memory image of the coil_def....
Multi-shell concentric-sphere head model holding the Berg-Scherg equivalent-source parameters that ac...
Forward field computation function pointers and client data for MEG and EEG dipole fitting.
MNELIB::mneUserFreeFunc eeg_client_free
MNELIB::mneUserFreeFunc meg_client_free
Workspace for the dipole fitting objective function, holding forward model, measured field,...
std::unique_ptr< FWDLIB::FwdEegSphereModel > eeg_model
QSharedPointer< const InvDipoleFitData > ConstSPtr
std::unique_ptr< FWDLIB::FwdCoilSet > meg_coils
static InvDipoleFitData * setup_dipole_fit_data(const QString &mriname, const QString &measname, const QString &bemname, Eigen::Vector3f *r0, FWDLIB::FwdEegSphereModel *eeg_model, int accurate_coils, const QString &badname, const QString &noisename, float grad_std, float mag_std, float eeg_std, float mag_reg, float grad_reg, float eeg_reg, int diagnoise, const QList< QString > &projnames, int include_meg, int include_eeg)
Master setup: read all inputs and build a ready-to-use fit workspace.
std::unique_ptr< FIFFLIB::FiffCoordTrans > mri_head_t
static int scale_dipole_fit_noise_cov(InvDipoleFitData *f, int nave)
Scale dipole-fit noise covariance for a given number of averages.
std::unique_ptr< MNELIB::MNEProjOp > proj
static InvDipoleForward * dipole_forward_one(InvDipoleFitData *d, const Eigen::Vector3f &rd, InvDipoleForward *old)
Compute the forward solution for a single dipole position.
QSharedPointer< InvDipoleFitData > SPtr
std::unique_ptr< MNELIB::MNECovMatrix > noise
std::unique_ptr< dipoleFitFuncsRec > bem_funcs
static int scale_noise_cov(InvDipoleFitData *f, int nave)
Scale the noise-covariance matrix for a given number of averages.
std::unique_ptr< FIFFLIB::FiffSparseMatrix > pick
std::unique_ptr< dipoleFitFuncsRec > sphere_funcs
static bool fit_one(InvDipoleFitData *fit, InvGuessData *guess, float time, Eigen::Ref< Eigen::VectorXf > B, int verbose, InvEcd &res)
Fit a single dipole to the given data.
static int compute_dipole_field(InvDipoleFitData &d, const Eigen::Vector3f &rd, int whiten, Eigen::Ref< Eigen::MatrixXf > fwd)
Compute the forward field for a dipole at the given location.
static int setup_forward_model(InvDipoleFitData *d, MNELIB::MNECTFCompDataSet *comp_data, FWDLIB::FwdCoilSet *comp_coils)
Set up the sphere-model and (optionally) BEM forward functions.
QList< FIFFLIB::FiffChInfo > chs
std::unique_ptr< FWDLIB::FwdBemModel > bem_model
static int select_dipole_fit_noise_cov(InvDipoleFitData *f, MNELIB::MNEMeasData *meas, int nave, const int *sels)
Select and weight the noise-covariance for the active channel set.
std::unique_ptr< FWDLIB::FwdCoilSet > eeg_els
std::unique_ptr< dipoleFitFuncsRec > mag_dipole_funcs
static std::unique_ptr< MNELIB::MNECovMatrix > ad_hoc_noise(FWDLIB::FwdCoilSet *meg, FWDLIB::FwdCoilSet *eeg, float grad_std, float mag_std, float eeg_std)
Create an ad-hoc diagonal noise-covariance matrix.
std::unique_ptr< MNELIB::MNECovMatrix > noise_orig
std::unique_ptr< FIFFLIB::FiffCoordTrans > meg_head_t
Stores forward field matrices and SVD decomposition for magnetic dipole fitting.
Single equivalent current dipole with position, orientation, amplitude, and goodness-of-fit.
Definition inv_ecd.h:56
Precomputed guess point grid with forward fields for initial dipole position candidates.
Collection of CTF third-order gradient compensation operators.
Measurement data container for MNE inverse and dipole-fit computations.