MNE-CPP  0.1.9
A Framework for Electrophysiology
mne_ctf_comp_data_set.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef MNECTFCOMPDATASET_H
38 #define MNECTFCOMPDATASET_H
39 
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "../mne_global.h"
45 
46 #include "mne_named_matrix.h"
48 
49 //=============================================================================================================
50 // EIGEN INCLUDES
51 //=============================================================================================================
52 
53 #include <Eigen/Core>
54 
55 //=============================================================================================================
56 // QT INCLUDES
57 //=============================================================================================================
58 
59 #include <QSharedPointer>
60 #include <QList>
61 
62 //=============================================================================================================
63 // DEFINE NAMESPACE MNELIB
64 //=============================================================================================================
65 
66 namespace MNELIB
67 {
68 
69 //=============================================================================================================
70 // FORWARD DECLARATIONS
71 //=============================================================================================================
72 
73 class MneCTFCompData;
74 
75 //=============================================================================================================
82 {
83 public:
84  typedef QSharedPointer<MneCTFCompDataSet> SPtr;
85  typedef QSharedPointer<const MneCTFCompDataSet> ConstSPtr;
87  //=========================================================================================================
93 
94  //=========================================================================================================
100 
101  //=========================================================================================================
107 
108  static MneCTFCompDataSet* mne_read_ctf_comp_data(const QString& name);
109 
110  static int mne_make_ctf_comp(MneCTFCompDataSet* set, /* The available compensation data */
111  const QList<FIFFLIB::FiffChInfo>& chs, /* Channels to compensate These may contain channels other than those requiring compensation */
112  int nch, /* How many of these */
113  QList<FIFFLIB::FiffChInfo> compchs, /* The compensation input channels These may contain channels other than the MEG compensation channels */
114  int ncomp);
115 
116  static int mne_set_ctf_comp(QList<FIFFLIB::FiffChInfo> &chs,
117  int nch,
118  int comp);
119 
120  static int mne_apply_ctf_comp(MneCTFCompDataSet* set, /* The compensation data */
121  int do_it,
122  float *data, /* The data to process */
123  int ndata,
124  float *compdata, /* Data containing the compensation channels */
125  int ncompdata);
126 
127  static int mne_apply_ctf_comp_t(MneCTFCompDataSet* set, /* The compensation data */
128  int do_it,
129  float **data, /* The data to process (channel by channel) */
130  int ndata,
131  int ns);
132 
133  static int mne_get_ctf_comp(const QList<FIFFLIB::FiffChInfo>& chs,int nch);
134 
135  /*
136  * Mapping from simple integer orders to the mysterious CTF compensation numbers
137  */
138  static int mne_map_ctf_comp_kind(int grad);
139 
140  static const char *mne_explain_ctf_comp(int kind);
141 
142  //int mne_ctf_compensate_to(mneCTFcompDataSet set, /* The compensation data */
143  // int compensate_to, /* What is the desired compensation to achieve */
144  // fiffChInfo chs, /* The channels to compensate */
145  // int nchan, /* How many? */
146  // fiffChInfo comp_chs, /* Maybe a different set, defaults to the same */
147  // int ncomp_chan, /* How many */
148  // float **data, /* The data in a np x nchan matrix allocated with ALLOC_CMATRIX(np,nchan) */
149  // float **comp_data, /* The compensation data in a np x ncomp_chan matrix, defaults to data */
150  // int np) /* How many time points */
152  //* Make data which has the third-order gradient compensation applied
153  //*/
154  //{
155  // int k;
156  // int have_comp_chs;
157  // int comp_was = MNE_CTFV_COMP_UNKNOWN;
158 
159  // if (!comp_data)
160  // comp_data = data;
161  // if (!comp_chs) {
162  // comp_chs = chs;
163  // ncomp_chan = nchan;
164  // }
165  // if (set) {
166  // mne_free_ctf_comp_data(set->undo); set->undo = NULL;
167  // mne_free_ctf_comp_data(set->current); set->current = NULL;
168  // }
169  // for (k = 0, have_comp_chs = 0; k < ncomp_chan; k++)
170  // if (comp_chs[k].kind == FIFFV_REF_MEG_CH)
171  // have_comp_chs++;
172  // if (have_comp_chs == 0 && compensate_to != MNE_CTFV_NOGRAD) {
173  // printf("No compensation channels in these data.");
174  // return FAIL;
175  // }
176  // /*
177  // * Update the 'current' field in 'set' to reflect the compensation possibly present in the data now
178  // */
179  // if (mne_make_ctf_comp(set,chs,nchan,comp_chs,ncomp_chan) == FAIL)
180  // goto bad;
181  // /*
182  // * Are we there already?
183  // */
184  // if (set->current && set->current->mne_kind == compensate_to) {
185  // printf("The data were already compensated as desired (%s)\n",mne_explain_ctf_comp(set->current->kind));
186  // return OK;
187  // }
188  // /*
189  // * Undo any previous compensation
190  // */
191  // for (k = 0; k < np; k++)
192  // if (mne_apply_ctf_comp(set,FALSE,data[k],nchan,comp_data[k],ncomp_chan) == FAIL)
193  // goto bad;
194  // if (set->current)
195  // printf("The previous compensation (%s) is now undone\n",mne_explain_ctf_comp(set->current->kind));
196  // /*
197  // * Set to new gradient compensation
198  // */
199  // if (compensate_to == MNE_CTFV_NOGRAD) {
200  // mne_set_ctf_comp(chs,nchan,compensate_to);
201  // printf("No compensation was requested. Original data have been restored.\n");
202  // }
203  // else {
204  // if (mne_set_ctf_comp(chs,nchan,compensate_to) > 0) {
205  // if (set->current)
206  // comp_was = set->current->mne_kind;
207  // if (mne_make_ctf_comp(set,chs,nchan,comp_chs,ncomp_chan) == FAIL)
208  // goto bad;
209  // /*
210  // * Do the third-order gradient compensation
211  // */
212  // for (k = 0; k < np; k++)
213  // if (mne_apply_ctf_comp(set,TRUE,data[k],nchan,comp_data[k],ncomp_chan) == FAIL)
214  // goto bad;
215  // if (set->current)
216  // printf("The data are now compensated as requested (%s).\n",mne_explain_ctf_comp(set->current->kind));
217  // }
218  // else
219  // printf("No MEG channels to compensate.\n");
220  // }
221  // return OK;
222 
223  //bad : {
224  // if (comp_was != MNE_CTFV_COMP_UNKNOWN)
225  // mne_set_ctf_comp(chs,nchan,comp_was);
226  // return FAIL;
227  // }
228  //}
229 
230  static int mne_ctf_set_compensation(MneCTFCompDataSet* set, /* The compensation data */
231  int compensate_to, /* What is the desired compensation to achieve */
232  QList<FIFFLIB::FiffChInfo>& chs, /* The channels to compensate */
233  int nchan, /* How many? */
234  QList<FIFFLIB::FiffChInfo> comp_chs, /* Maybe a different set, defaults to the same */
235  int ncomp_chan);
236 
237 public:
238  QList<MneCTFCompData*> comps; /* All available compensation data sets */
239  int ncomp; /* How many? */
240  QList<FIFFLIB::FiffChInfo> chs; /* Channel information */
241  int nch; /* How many of the above */
242  MneCTFCompData* undo; /* Compensation data to undo the current compensation before applying current */
243  MneCTFCompData* current; /* The current compensation data composed from the above taking into account channels presently available */
244 
246 //typedef struct {
247 // QList<MNELIB::MneCTFCompData*> comps; /* All available compensation data sets */
248 // int ncomp; /* How many? */
249 // FIFFLIB::fiffChInfo chs; /* Channel information */
250 // int nch; /* How many of the above */
251 // MNELIB::MneCTFCompData* undo; /* Compensation data to undo the current compensation before applying current */
252 // MNELIB::MneCTFCompData* current; /* The current compensation data composed from the above taking into account channels presently available */
253 //} *mneCTFcompDataSet,mneCTFcompDataSetRec;
254 };
255 
256 //=============================================================================================================
257 // INLINE DEFINITIONS
258 //=============================================================================================================
259 } // NAMESPACE MNELIB
260 
261 #endif // MNECTFCOMPDATASET_H
QSharedPointer< const MneCTFCompDataSet > ConstSPtr
QSharedPointer< MneCTFCompDataSet > SPtr
One MNE CTF compensation description.
MNE Named Matrix (MneNamedMatrix) class declaration.
One MNE CTF Compensation Data Set description.
#define MNESHARED_EXPORT
Definition: mne_global.h:56
FiffSparseMatrix class declaration.