MNE-CPP  0.1.9
A Framework for Electrophysiology
rtsensorinterpolationmatworker.cpp
Go to the documentation of this file.
1 //=============================================================================================================
35 //=============================================================================================================
36 // INCLUDES
37 //=============================================================================================================
38 
40 #include "../../../../helpers/geometryinfo/geometryinfo.h"
41 #include "../../../../helpers/interpolation/interpolation.h"
42 
43 //=============================================================================================================
44 // QT INCLUDES
45 //=============================================================================================================
46 
47 //=============================================================================================================
48 // EIGEN INCLUDES
49 //=============================================================================================================
50 
51 //=============================================================================================================
52 // USED NAMESPACES
53 //=============================================================================================================
54 
55 using namespace DISP3DLIB;
56 using namespace MNELIB;
57 using namespace FIFFLIB;
58 using namespace Eigen;
59 
60 //=============================================================================================================
61 // DEFINE MEMBER METHODS
62 //=============================================================================================================
63 
65 : m_bInterpolationInfoIsInit(false)
66 {
69  m_lInterpolationData.matDistanceMatrix = QSharedPointer<MatrixXd>(new MatrixXd());
70 }
71 
72 //=============================================================================================================
73 
74 void RtSensorInterpolationMatWorker::setInterpolationFunction(const QString &sInterpolationFunction)
75 {
76  if(sInterpolationFunction == "Linear") {
78  }
79  else if(sInterpolationFunction == "Square") {
81  }
82  else if(sInterpolationFunction == "Cubic") {
84  }
85  else if(sInterpolationFunction == "Gaussian") {
87  }
88 
89  if(m_bInterpolationInfoIsInit == true){
90  //recalculate Interpolation matrix parameters changed
91  emitMatrix();
92  }
93 }
94 
95 //=============================================================================================================
96 
98 {
100 
101  //recalculate everything because parameters changed
103 }
104 
105 //=============================================================================================================
106 
107 void RtSensorInterpolationMatWorker::setInterpolationInfo(const Eigen::MatrixX3f &matVertices,
108  const QVector<QVector<int> > &vecNeighborVertices,
109  const QVector<Vector3f> &vecSensorPos,
110  const FiffInfo &fiffInfo,
111  int iSensorType)
112 {
113  if(matVertices.rows() == 0) {
114  qDebug() << "RtSensorInterpolationMatWorker::calculateSurfaceData - Surface data is empty. Returning ...";
115  return;
116  }
117 
118  //set members
119  m_lInterpolationData.matVertices = matVertices;
120  m_lInterpolationData.fiffInfo = fiffInfo;
121  m_lInterpolationData.iSensorType = iSensorType;
122  m_lInterpolationData.vecNeighborVertices = vecNeighborVertices;
123 
124  //set vecExcludeIndex
126  int iCounter = 0;
127  for(const FiffChInfo &info : m_lInterpolationData.fiffInfo.chs) {
129  (info.unit == FIFF_UNIT_T || info.unit == FIFF_UNIT_V)) {
130  if(m_lInterpolationData.fiffInfo.bads.contains(info.ch_name)) {
131  m_lInterpolationData.vecExcludeIndex.push_back(iCounter);
132  }
133  iCounter++;
134  }
135  }
136 
137  //sensor projecting: One time operation because surface and sensors can not change
139  vecSensorPos);
140 
142 
144 }
145 
146 //=============================================================================================================
147 
149 {
151  qDebug() << "RtSensorInterpolationMatWorker::updateBadChannels - Set interpolation info first.";
152  return;
153  }
154 
156 
157  //filtering of bad channels out of the distance table
161 
162  //set vecExcludeIndex
164  int iCounter = 0;
165  for(const FiffChInfo &info : m_lInterpolationData.fiffInfo.chs) {
167  (info.unit == FIFF_UNIT_T || info.unit == FIFF_UNIT_V)) {
168  if(m_lInterpolationData.fiffInfo.bads.contains(info.ch_name)) {
169  m_lInterpolationData.vecExcludeIndex.push_back(iCounter);
170  }
171  iCounter++;
172  }
173  }
174 
175  emitMatrix();
176 }
177 
178 //=============================================================================================================
179 
181 {
183  qDebug() << "RtSensorInterpolationMatWorker::calculateInterpolationOperator - Set interpolation info first.";
184  return;
185  }
186 
187  //SCDC with cancel distance
192 
193  //filtering of bad channels out of the distance table
197 
198  emitMatrix();
199 }
200 
201 //=============================================================================================================
202 
204 {
205  //create Interpolation matrix
211 }
DISP3DLIB::Interpolation::cubic
static double cubic(const double dIn)
Definition: interpolation.cpp:191
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::interpolationFunction
double(* interpolationFunction)(double)
Definition: rtsensorinterpolationmatworker.h:166
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::matVertices
Eigen::MatrixX3f matVertices
Definition: rtsensorinterpolationmatworker.h:158
FIFFLIB::FiffInfo
FIFF measurement file information.
Definition: fiff_info.h:84
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::vecNeighborVertices
QVector< QVector< int > > vecNeighborVertices
Definition: rtsensorinterpolationmatworker.h:162
DISP3DLIB::RtSensorInterpolationMatWorker::setBadChannels
void setBadChannels(const FIFFLIB::FiffInfo &info)
Definition: rtsensorinterpolationmatworker.cpp:148
DISP3DLIB::GeometryInfo::projectSensors
static QVector< int > projectSensors(const Eigen::MatrixX3f &matVertices, const QVector< Eigen::Vector3f > &vecSensorPositions)
Calculates the nearest neighbor (euclidian distance) vertex to each sensor.
Definition: geometryinfo.cpp:150
DISP3DLIB::RtSensorInterpolationMatWorker::setInterpolationFunction
void setInterpolationFunction(const QString &sInterpolationFunction)
Definition: rtsensorinterpolationmatworker.cpp:74
FIFFLIB::FiffChInfo::ch_name
QString ch_name
Definition: fiff_ch_info.h:127
FIFFLIB::FiffInfoBase::bads
QStringList bads
Definition: fiff_info_base.h:220
DISP3DLIB::RtSensorInterpolationMatWorker::emitMatrix
void emitMatrix()
Definition: rtsensorinterpolationmatworker.cpp:203
DISP3DLIB::Interpolation::linear
static double linear(const double dIn)
Definition: interpolation.cpp:170
DISP3DLIB::RtSensorInterpolationMatWorker::setCancelDistance
void setCancelDistance(double dCancelDist)
Definition: rtsensorinterpolationmatworker.cpp:97
FIFFLIB::FiffChInfo::unit
fiff_int_t unit
Definition: fiff_ch_info.h:125
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::matDistanceMatrix
QSharedPointer< Eigen::MatrixXd > matDistanceMatrix
Definition: rtsensorinterpolationmatworker.h:157
DISP3DLIB::RtSensorInterpolationMatWorker::RtSensorInterpolationMatWorker
RtSensorInterpolationMatWorker()
Definition: rtsensorinterpolationmatworker.cpp:64
rtsensorinterpolationmatworker.h
RtSensorInterpolationMatWorker class declaration.
DISP3DLIB::RtSensorInterpolationMatWorker::m_lInterpolationData
struct DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData m_lInterpolationData
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::vecMappedSubset
QVector< int > vecMappedSubset
Definition: rtsensorinterpolationmatworker.h:160
DISP3DLIB::RtSensorInterpolationMatWorker::calculateInterpolationOperator
void calculateInterpolationOperator()
Definition: rtsensorinterpolationmatworker.cpp:180
DISP3DLIB::RtSensorInterpolationMatWorker::m_bInterpolationInfoIsInit
bool m_bInterpolationInfoIsInit
Definition: rtsensorinterpolationmatworker.h:169
FIFFLIB::FiffChInfo
Channel info descriptor.
Definition: fiff_ch_info.h:74
FIFFLIB::FiffInfoBase::chs
QList< FiffChInfo > chs
Definition: fiff_info_base.h:223
DISP3DLIB::RtSensorInterpolationMatWorker::newInterpolationMatrixCalculated
void newInterpolationMatrixCalculated(QSharedPointer< Eigen::SparseMatrix< float > > pMatInterpolationMatrix)
DISP3DLIB::RtSensorInterpolationMatWorker::setInterpolationInfo
void setInterpolationInfo(const Eigen::MatrixX3f &matVertices, const QVector< QVector< int > > &vecNeighborVertices, const QVector< Eigen::Vector3f > &vecSensorPos, const FIFFLIB::FiffInfo &fiffInfo, int iSensorType)
Definition: rtsensorinterpolationmatworker.cpp:107
DISP3DLIB::Interpolation::gaussian
static double gaussian(const double dIn)
Definition: interpolation.cpp:177
FIFFLIB::FiffChInfo::kind
fiff_int_t kind
Definition: fiff_ch_info.h:121
DISP3DLIB::Interpolation::square
static double square(const double dIn)
Definition: interpolation.cpp:184
DISP3DLIB::Interpolation::createInterpolationMat
static QSharedPointer< Eigen::SparseMatrix< float > > createInterpolationMat(const QVector< int > &vecProjectedSensors, const QSharedPointer< Eigen::MatrixXd > matDistanceTable, double(*interpolationFunction)(double), const double dCancelDist=FLOAT_INFINITY, const QVector< int > &vecExcludeIndex=QVector< int >())
Definition: interpolation.cpp:71
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::dCancelDistance
double dCancelDistance
Definition: rtsensorinterpolationmatworker.h:155
DISP3DLIB::GeometryInfo::scdc
static QSharedPointer< Eigen::MatrixXd > scdc(const Eigen::MatrixX3f &matVertices, const QVector< QVector< int > > &vecNeighborVertices, QVector< int > &pVecVertSubset, double dCancelDist=FLOAT_INFINITY)
scdc Calculates surface constrained distances on a mesh.
Definition: geometryinfo.cpp:78
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::fiffInfo
FIFFLIB::FiffInfo fiffInfo
Definition: rtsensorinterpolationmatworker.h:164
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::iSensorType
int iSensorType
Definition: rtsensorinterpolationmatworker.h:154
DISP3DLIB::RtSensorInterpolationMatWorker::InterpolationData::vecExcludeIndex
QVector< int > vecExcludeIndex
Definition: rtsensorinterpolationmatworker.h:161
DISP3DLIB::GeometryInfo::filterBadChannels
static QVector< int > filterBadChannels(QSharedPointer< Eigen::MatrixXd > matDistanceTable, const FIFFLIB::FiffInfo &fiffInfo, qint32 iSensorType)
filterBadChannels Filters bad channels from distance table
Definition: geometryinfo.cpp:314