InvEcdSet
Namespace: INVLIB · Library: Inverse Library
#include <inv/inv_ecd_set.h>
class INVLIB::InvEcdSet
Implements Electric Current Dipole Set (Replaces *ecdSet,ecdSetRec struct of MNE-C fit_types.h).
Holds a set of Electric Current Dipoles.
InvDipoleFitSettings settings; // the options of the MNE-C mne_dipole_fit tool
settings.measname = tmp.filePath("synthetic-ave.fif");
settings.include_meg = true;
settings.include_eeg = false;
settings.guess_mindist = 0.0f;
settings.tmin = 0.0f;
settings.dipname = tmp.filePath("fit.dat"); // MNE-C .dat dipole file
settings.checkIntegrity();
InvDipoleFit fit(&settings);
InvEcdSet dipoles = fit.calculateFit();
const bool saved = dipoles.save_dipoles_dip(tmp.filePath("fit.dip")); // readable by mne.read_dipole
const InvEcdSet reread = InvEcdSet::read_dipoles_dip(tmp.filePath("fit.dip"));
Public Methods
InvEcdSet()
Constructs a Electric Current Dipole Set object.
InvEcdSet(p_ECDSet)
Copy constructor.
Parameters:
- p_ECDSet : const InvEcdSet & Electric Current Dipole Set which should be copied.
operator=(other)
Copy assignment.
Every member has value semantics, so the compiler-generated member-wise assignment is correct. It is declared explicitly because declaring a copy constructor and/or a destructor deprecates the implicitly generated one.
Parameters:
- other : const InvEcdSet & Object to assign from.
Returns:
- InvEcdSet & — reference to this object.
~InvEcdSet()
Destroys the Electric Current Dipole description.
addEcd(p_ecd)
Appends an Electric Current Dipole to the set.
Parameters:
- p_ecd : const InvEcd & Dipole to append (copied).
save_dipoles_bdip(fileName)
Save dipoles in the bdip format employed by xfit.
Parameters:
- fileName : const QString & File name to save to.
Returns:
- bool — True on success or if there is nothing to save, false if the file could not be written.
save_dipoles_dip(fileName)
Save dipoles in the dip format suitable for mrilab.
Parameters:
- fileName : const QString & File name to save to.
Returns:
- bool — True on success or if there is nothing to save, false if the file could not be written.
size()
Returns the number of stored ECDs.
Returns:
- qint32 — number of stored ECDs.
operator[](idx)
Subscript operator [] to access InvEcd by index.
Parameters:
- idx : int
the
InvEcdindex.
Returns:
operator[](idx)
Subscript operator [] to access InvEcd by index.
Parameters:
- idx : int
the
InvEcdindex.
Returns:
operator<<(p_ecd)
Subscript operator << to add a new InvEcd.
Parameters:
Returns:
Static Methods
read_dipoles_dip(fileName)
Read dipoles from the dip format compatible with mrilab.
Parameters:
- fileName : const QString & File name to read from.
Returns:
- InvEcdSet — The dipole set read from the file; empty if the file could not be read.
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.
settings.dipname = tmp.filePath("fit.dat"); // MNE-C .dat dipole file
settings.checkIntegrity();
InvDipoleFit fit(&settings);
InvEcdSet dipoles = fit.calculateFit();
const bool saved = dipoles.save_dipoles_dip(tmp.filePath("fit.dip")); // readable by mne.read_dipole
const InvEcdSet reread = InvEcdSet::read_dipoles_dip(tmp.filePath("fit.dip"));
const Vector3d posMm = dipoles.size() > 0 ? Vector3d(1e3 * dipoles[0].rd.cast<double>()) : Vector3d::Zero();
ok &= expect(saved && dipoles.size() == 1 && dipoles[0].valid && (posMm - mnePosMm).norm() < 1.0 && std::abs(100.0 * dipoles[0].good - 99.99996959113513) < 0.01 && dipoles[0].nfree == 297 && reread.size() == 1 && (reread[0].rd - dipoles[0].rd).norm() < 1e-4f,
"InvDipoleFitSettings/InvDipoleFit/InvEcdSet: the pipeline fit matches mne.fit_dipole and round-trips through .dip");
ex_disp3d_scene
Disp3D scene data: sensor-to-surface interpolation, electrodes, MRI slices, video overlay and layers.
InvEcdSet dipoles;
InvEcd strong;
strong.rd = Vector3f(0.0f, 0.0f, 0.05f);
strong.Q = Vector3f(0.0f, 0.0f, 20e-9f);
InvEcd weak;
weak.rd = Vector3f(0.03f, 0.0f, 0.05f);
weak.Q = Vector3f(10e-9f, 0.0f, 0.0f);
dipoles.addEcd(strong);
dipoles.addEcd(weak);
DipoleObject dipoleGlyphs;
dipoleGlyphs.load(dipoles); // one cone per dipole, scaled by moment
float dipoleDistance = 0.0f;
const int pickedDipole = dipoleGlyphs.intersect(QVector3D(0.03f, 0.0f, 0.2f), QVector3D(0.0f, 0.0f, -1.0f), dipoleDistance);
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>