52 #include <Eigen/Dense>
58 using namespace INVERSELIB;
59 using namespace FIFFLIB;
60 using namespace Eigen;
75 updateBadChannels(pFiffInfo);
76 updateChannels(pFiffInfo);
77 updateHpiDigitizer(pFiffInfo->dig);
78 updateSensors(m_lChannels);
85 m_lBads = pFiffInfo->bads;
93 const int iNumCh = pFiffInfo->nchan;
95 m_vecInnerind.clear();
96 for (
int i = 0; i < iNumCh; ++i) {
104 if(!(pFiffInfo->bads.contains(pFiffInfo->ch_names.at(i)))) {
105 m_vecInnerind.append(i);
106 m_lChannels.append(pFiffInfo->chs[i]);
114 void HpiDataUpdater::updateSensors(
const QList<FIFFLIB::FiffChInfo>& lChannels)
116 const Accuracy accuracy = Accuracy::high;
122 void HpiDataUpdater::updateHpiDigitizer(
const QList<FiffDigPoint>& lDig)
125 QList<FiffDigPoint> lHPIPoints;
128 for(
int i = 0; i < lDig.size(); ++i) {
129 if(lDig[i].kind == FIFFV_POINT_HPI) {
131 lHPIPoints.append(lDig[i]);
136 if (lHPIPoints.size() > 0) {
137 m_matHpiDigitizer = MatrixXd(iNumCoils,3);
138 for (
int i = 0; i < lHPIPoints.size(); ++i) {
139 m_matHpiDigitizer(i,0) = lHPIPoints.at(i).r[0];
140 m_matHpiDigitizer(i,1) = lHPIPoints.at(i).r[1];
141 m_matHpiDigitizer(i,2) = lHPIPoints.at(i).r[2];
144 std::cout <<
"HPIFit::updateHpiDigitizer - No HPI coils digitized. Returning." << std::endl;
153 const bool bUpdate = checkIfChanged(pFiffInfo->bads,pFiffInfo->chs);
156 updateBadChannels(pFiffInfo);
157 updateChannels(pFiffInfo);
158 updateHpiDigitizer(pFiffInfo->dig);
159 updateSensors(m_lChannels);
165 bool HpiDataUpdater::checkIfChanged(
const QList<QString>& lBads,
const QList<FIFFLIB::FiffChInfo>& lChannels)
167 bool bUpdate =
false;
168 if(!(m_lBads == lBads) || !(m_lChannels == lChannels)) {
178 prepareData(matData);
179 prepareProjectors(matProjectors);
180 m_matDataProjected = m_matProjectors * m_matInnerdata;
185 void HpiDataUpdater::prepareData(
const Eigen::MatrixXd& matData)
188 m_matInnerdata = MatrixXd(m_vecInnerind.size(), matData.cols());
190 for(
int j = 0; j < m_vecInnerind.size(); ++j) {
191 m_matInnerdata.row(j) << matData.row(m_vecInnerind[j]);
197 void HpiDataUpdater::prepareProjectors(
const Eigen::MatrixXd& matProjectors)
200 if(m_vecInnerind.size() == 0) {
201 std::cout <<
"HPIFit::updateProjectors - No channels. Returning." << std::endl;
206 MatrixXd matProjectorsRows(m_vecInnerind.size(),matProjectors.cols());
207 MatrixXd matProjectorsInnerind(m_vecInnerind.size(),m_vecInnerind.size());
209 for (
int i = 0; i < matProjectorsRows.rows(); ++i) {
210 matProjectorsRows.row(i) = matProjectors.row(m_vecInnerind.at(i));
213 for (
int i = 0; i < matProjectorsInnerind.cols(); ++i) {
214 matProjectorsInnerind.col(i) = matProjectorsRows.col(m_vecInnerind.at(i));
216 m_matProjectors = matProjectorsInnerind;