InvGuessData
Namespace: INVLIB · Library: Inverse Library
#include <inv/inv_guess_data.h>
class INVLIB::InvGuessData
Implements InvGuessData (Replaces *guessData,guessDataRec struct of MNE-C fit_types.h).
Precomputed guess point grid with forward fields for initial dipole position candidates.
// MEG channels and SSP projectors from the sample file, sphere at (0, 0, 40) mm, ad-hoc noise
// (5e-13 T/m gradiometers, 20 fT magnetometers).
Vector3f r0(0.0f, 0.0f, 0.04f);
std::unique_ptr<InvDipoleFitData> fitData(InvDipoleFitData::setup_dipole_fit_data(
QString(), sampleAve, QString(), &r0, nullptr, false, QString(), QString(),
5e-13f, 20e-15f, 0.2e-6f, 0.1f, 0.1f, 0.1f, false, {sampleAve}, true, false));
MatrixXf gain(fitData->nmeg, 3);
const bool fieldOk = InvDipoleFitData::compute_dipole_field(*fitData, truePos, false, gain) == 0; // projected, not whitened
VectorXf field = gain * trueMoment;
InvGuessData guesses(QString(), QString(), 0.0f, 0.02f, 0.015f, fitData.get(), 0.08f); // 15 mm grid in an 80 mm sphere
std::unique_ptr<InvDipoleForward> atTruth(InvDipoleFitData::dipole_forward_one(fitData.get(), truePos, nullptr));
InvEcd dipole;
VectorXf b = field; // fit_one projects and whitens in place
const bool fitted = InvDipoleFitData::fit_one(fitData.get(), &guesses, 0.0f, b, false, dipole);
Public Methods
InvGuessData()
Constructs the Guess Data Refactored: new_guess_data (dipole_fit_setup.c).
InvGuessData()
Deleted — non-copyable due to unique_ptr members.
operator=()
InvGuessData(guessname, guess_surfname, mindist, exclude, grid, f, guessrad)
Constructs the Guess Data from given Data Refactored: make_guess_data (dipole_fit_setup.c).
Parameters:
-
guessname : const QString & File with a predefined guess point set (empty = build a grid).
-
guess_surfname : const QString & Surface file bounding the guess grid (empty = inner skull of the BEM, or a sphere).
-
mindist : float Minimum distance of guess points from the bounding surface (m).
-
exclude : float Exclude guess points closer than this to the sphere origin (m).
-
grid : float Spacing of the guess grid (m).
-
f : *InvDipoleFitData ** Dipole fit data providing the forward model.
-
guessrad : float Radius of the spherical guess volume when no surface bounds it (m).
~InvGuessData()
Destroys the Guess Data description Refactored: free_guess_data (dipole_fit_setup.c).
compute_guess_fields(f)
Once the guess locations have been set up we can compute the fields Refactored: compute_guess_fields (dipole_fit_setup.c).
Parameters:
- f : *InvDipoleFitData ** Dipole Fit Data to the Compute Guess Fields.
Returns:
- bool — true when successful.
Example
- Full source:
src/examples/ex_inv_dipole_fit/main.cpp - Build target:
ex_inv_dipole_fit(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_inv_dipole_fit
Inverse library: equivalent current dipole fitting in a sphere model.
InvGuessData guesses(QString(), QString(), 0.0f, 0.02f, 0.015f, fitData.get(), 0.08f); // 15 mm grid in an 80 mm sphere
std::unique_ptr<InvDipoleForward> atTruth(InvDipoleFitData::dipole_forward_one(fitData.get(), truePos, nullptr));
InvEcd dipole;
VectorXf b = field; // fit_one projects and whitens in place
const bool fitted = InvDipoleFitData::fit_one(fitData.get(), &guesses, 0.0f, b, false, dipole);
ok &= expect(fieldOk && fitted && fitData->nmeg == 305 && guesses.nguess == 627 && atTruth && atTruth->sing.size() == 3 && dipole.valid && (dipole.rd - truePos).norm() < 1e-3f && (1e9 * dipole.Q.cast<double>() - mneMomentNAm).norm() < 0.02 * mneMomentNAm.norm() && dipole.good > 0.9999f,
"InvDipoleFitData/InvGuessData/InvDipoleForward/InvEcd: one sample fits the dipole like mne.fit_dipole");
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>