v2.0.0
Loading...
Searching...
No Matches
mne_ctf_comp_data.cpp
Go to the documentation of this file.
1//=============================================================================================================
36
37//=============================================================================================================
38// INCLUDES
39//=============================================================================================================
40
41#include "mne_ctf_comp_data.h"
42
43#include <fiff/fiff_constants.h>
44#include <fiff/fiff_tag.h>
45
46#include <QFile>
47
48#include <Eigen/Core>
49
50#ifndef TRUE
51#define TRUE 1
52#endif
53
54#ifndef FALSE
55#define FALSE 0
56#endif
57
58#ifndef FAIL
59#define FAIL -1
60#endif
61
62#ifndef OK
63#define OK 0
64#endif
65
66#define MNE_CTFV_COMP_UNKNOWN -1
67#define MNE_CTFV_COMP_NONE 0
68#define MNE_CTFV_COMP_G1BR 0x47314252
69#define MNE_CTFV_COMP_G2BR 0x47324252
70#define MNE_CTFV_COMP_G3BR 0x47334252
71#define MNE_CTFV_COMP_G2OI 0x47324f49
72#define MNE_CTFV_COMP_G3OI 0x47334f49
73
74//=============================================================================================================
75// USED NAMESPACES
76//=============================================================================================================
77
78using namespace Eigen;
79using namespace FIFFLIB;
80using namespace MNELIB;
81
82//=============================================================================================================
83// DEFINE MEMBER METHODS
84//=============================================================================================================
85
92
93//=============================================================================================================
94
99{
100 kind = comp.kind;
101 mne_kind = comp.mne_kind;
102 calibrated = comp.calibrated;
103 data = std::make_unique<MNENamedMatrix>(*comp.data);
104
105 presel = std::make_unique<FiffSparseMatrix>(*comp.presel);
106 postsel = std::make_unique<FiffSparseMatrix>(*comp.postsel);
107}
108
109//=============================================================================================================
110
114
115//=============================================================================================================
116
117int MNECTFCompData::calibrate(const QList<FIFFLIB::FiffChInfo>& chs, int nch, int do_it)
118{
119 Eigen::VectorXf col_cals(this->data->ncol);
120 Eigen::VectorXf row_cals(this->data->nrow);
121 int j,k,p,found;
122 QString name;
123
124 if (calibrated)
125 return OK;
126
127 for (j = 0; j < this->data->nrow; j++) {
128 name = this->data->rowlist[j];
129 found = FALSE;
130 for (p = 0; p < nch; p++)
131 if (QString::compare(name,chs[p].ch_name) == 0) {
132 row_cals[j] = chs[p].range*chs[p].cal;
133 found = TRUE;
134 break;
135 }
136 if (!found) {
137 printf("Channel %s not found. Cannot calibrate the compensation matrix.",name.toUtf8().constData());
138 return FAIL;
139 }
140 }
141 for (k = 0; k < this->data->ncol; k++) {
142 name = this->data->collist[k];
143 found = FALSE;
144 for (p = 0; p < nch; p++)
145 if (QString::compare(name,chs[p].ch_name) == 0) {
146 col_cals[k] = chs[p].range*chs[p].cal;
147 found = TRUE;
148 break;
149 }
150 if (!found) {
151 printf("Channel %s not found. Cannot calibrate the compensation matrix.",name.toUtf8().constData());
152 return FAIL;
153 }
154 }
155 if (do_it) {
156 for (j = 0; j < this->data->nrow; j++)
157 for (k = 0; k < this->data->ncol; k++)
158 this->data->data(j, k) = row_cals[j]*this->data->data(j, k)/col_cals[k];
159 }
160 else {
161 for (j = 0; j < this->data->nrow; j++)
162 for (k = 0; k < this->data->ncol; k++)
163 this->data->data(j, k) = col_cals[k]*this->data->data(j, k)/row_cals[j];
164 }
165 return OK;
166}
FiffTag class declaration, which provides fiff tag I/O and processing methods.
Fiff constants.
#define MNE_CTFV_COMP_UNKNOWN
MNECTFCompData class declaration.
#define TRUE
#define FALSE
#define OK
#define FAIL
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
std::unique_ptr< FIFFLIB::FiffSparseMatrix > postsel
std::unique_ptr< MNENamedMatrix > data
int calibrate(const QList< FIFFLIB::FiffChInfo > &chs, int nch, int do_it)
std::unique_ptr< FIFFLIB::FiffSparseMatrix > presel