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 }
void addData(const CONNECTIVITYLIB::Network &tNetworkData)
QList< QStandardItem * > findChildren(int type)
QString getConnectivityMethod() const
Definition: network.cpp:202
This item integrates GeometryInfo and Interpolation into Disp3D structure.
QPointer< MneDataTreeItem > m_pMneDataTreeItem
FIFF measurement file information.
Definition: fiff_info.h:84
BEM surface provides geometry information.
QPointer< EcdDataTreeItem > m_EcdDataTreeItem
Provides a generic brain tree item to hold real time data.
Annotation set.
Definition: annotationset.h:80
MNESourceEstimate class declaration.
Provides a generic brain tree item to hold real time data.
Provides a generic brain tree item.
SurfaceSet class declaration.
Holds a set of Electric Current Dipoles.
Definition: ecd_set.h:80
Provides a generic brain tree item to hold real time data.
MNESourceSpace class declaration.
FiffDigPointSet class declaration.
QPointer< SensorDataTreeItem > m_pMEGSensorDataTreeItem
Source Space descritpion.
void addData(const FIFFLIB::FiffDigPointSet &tDigitizer, Qt3DCore::QEntity *parent)
MeasurementTreeItem class declaration.
A hemisphere set of surfaces.
Definition: surfaceset.h:71
Holds a set of digitizer points.
This class holds information about a network, can compute a distance table and provide network metric...
Definition: network.h:87
const QPair< float, float > & getFrequencyRange() const
Definition: network.cpp:404
DigitizerSetTreeItem provides a tree item to hold the set of digitizer data.
Provides the basic tree item.
FiffDigPointSet class declaration.
MNEBemSurface class declaration.
FsSurfaceTreeItem * addData(const FSLIB::Surface &tSurface, const FSLIB::Annotation &tAnnotation, Qt3DCore::QEntity *p3DEntityParent=0)
qint32 size() const
Definition: ecd_set.h:193
const QList< QSharedPointer< NetworkNode > > & getNodes() const
Definition: network.cpp:155
AnnotationSet class declaration.
QPointer< SensorDataTreeItem > m_pEEGSensorDataTreeItem
Label class declaration.
QList< SourceSpaceTreeItem * > addData(const MNELIB::MNESourceSpace &tSourceSpace, Qt3DCore::QEntity *p3DEntityParent=0)