MNE-CPP  0.1.9
A Framework for Electrophysiology
dipole_fit_data.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef DIPOLEFITDATA_H
38 #define DIPOLEFITDATA_H
39 
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "../inverse_global.h"
45 
46 #include <fiff/fiff_types.h>
47 #include "analyze_types.h"
48 #include <fwd/fwd_types.h>
50 #include <fwd/fwd_bem_model.h>
51 #include "dipole_forward.h"
52 
53 //=============================================================================================================
54 // EIGEN INCLUDES
55 //=============================================================================================================
56 
57 #include <Eigen/Core>
58 
59 //=============================================================================================================
60 // QT INCLUDES
61 //=============================================================================================================
62 
63 #include <QSharedPointer>
64 
65 // ToDo move to cpp
66 #define COLUMN_NORM_NONE 0 /* No column normalization requested */
67 #define COLUMN_NORM_COMP 1 /* Componentwise normalization */
68 #define COLUMN_NORM_LOC 2 /* Dipole locationwise normalization */
69 
70 //=============================================================================================================
71 // DEFINE NAMESPACE INVERSELIB
72 //=============================================================================================================
73 
74 namespace INVERSELIB
75 {
76 
77 /*
78  * These are the type definitions for dipole fitting
79  */
80 typedef void (*fitUserFreeFunc)(void *);
81 
82 // (Replaces *dipoleFitFuncs,dipoleFitFuncsRec struct of MNE-C fit_types.h).
83 
84 typedef struct {
85  fwdFieldFunc meg_field; /* MEG forward calculation functions */
86  fwdVecFieldFunc meg_vec_field;
87  void *meg_client; /* Client data for MEG field computations */
88  mneUserFreeFunc meg_client_free;
89 
90  fwdFieldFunc eeg_pot; /* EEG forward calculation functions */
91  fwdVecFieldFunc eeg_vec_pot;
92  void *eeg_client; /* Client data for EEG field computations */
93  mneUserFreeFunc eeg_client_free;
95 
96 //=============================================================================================================
97 // FORWARD DECLARATIONS
98 //=============================================================================================================
99 
100 class GuessData;
101 class ECD;
102 
103 //=============================================================================================================
110 {
111 public:
112  typedef QSharedPointer<DipoleFitData> SPtr;
113  typedef QSharedPointer<const DipoleFitData> ConstSPtr;
115  //=========================================================================================================
119  explicit DipoleFitData();
120 
121  //=========================================================================================================
126  virtual ~DipoleFitData();
127 
128  //============================= dipole_fit_setup.c =============================
129 
130  static int setup_forward_model(DipoleFitData* d, MNELIB::MneCTFCompDataSet* comp_data, FWDLIB::FwdCoilSet* comp_coils);
131 
132  static MNELIB::MneCovMatrix* ad_hoc_noise(FWDLIB::FwdCoilSet* meg, /* Channel name lists to define which channels are gradiometers */
133  FWDLIB::FwdCoilSet* eeg,
134  float grad_std,
135  float mag_std,
136  float eeg_std);
137 
138  //ToDo move to mneProjOp class
139  static int make_projection(const QList<QString>& projnames,
140  const QList<FIFFLIB::FiffChInfo>& chs,
141  int nch,
142  MNELIB::MneProjOp* *res);
143 
144  static int scale_noise_cov(DipoleFitData* f,int nave);
145 
146  static int scale_dipole_fit_noise_cov(DipoleFitData* f,int nave);
147 
148  static int select_dipole_fit_noise_cov(DipoleFitData* f, mshMegEegData d);
149 
150  static DipoleFitData* setup_dipole_fit_data( const QString& mriname,
151  const QString& measname,
152  const QString& bemname,
153  Eigen::Vector3f *r0,
154  FWDLIB::FwdEegSphereModel* eeg_model,
155  int accurate_coils,
156  const QString& badname,
157  const QString& noisename,
158  float grad_std,
159  float mag_std,
160  float eeg_std,
161  float mag_reg,
162  float grad_reg,
163  float eeg_reg,
164  int diagnoise,
165  const QList<QString>& projnames,
166  int include_meg,
167  int include_eeg);
168 
169  //=========================================================================================================
181  static bool fit_one(DipoleFitData* fit, GuessData* guess, float time, float *B, int verbose, ECD& res);
182 
183 //============================= dipole_forward.c
184 
185  static int compute_dipole_field(DipoleFitData* d, float *rd, int whiten, float **fwd);
186 
187  //============================= dipole_forward.c
188 
189  static DipoleForward* dipole_forward_one(DipoleFitData* d,
190  float *rd,
191  DipoleForward* old);
192 
193 public:
197  QList<FIFFLIB::FiffChInfo> chs;
198  int nmeg;
199  int neeg;
200  QStringList ch_names;
204  float r0[3];
205  QString bemname;
218  int nave;
222  void *user;
223  fitUserFreeFunc user_free;
225 // ### OLD STRUCT ###
226 // typedef struct { /* This structure holds all fitting-related data */
227 // fiffCoordTrans mri_head_t; /* MRI <-> head coordinate transformation */
228 // fiffCoordTrans meg_head_t; /* MEG <-> head coordinate transformation */
229 // int coord_frame; /* Common coordinate frame */
230 // fiffChInfo chs; /* Channels */
231 // int nmeg; /* How many MEG */
232 // int neeg; /* How many EEG */
233 // char **ch_names; /* List of all channel names */
234 // mneSparseMatrix pick; /* Matrix to pick data from the
235 // full data set which may contain channels
236 // we are not interested in */
237 // fwdCoilSet meg_coils; /* MEG coil definitions */
238 // fwdCoilSet eeg_els; /* EEG electrode definitions */
239 // float r0[3]; /* Sphere model origin */
240 // char *bemname; /* Using a BEM? */
241 
242 // FwdEegSphereModel *eeg_model; /* EEG sphere model definition */
243 // fwdBemModel bem_model; /* BEM model definition */
244 
245 // dipoleFitFuncs sphere_funcs; /* These are the sphere model forward functions */
246 // dipoleFitFuncs bem_funcs; /* These are the BEM forward functions */
247 // dipoleFitFuncs funcs; /* Points to one of the two above */
248 // dipoleFitFuncs mag_dipole_funcs; /* Functions to fit a magnetic dipole */
249 
250 // int fixed_noise; /* Were fixed noise values used rather than a noise-covariance
251 // * matrix read from a file */
252 // MneCovMatrix* noise_orig; /* Noise covariance matrix (original) */
253 // MneCovMatrix* noise; /* Noise covariance matrix (weighted to take the selection into account) */
254 // int nave; /* How many averages does this correspond to? */
255 // mneProjOp proj; /* The projection operator to use */
256 // int column_norm; /* What kind of column normalization to apply to the forward solution */
257 // int fit_mag_dipoles; /* Fit magnetic dipoles? */
258 // void *user; /* User data for anything we need */
259 // fitUserFreeFunc user_free; /* Function to free the above */
260 // } *dipoleFitData,dipoleFitDataRec;
261 };
262 
263 //=============================================================================================================
264 // INLINE DEFINITIONS
265 //=============================================================================================================
266 } //NAMESPACE
267 
268 #endif // DIPOLEFITDATA_H
INVERSELIB::DipoleFitData::eeg_model
FWDLIB::FwdEegSphereModel * eeg_model
Definition: dipole_fit_data.h:207
INVERSELIB::DipoleFitData::SPtr
QSharedPointer< DipoleFitData > SPtr
Definition: dipole_fit_data.h:112
INVERSELIB::DipoleFitData::proj
MNELIB::MneProjOp * proj
Definition: dipole_fit_data.h:219
fwd_eeg_sphere_model.h
FwdEegSphereModel class declaration.
INVERSESHARED_EXPORT
#define INVERSESHARED_EXPORT
Definition: inverse_global.h:56
INVERSELIB::DipoleFitData::bemname
QString bemname
Definition: dipole_fit_data.h:205
INVERSELIB::DipoleFitData::noise_orig
MNELIB::MneCovMatrix * noise_orig
Definition: dipole_fit_data.h:216
INVERSELIB::mshMegEegData
Definition: analyze_types.h:299
INVERSELIB::DipoleFitData::column_norm
int column_norm
Definition: dipole_fit_data.h:220
FIFFLIB::FiffSparseMatrix
Data associated with MNE computations for each mneMeasDataSet.
Definition: fiff_sparse_matrix.h:74
INVERSELIB::DipoleFitData::ConstSPtr
QSharedPointer< const DipoleFitData > ConstSPtr
Definition: dipole_fit_data.h:113
FWDLIB::FwdEegSphereModel
Electric Current Dipole description.
Definition: fwd_eeg_sphere_model.h:91
INVERSELIB::DipoleFitData::coord_frame
int coord_frame
Definition: dipole_fit_data.h:196
INVERSELIB::DipoleFitData::funcs
dipoleFitFuncs funcs
Definition: dipole_fit_data.h:212
INVERSELIB::ECD
Electric Current Dipole description.
Definition: ecd.h:72
INVERSELIB::DipoleFitData::noise
MNELIB::MneCovMatrix * noise
Definition: dipole_fit_data.h:217
FWDLIB::FwdCoilSet
FwdCoilSet description.
Definition: fwd_coil_set.h:75
INVERSELIB::DipoleFitData::user
void * user
Definition: dipole_fit_data.h:222
MNELIB::MneProjOp
One linear projection item.
Definition: mne_proj_op.h:83
FIFFLIB::FiffCoordTransOld
Coordinate transformation descriptor.
Definition: fiff_coord_trans_old.h:80
INVERSELIB::DipoleFitData::ch_names
QStringList ch_names
Definition: dipole_fit_data.h:200
dipole_forward.h
DipoleForward class declaration.
INVERSELIB::DipoleFitData::meg_head_t
FIFFLIB::FiffCoordTransOld * meg_head_t
Definition: dipole_fit_data.h:195
INVERSELIB::DipoleFitData
Dipole Fit Data implementation.
Definition: dipole_fit_data.h:109
INVERSELIB::DipoleFitData::nmeg
int nmeg
Definition: dipole_fit_data.h:198
INVERSELIB::DipoleFitData::fit_mag_dipoles
int fit_mag_dipoles
Definition: dipole_fit_data.h:221
INVERSELIB::DipoleFitData::fixed_noise
int fixed_noise
Definition: dipole_fit_data.h:215
INVERSELIB::DipoleFitData::pick
FIFFLIB::FiffSparseMatrix * pick
Definition: dipole_fit_data.h:201
INVERSELIB::DipoleFitData::mag_dipole_funcs
dipoleFitFuncs mag_dipole_funcs
Definition: dipole_fit_data.h:213
INVERSELIB::DipoleFitData::nave
int nave
Definition: dipole_fit_data.h:218
MNELIB::MneCTFCompDataSet
One MNE CTF Compensation Data Set description.
Definition: mne_ctf_comp_data_set.h:81
INVERSELIB::DipoleFitData::eeg_els
FWDLIB::FwdCoilSet * eeg_els
Definition: dipole_fit_data.h:203
INVERSELIB::DipoleFitData::neeg
int neeg
Definition: dipole_fit_data.h:199
INVERSELIB::DipoleForward
DipoleForward description.
Definition: dipole_forward.h:72
INVERSELIB::dipoleFitFuncs
Definition: dipole_fit_data.h:84
INVERSELIB::DipoleFitData::bem_funcs
dipoleFitFuncs bem_funcs
Definition: dipole_fit_data.h:211
FWDLIB::FwdBemModel
Holds the BEM model definition.
Definition: fwd_bem_model.h:110
INVERSELIB::GuessData
GuessData description.
Definition: guess_data.h:78
fiff_types.h
Definitions for describing the objects in a FIFF file.
INVERSELIB::DipoleFitData::sphere_funcs
dipoleFitFuncs sphere_funcs
Definition: dipole_fit_data.h:210
INVERSELIB::DipoleFitData::bem_model
FWDLIB::FwdBemModel * bem_model
Definition: dipole_fit_data.h:208
MNELIB::MneCovMatrix
Covariance matrix storage.
Definition: mne_cov_matrix.h:96
INVERSELIB::DipoleFitData::meg_coils
FWDLIB::FwdCoilSet * meg_coils
Definition: dipole_fit_data.h:202
fwd_bem_model.h
FwdBemModel class declaration.
INVERSELIB::DipoleFitData::chs
QList< FIFFLIB::FiffChInfo > chs
Definition: dipole_fit_data.h:197
INVERSELIB::DipoleFitData::mri_head_t
FIFFLIB::FiffCoordTransOld * mri_head_t
Definition: dipole_fit_data.h:194