66 #define MALLOC_31(x,t) (t *)malloc((x)*sizeof(t))
68 #define FREE_31(x) if ((char *)(x) != NULL) free((char *)(x))
70 #define MNE_CTFV_COMP_UNKNOWN -1
71 #define MNE_CTFV_COMP_NONE 0
72 #define MNE_CTFV_COMP_G1BR 0x47314252
73 #define MNE_CTFV_COMP_G2BR 0x47324252
74 #define MNE_CTFV_COMP_G3BR 0x47334252
75 #define MNE_CTFV_COMP_G2OI 0x47324f49
76 #define MNE_CTFV_COMP_G3OI 0x47334f49
82 using namespace Eigen;
83 using namespace FIFFLIB;
84 using namespace MNELIB;
90 MneCTFCompData::MneCTFCompData()
91 :kind(MNE_CTFV_COMP_UNKNOWN)
92 ,mne_kind(MNE_CTFV_COMP_UNKNOWN)
106 :kind(MNE_CTFV_COMP_UNKNOWN)
107 ,mne_kind(MNE_CTFV_COMP_UNKNOWN)
117 mne_kind = comp.mne_kind;
118 calibrated = comp.calibrated;
135 FREE_31(presel_data);
136 FREE_31(postsel_data);
142 int MneCTFCompData::mne_calibrate_ctf_comp(
MneCTFCompData *one,
const QList<FIFFLIB::FiffChInfo>& chs,
int nch,
int do_it)
147 float *col_cals,*row_cals;
157 row_cals = MALLOC_31(one->data->nrow,
float);
158 col_cals = MALLOC_31(one->data->ncol,
float);
160 for (j = 0; j < one->data->nrow; j++) {
161 name = one->data->rowlist[j];
163 for (p = 0; p < nch; p++)
164 if (QString::compare(name,chs[p].ch_name) == 0) {
165 row_cals[j] = chs[p].range*chs[p].cal;
170 printf(
"Channel %s not found. Cannot calibrate the compensation matrix.",name.toUtf8().constData());
174 for (
k = 0;
k < one->data->ncol;
k++) {
175 name = one->data->collist[
k];
177 for (p = 0; p < nch; p++)
178 if (QString::compare(name,chs[p].ch_name) == 0) {
179 col_cals[
k] = chs[p].range*chs[p].cal;
184 printf(
"Channel %s not found. Cannot calibrate the compensation matrix.",name.toUtf8().constData());
188 data = one->data->data;
190 for (j = 0; j < one->data->nrow; j++)
191 for (
k = 0;
k < one->data->ncol;
k++)
192 data[j][
k] = row_cals[j]*data[j][
k]/col_cals[
k];
195 for (j = 0; j < one->data->nrow; j++)
196 for (
k = 0;
k < one->data->ncol;
k++)
197 data[j][
k] = col_cals[
k]*data[j][
k]/row_cals[j];