MNE-CPP  0.1.9
A Framework for Electrophysiology
measurementtreeitem.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "measurementtreeitem.h"
42 #include "../hemisphere/hemispheretreeitem.h"
43 #include "../sourcespace/sourcespacetreeitem.h"
44 #include "../sourcedata/mnedatatreeitem.h"
45 #include "../sourcedata/ecddatatreeitem.h"
46 #include "../network/networktreeitem.h"
47 #include "../freesurfer/fssurfacetreeitem.h"
48 #include "../freesurfer/fsannotationtreeitem.h"
49 #include "../digitizer/digitizersettreeitem.h"
50 #include "../digitizer/digitizertreeitem.h"
51 #include "../mri/mritreeitem.h"
52 #include "../subject/subjecttreeitem.h"
53 #include "../bem/bemtreeitem.h"
54 #include "../bem/bemsurfacetreeitem.h"
55 #include "../sensorspace/sensorsettreeitem.h"
56 #include "../sensorspace/sensorsurfacetreeitem.h"
57 #include "../sensordata/sensordatatreeitem.h"
58 
59 #include <fs/label.h>
60 #include <fs/annotationset.h>
61 #include <fs/surfaceset.h>
62 
63 #include <mne/mne_sourceestimate.h>
64 #include <mne/mne_sourcespace.h>
65 #include <mne/mne_bem_surface.h>
66 
68 
70 
71 //=============================================================================================================
72 // QT INCLUDES
73 //=============================================================================================================
74 
75 //=============================================================================================================
76 // EIGEN INCLUDES
77 //=============================================================================================================
78 
79 #include <Eigen/Core>
80 
81 //=============================================================================================================
82 // USED NAMESPACES
83 //=============================================================================================================
84 
85 using namespace FSLIB;
86 using namespace MNELIB;
87 using namespace DISP3DLIB;
88 using namespace INVERSELIB;
89 using namespace CONNECTIVITYLIB;
90 using namespace Eigen;
91 using namespace FIFFLIB;
92 
93 //=============================================================================================================
94 // DEFINE MEMBER METHODS
95 //=============================================================================================================
96 
97 MeasurementTreeItem::MeasurementTreeItem(int iType,
98  const QString& text)
99 : AbstractTreeItem(iType, text)
100 {
101  initItem();
102 }
103 
104 //=============================================================================================================
105 
107 {
108  this->setEditable(false);
109  this->setCheckable(true);
110  this->setCheckState(Qt::Checked);
111  this->setToolTip("Measurement item");
112 }
113 
114 //=============================================================================================================
115 
116 QList<SourceSpaceTreeItem*> MeasurementTreeItem::addData(const MNESourceSpace& tSourceSpace,
117  Qt3DCore::QEntity* p3DEntityParent)
118 {
119  //Generate child items based on surface set input parameters
120  QList<SourceSpaceTreeItem*> pReturnItem;
121 
122  QList<QStandardItem*> itemList = this->findChildren(Data3DTreeModelItemTypes::HemisphereItem);
123 
124  //If there are more hemispheres in tSourceSpace than in the tree model
125  bool hemiItemFound = false;
126 
127  //Search for already created hemi items and add source space data respectivley
128  for(int i = 0; i < tSourceSpace.size(); ++i) {
129  for(int j = 0; j < itemList.size(); ++j) {
130  if(HemisphereTreeItem* pHemiItem = dynamic_cast<HemisphereTreeItem*>(itemList.at(j))) {
131  if(pHemiItem->data(Data3DTreeModelItemRoles::SurfaceHemi).toInt() == i) {
132  hemiItemFound = true;
133  pReturnItem.append(pHemiItem->addData(tSourceSpace[i], p3DEntityParent));
134  }
135  }
136  }
137 
138  if(!hemiItemFound) {
139  //Item does not exist yet, create it here.
140  HemisphereTreeItem* pHemiItem = new HemisphereTreeItem(Data3DTreeModelItemTypes::HemisphereItem);
141 
142  pReturnItem.append(pHemiItem->addData(tSourceSpace[i], p3DEntityParent));
143 
144  QList<QStandardItem*> list;
145  list << pHemiItem;
146  list << new QStandardItem(pHemiItem->toolTip());
147  this->appendRow(list);
148  }
149 
150  hemiItemFound = false;
151  }
152 
153  return pReturnItem;
154 }
155 
156 //=============================================================================================================
157 
159  const MNEForwardSolution& tForwardSolution,
160  const SurfaceSet& tSurfSet,
161  const AnnotationSet& tAnnotSet,
162  Qt3DCore::QEntity* p3DEntityParent,
163  bool bUseGPU)
164 {
165  if(!tSourceEstimate.isEmpty()) {
166  //CPU for source data
167  if(m_pMneDataTreeItem) {
168  m_pMneDataTreeItem->addData(tSourceEstimate);
169  } else {
170  //Add sensor data as child
171  //If item does not exists yet, create it here!
172  m_pMneDataTreeItem = new MneDataTreeItem(Data3DTreeModelItemTypes::MNEDataItem,
173  "MNE data",
174  bUseGPU);
175 
176  QList<QStandardItem*> list;
177  list << m_pMneDataTreeItem;
178  list << new QStandardItem(m_pMneDataTreeItem->toolTip());
179  this->appendRow(list);
180 
181  m_pMneDataTreeItem->initData(tForwardSolution,
182  tSurfSet,
183  tAnnotSet,
184  p3DEntityParent);
185 
186  m_pMneDataTreeItem->addData(tSourceEstimate);
187  }
188 
189  return m_pMneDataTreeItem;
190  }
191 
192  return Q_NULLPTR;
193 }
194 
195 //=============================================================================================================
196 
197 SensorDataTreeItem *MeasurementTreeItem::addData(const MatrixXd &tSensorData,
198  const MNEBemSurface &bemSurface,
199  const FiffInfo &fiffInfo,
200  const QString &sSensorType,
201  Qt3DCore::QEntity* p3DEntityParent,
202  bool bUseGPU)
203 {
204  if(!tSensorData.size() == 0) {
205  if(sSensorType == "EEG") {
206  //GPU for EEG data
208  m_pEEGSensorDataTreeItem->addData(tSensorData);
209  } else {
210  //Add sensor data as child
211  //If item does not exists yet, create it here!
212  m_pEEGSensorDataTreeItem = new SensorDataTreeItem(Data3DTreeModelItemTypes::SensorDataItem,
213  "Sensor Data",
214  bUseGPU);
215  m_pEEGSensorDataTreeItem->setText("EEG Data");
216 
217  QList<QStandardItem*> list;
218  list << m_pEEGSensorDataTreeItem;
219  list << new QStandardItem(m_pEEGSensorDataTreeItem->toolTip());
220  this->appendRow(list);
221 
222  m_pEEGSensorDataTreeItem->initData(bemSurface,
223  fiffInfo,
224  sSensorType,
225  p3DEntityParent);
226 
227  m_pEEGSensorDataTreeItem->addData(tSensorData);
228  }
229 
231  }
232 
233  if(sSensorType == "MEG") {
234  //GPU for EEG data
236  m_pMEGSensorDataTreeItem->addData(tSensorData);
237  } else {
238  //Add sensor data as child
239  //If item does not exists yet, create it here!
240  m_pMEGSensorDataTreeItem = new SensorDataTreeItem(Data3DTreeModelItemTypes::SensorDataItem,
241  "Sensor Data",
242  bUseGPU);
243  m_pMEGSensorDataTreeItem->setText("MEG Data");
244 
245  QList<QStandardItem*> list;
246  list << m_pMEGSensorDataTreeItem;
247  list << new QStandardItem(m_pMEGSensorDataTreeItem->toolTip());
248  this->appendRow(list);
249 
250  m_pMEGSensorDataTreeItem->initData(bemSurface,
251  fiffInfo,
252  sSensorType,
253  p3DEntityParent);
254 
255  m_pMEGSensorDataTreeItem->addData(tSensorData);
256  }
257 
259  }
260  }
261 
262  return Q_NULLPTR;
263 }
264 
265 //=============================================================================================================
266 
268  Qt3DCore::QEntity* p3DEntityParent)
269 {
270  if(pECDSet.size() > 0) {
271  //Add source estimation data as child
272  if(this->findChildren(Data3DTreeModelItemTypes::ECDDataItem).size() == 0) {
273  //If ecd data item does not exists yet, create it here!
274  if(!m_EcdDataTreeItem) {
275  m_EcdDataTreeItem = new EcdDataTreeItem(p3DEntityParent);
276  }
277 
278  QList<QStandardItem*> list;
279  list << m_EcdDataTreeItem;
280  list << new QStandardItem(m_EcdDataTreeItem->toolTip());
281  this->appendRow(list);
282 
283  m_EcdDataTreeItem->addData(pECDSet);
284 
285  } else {
286  if(m_EcdDataTreeItem) {
287  m_EcdDataTreeItem->addData(pECDSet);
288  }
289  }
290 
291  return m_EcdDataTreeItem;
292  } else {
293  qDebug() << "MeasurementTreeItem::addData - pECDSet is empty";
294  }
295 
296  return Q_NULLPTR;
297 }
298 
299 //=============================================================================================================
300 
302  Qt3DCore::QEntity *p3DEntityParent)
303 {
304  if(tDigitizer.size() > 0) {
305  //Find the digitizer kind
306  QList<QStandardItem*> itemDigitizerList = this->findChildren(Data3DTreeModelItemTypes::DigitizerSetItem);
307  DigitizerSetTreeItem* pReturnItem = Q_NULLPTR;
308 
309  //If digitizer does not exist, create a new one
310  if(itemDigitizerList.size() == 0) {
311  pReturnItem = new DigitizerSetTreeItem(Data3DTreeModelItemTypes::DigitizerSetItem,"Digitizer");
312  itemDigitizerList << pReturnItem;
313  itemDigitizerList << new QStandardItem(pReturnItem->toolTip());
314  this->appendRow(itemDigitizerList);
315  }
316 
317  // Add Data to the first Digitizer Set Item
318  //Check if it is really a digitizer tree item
319  if(itemDigitizerList.at(0)->type() == Data3DTreeModelItemTypes::DigitizerSetItem) {
320  if(pReturnItem = dynamic_cast<DigitizerSetTreeItem*>(itemDigitizerList.at(0))) {
321  pReturnItem->addData(tDigitizer, p3DEntityParent);
322  }
323  }
324 
325  return pReturnItem;
326  } else {
327  qDebug() << "MeasurementTreeItem::addData - digitizer set is empty";
328  }
329 
330  return Q_NULLPTR;
331 }
332 
333 //=============================================================================================================
334 
336  Qt3DCore::QEntity* p3DEntityParent)
337 {
338  if(!tNetworkData.getNodes().isEmpty()) {
339  NetworkTreeItem* pReturnItem = Q_NULLPTR;
340 
341  QPair<float,float> freqs = tNetworkData.getFrequencyRange();
342  QString sItemName = QString("%1").arg(tNetworkData.getConnectivityMethod()).arg(QString::number(freqs.first)).arg(QString::number(freqs.second));
343 
344  //Add network estimation data as child
345  QList<QStandardItem*> lItems = this->findChildren(sItemName);
346 
347  if(lItems.isEmpty()) {
348  pReturnItem = new NetworkTreeItem(p3DEntityParent);
349 
350  pReturnItem->setText(sItemName);
351 
352  QList<QStandardItem*> list;
353  list << pReturnItem;
354  list << new QStandardItem(pReturnItem->toolTip());
355  this->appendRow(list);
356 
357  pReturnItem->addData(tNetworkData);
358  } else {
359  if(lItems.first()) {
360  if(pReturnItem = dynamic_cast<NetworkTreeItem*>(lItems.first())) {
361  pReturnItem->addData(tNetworkData);
362  }
363  }
364  }
365 
366  return pReturnItem;
367  } else {
368  qDebug() << "MeasurementTreeItem::addData - network data is empty";
369  }
370 
371  return Q_NULLPTR;
372 }
DISP3DLIB::MeasurementTreeItem::m_EcdDataTreeItem
QPointer< EcdDataTreeItem > m_EcdDataTreeItem
Definition: measurementtreeitem.h:242
DISP3DLIB::DigitizerSetTreeItem::addData
void addData(const FIFFLIB::FiffDigPointSet &tDigitizer, Qt3DCore::QEntity *parent)
Definition: digitizersettreeitem.cpp:98
DISP3DLIB::HemisphereTreeItem::addData
FsSurfaceTreeItem * addData(const FSLIB::Surface &tSurface, const FSLIB::Annotation &tAnnotation, Qt3DCore::QEntity *p3DEntityParent=0)
Definition: hemispheretreeitem.cpp:95
CONNECTIVITYLIB::Network
This class holds information about a network, can compute a distance table and provide network metric...
Definition: network.h:88
DISP3DLIB::MeasurementTreeItem::m_pMneDataTreeItem
QPointer< MneDataTreeItem > m_pMneDataTreeItem
Definition: measurementtreeitem.h:235
DISP3DLIB::DigitizerSetTreeItem
DigitizerSetTreeItem provides a tree item to hold the set of digitizer data.
Definition: digitizersettreeitem.h:92
FIFFLIB::FiffInfo
FIFF measurement file information.
Definition: fiff_info.h:84
CONNECTIVITYLIB::Network::getFrequencyRange
const QPair< float, float > & getFrequencyRange() const
Definition: network.cpp:405
ecd_set.h
FiffDigPointSet class declaration.
DISP3DLIB::MneDataTreeItem
Provides a generic brain tree item to hold real time data.
Definition: mnedatatreeitem.h:99
DISP3DLIB::HemisphereTreeItem
Provides a generic brain tree item.
Definition: hemispheretreeitem.h:95
FSLIB::AnnotationSet
Annotation set.
Definition: annotationset.h:80
annotationset.h
AnnotationSet class declaration.
MNELIB::MNEForwardSolution
Forward operator.
Definition: mne_forwardsolution.h:170
MNELIB::MNESourceSpace
Source Space descritpion.
Definition: mne_sourcespace.h:92
DISP3DLIB::MeasurementTreeItem::addData
QList< SourceSpaceTreeItem * > addData(const MNELIB::MNESourceSpace &tSourceSpace, Qt3DCore::QEntity *p3DEntityParent=0)
Definition: measurementtreeitem.cpp:116
DISP3DLIB::SensorDataTreeItem
This item integrates GeometryInfo and Interpolation into Disp3D structure.
Definition: sensordatatreeitem.h:92
DISP3DLIB::AbstractTreeItem
Provides the basic tree item.
Definition: abstracttreeitem.h:76
INVERSELIB::ECDSet
Holds a set of Electric Current Dipoles.
Definition: ecd_set.h:80
MNELIB::MNESourceEstimate::isEmpty
bool isEmpty() const
Definition: mne_sourceestimate.h:218
INVERSELIB::ECDSet::size
qint32 size() const
Definition: ecd_set.h:193
DISP3DLIB::MeasurementTreeItem::m_pEEGSensorDataTreeItem
QPointer< SensorDataTreeItem > m_pEEGSensorDataTreeItem
Definition: measurementtreeitem.h:237
CONNECTIVITYLIB::Network::getNodes
const QList< QSharedPointer< NetworkNode > > & getNodes() const
Definition: network.cpp:156
surfaceset.h
SurfaceSet class declaration.
label.h
Label class declaration.
mne_bem_surface.h
MNEBemSurface class declaration.
DISP3DLIB::AbstractTreeItem::findChildren
QList< QStandardItem * > findChildren(int type)
Definition: abstracttreeitem.cpp:112
measurementtreeitem.h
MeasurementTreeItem class declaration.
MNELIB::MNESourceEstimate
Source estimation.
Definition: mne_sourceestimate.h:84
DISP3DLIB::MeasurementTreeItem::m_pMEGSensorDataTreeItem
QPointer< SensorDataTreeItem > m_pMEGSensorDataTreeItem
Definition: measurementtreeitem.h:238
FSLIB::SurfaceSet
A hemisphere set of surfaces.
Definition: surfaceset.h:71
CONNECTIVITYLIB::Network::getConnectivityMethod
QString getConnectivityMethod() const
Definition: network.cpp:203
DISP3DLIB::NetworkTreeItem::addData
void addData(const CONNECTIVITYLIB::Network &tNetworkData)
Definition: networktreeitem.cpp:142
mne_sourcespace.h
MNESourceSpace class declaration.
fiff_dig_point_set.h
FiffDigPointSet class declaration.
DISP3DLIB::EcdDataTreeItem
Provides a generic brain tree item to hold real time data.
Definition: ecddatatreeitem.h:86
MNELIB::MNEBemSurface
BEM surface provides geometry information.
Definition: mne_bem_surface.h:79
MNELIB::MNESourceSpace::size
qint32 size() const
Definition: mne_sourcespace.h:333
FIFFLIB::FiffDigPointSet::size
qint32 size() const
Definition: fiff_dig_point_set.h:271
DISP3DLIB::NetworkTreeItem
Provides a generic brain tree item to hold real time data.
Definition: networktreeitem.h:101
mne_sourceestimate.h
MNESourceEstimate class declaration.
DISP3DLIB::MeasurementTreeItem::initItem
void initItem()
Definition: measurementtreeitem.cpp:106
FIFFLIB::FiffDigPointSet
Holds a set of digitizer points.
Definition: fiff_dig_point_set.h:83