MNE-CPP  0.1.9
A Framework for Electrophysiology
mnedatatreeitem.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //=============================================================================================================
37 // INCLUDES
38 //=============================================================================================================
39 
40 #include "mnedatatreeitem.h"
41 #include "../../workers/rtSourceLoc/rtsourcedatacontroller.h"
42 #include "../common/metatreeitem.h"
43 #include "../common/abstractmeshtreeitem.h"
44 #include "../common/gpuinterpolationitem.h"
45 #include "../freesurfer/fssurfacetreeitem.h"
46 #include "../../3dhelpers/custommesh.h"
47 #include "../../materials/pervertexphongalphamaterial.h"
48 
49 #include <mne/mne_sourceestimate.h>
51 #include <fs/surfaceset.h>
52 #include <fs/annotationset.h>
53 
54 //=============================================================================================================
55 // QT INCLUDES
56 //=============================================================================================================
57 
58 #include <QVector3D>
59 #include <Qt3DCore/QEntity>
60 
61 //=============================================================================================================
62 // EIGEN INCLUDES
63 //=============================================================================================================
64 
65 #include <Eigen/Core>
66 
67 //=============================================================================================================
68 // USED NAMESPACES
69 //=============================================================================================================
70 
71 using namespace Eigen;
72 using namespace MNELIB;
73 using namespace DISP3DLIB;
74 using namespace FSLIB;
75 using namespace FIFFLIB;
76 
77 //=============================================================================================================
78 // DEFINE MEMBER METHODS
79 //=============================================================================================================
80 
81 MneDataTreeItem::MneDataTreeItem(int iType,
82  const QString &text,
83  bool bUseGPU)
84 : AbstractTreeItem(iType, text)
85 , m_bIsDataInit(false)
86 , m_bUseGPU(bUseGPU)
87 {
88  initItem();
89 }
90 
91 //=============================================================================================================
92 
94 {
95  m_pRtSourceDataController->deleteLater();
96 }
97 
98 //=============================================================================================================
99 
101 {
102  this->setCheckable(true);
103  this->setCheckState(Qt::Checked);
104  this->setEditable(false);
105  this->setToolTip("MNE Data item");
106 
107  //Add items
108  QList<QStandardItem*> list;
109  QVariant data;
110 
111  MetaTreeItem* pItemStreamStatus = new MetaTreeItem(MetaTreeItemTypes::StreamStatus, "Stream data on/off");
112  connect(pItemStreamStatus, &MetaTreeItem::checkStateChanged,
114  list << pItemStreamStatus;
115  list << new QStandardItem(pItemStreamStatus->toolTip());
116  this->appendRow(list);
117  pItemStreamStatus->setCheckable(true);
118  pItemStreamStatus->setCheckState(Qt::Unchecked);
119 
120  data.setValue(false);
121  pItemStreamStatus->setData(data, MetaTreeItemRoles::StreamStatus);
122 
123  QString defaultVisualizationType = "Interpolation based";
124  MetaTreeItem* pItemVisuaizationType = new MetaTreeItem(MetaTreeItemTypes::VisualizationType, defaultVisualizationType);
125  connect(pItemVisuaizationType, &MetaTreeItem::dataChanged,
127  list.clear();
128  list << pItemVisuaizationType;
129  list << new QStandardItem(pItemVisuaizationType->toolTip());
130  this->appendRow(list);
131  data.setValue(defaultVisualizationType);
132  pItemVisuaizationType->setData(data, MetaTreeItemRoles::VisualizationType);
133 
134  MetaTreeItem* pItemColormapType = new MetaTreeItem(MetaTreeItemTypes::ColormapType, "Hot");
135  connect(pItemColormapType, &MetaTreeItem::dataChanged,
137  list.clear();
138  list << pItemColormapType;
139  list << new QStandardItem(pItemColormapType->toolTip());
140  this->appendRow(list);
141  data.setValue(QString("Hot"));
142  pItemColormapType->setData(data, MetaTreeItemRoles::ColormapType);
143 
144  MetaTreeItem* pItemSourceLocNormValue = new MetaTreeItem(MetaTreeItemTypes::DataThreshold, "0.0,5.5,15");
145  connect(pItemSourceLocNormValue, &MetaTreeItem::dataChanged,
147  list.clear();
148  list << pItemSourceLocNormValue;
149  list << new QStandardItem(pItemSourceLocNormValue->toolTip());
150  this->appendRow(list);
151  data.setValue(QVector3D(0.0,5.5,15));
152  pItemSourceLocNormValue->setData(data, MetaTreeItemRoles::DataThreshold);
153 
154  MetaTreeItem *pItemStreamingInterval = new MetaTreeItem(MetaTreeItemTypes::StreamingTimeInterval, "17");
155  connect(pItemStreamingInterval, &MetaTreeItem::dataChanged,
157  list.clear();
158  list << pItemStreamingInterval;
159  list << new QStandardItem(pItemStreamingInterval->toolTip());
160  this->appendRow(list);
161  data.setValue(17);
162  pItemStreamingInterval->setData(data, MetaTreeItemRoles::StreamingTimeInterval);
163 
164  MetaTreeItem *pItemLoopedStreaming = new MetaTreeItem(MetaTreeItemTypes::LoopedStreaming, "Loop last data");
165  connect(pItemLoopedStreaming, &MetaTreeItem::checkStateChanged,
167  pItemLoopedStreaming->setCheckable(true);
168  pItemLoopedStreaming->setCheckState(Qt::Checked);
169  list.clear();
170  list << pItemLoopedStreaming;
171  list << new QStandardItem(pItemLoopedStreaming->toolTip());
172  this->appendRow(list);
173 
174  MetaTreeItem *pItemAveragedStreaming = new MetaTreeItem(MetaTreeItemTypes::NumberAverages, "17");
175  connect(pItemAveragedStreaming, &MetaTreeItem::dataChanged,
177  list.clear();
178  list << pItemAveragedStreaming;
179  list << new QStandardItem(pItemAveragedStreaming->toolTip());
180  this->appendRow(list);
181  data.setValue(1);
182  pItemAveragedStreaming->setData(data, MetaTreeItemRoles::NumberAverages);
183 
184 // MetaTreeItem *pItemCancelDistance = new MetaTreeItem(MetaTreeItemTypes::CancelDistance, "0.05");
185 // list.clear();
186 // list << pItemCancelDistance;
187 // list << new QStandardItem(pItemCancelDistance->toolTip());
188 // this->appendRow(list);
189 // data.setValue(0.05);
190 // pItemCancelDistance->setData(data, MetaTreeItemRoles::CancelDistance);
191 // connect(pItemCancelDistance, &MetaTreeItem::dataChanged,
192 // this, &MneDataTreeItem::onCancelDistanceChanged);
193 
194  MetaTreeItem* pInterpolationFunction = new MetaTreeItem(MetaTreeItemTypes::InterpolationFunction, "Cubic");
195  connect(pInterpolationFunction, &MetaTreeItem::dataChanged,
197  list.clear();
198  list << pInterpolationFunction;
199  list << new QStandardItem(pInterpolationFunction->toolTip());
200  this->appendRow(list);
201  data.setValue(QString("Cubic"));
202  pInterpolationFunction->setData(data, MetaTreeItemRoles::InterpolationFunction);
203 }
204 
205 //=============================================================================================================
206 
207 void MneDataTreeItem::initData(const MNEForwardSolution& tForwardSolution,
208  const SurfaceSet& tSurfSet,
209  const AnnotationSet& tAnnotSet,
210  Qt3DCore::QEntity* p3DEntityParent)
211 {
212  if(tForwardSolution.src.size() < 2 || tAnnotSet.size() < 2 || tSurfSet.size() < 2) {
213  qDebug() << "MneDataTreeItem::initData - Two hemisphere were not found. Check input.";
214  qDebug() << "MneDataTreeItem::initData - tForwardSolution.src.size(): "<<tForwardSolution.src.size();
215  qDebug() << "MneDataTreeItem::initData - tSurfSet.size(): "<<tSurfSet.size();
216  qDebug() << "MneDataTreeItem::initData - tAnnotSet.size(): "<<tAnnotSet.size();
217  return;
218  }
219 
220  //Set data based on clusterd or full source space
221  bool isClustered = tForwardSolution.src[0].isClustered();
222 
223  VectorXi clustVertNoTemp, clustVertNoLeft, clustVertNoRight;
224 
225  for(int i = 0; i < tForwardSolution.src.size(); ++i) {
226  if(isClustered) {
227  //When clustered source space, the idx no's are the annotation labels. Take the .cluster_info.centroidVertno instead.
228  clustVertNoTemp.resize(tForwardSolution.src[i].cluster_info.centroidVertno.size());
229  for(int j = 0; j < clustVertNoTemp.rows(); ++j) {
230  clustVertNoTemp(j) = tForwardSolution.src[i].cluster_info.centroidVertno.at(j);
231  }
232  } else {
233  clustVertNoTemp = tForwardSolution.src[i].vertno;
234  }
235 
236  if(i == 0) {
237  clustVertNoLeft = clustVertNoTemp;
238  } else if (i == 1) {
239  clustVertNoRight = clustVertNoTemp;
240  }
241  }
242 
243  //Add meta information as item children
244  QList<QStandardItem*> list;
245  QVariant data;
246 
247  QString sIsClustered = isClustered ? "Clustered" : "Full";
248  MetaTreeItem* pItemSourceSpaceType = new MetaTreeItem(MetaTreeItemTypes::SourceSpaceType, sIsClustered);
249  pItemSourceSpaceType->setEditable(false);
250  list.clear();
251  list << pItemSourceSpaceType;
252  list << new QStandardItem(pItemSourceSpaceType->toolTip());
253  this->appendRow(list);
254  data.setValue(sIsClustered);
255  pItemSourceSpaceType->setData(data, MetaTreeItemRoles::SourceSpaceType);
256 
257  //Process annotation data for patch based visualization
258  QList<FSLIB::Label> qListLabelsLeft, qListLabelsRight;
259  QList<RowVector4i> qListLabelRGBAs;
260 
261  VectorXi vecLabelIdsLeftHemi;
262  VectorXi vecLabelIdsRightHemi;
263 
264  vecLabelIdsLeftHemi = tAnnotSet[0].getLabelIds();
265  vecLabelIdsRightHemi = tAnnotSet[1].getLabelIds();
266  tAnnotSet[0].toLabels(tSurfSet[0], qListLabelsLeft, qListLabelRGBAs);
267  tAnnotSet[1].toLabels(tSurfSet[1], qListLabelsRight, qListLabelRGBAs);
268 
269  //set rt data corresponding to the hemisphere
272  }
273 
274  //Create InterpolationItems for CPU or GPU usage
275  if(m_bUseGPU) {
277  {
279  Data3DTreeModelItemTypes::GpuInterpolationItem,
280  QStringLiteral("3D Plot - Left"));
281 
282  m_pInterpolationItemLeftGPU->initData(tSurfSet[0].rr(),
283  tSurfSet[0].nn(),
284  tSurfSet[0].tris());
285 
286  m_pInterpolationItemLeftGPU->setPosition(QVector3D(-tSurfSet[0].offset()(0),
287  -tSurfSet[0].offset()(1),
288  -tSurfSet[0].offset()(2)));
289 
290  QList<QStandardItem*> list;
292  list << new QStandardItem(m_pInterpolationItemLeftGPU->toolTip());
293  this->appendRow(list);
294 
295  m_pInterpolationItemLeftGPU->setAlpha(1.0f);
296  }
297 
299  {
301  Data3DTreeModelItemTypes::GpuInterpolationItem,
302  QStringLiteral("3D Plot - Right"));
303 
304  m_pInterpolationItemRightGPU->initData(tSurfSet[1].rr(),
305  tSurfSet[1].nn(),
306  tSurfSet[1].tris());
307 
308  m_pInterpolationItemRightGPU->setPosition(QVector3D(-tSurfSet[1].offset()(0),
309  -tSurfSet[1].offset()(1),
310  -tSurfSet[1].offset()(2)));
311 
312  QList<QStandardItem*> list;
314  list << new QStandardItem(m_pInterpolationItemRightGPU->toolTip());
315  this->appendRow(list);
316 
317  m_pInterpolationItemRightGPU->setAlpha(1.0f);
318  }
319 
320  m_pRtSourceDataController->setStreamSmoothedData(false);
321 
324 
327 
330  } else {
333  Data3DTreeModelItemTypes::AbstractMeshItem,
334  QStringLiteral("3D Plot - Left"));
335 
336  m_pInterpolationItemLeftCPU->setMeshData(tSurfSet[0].rr(),
337  tSurfSet[0].nn(),
338  tSurfSet[0].tris(),
340  Qt3DRender::QGeometryRenderer::Triangles);
341 
342  m_pInterpolationItemLeftCPU->setPosition(QVector3D(-tSurfSet[0].offset()(0),
343  -tSurfSet[0].offset()(1),
344  -tSurfSet[0].offset()(2)));
345 
346  QList<QStandardItem*> list;
348  list << new QStandardItem(m_pInterpolationItemLeftCPU->toolTip());
349  this->appendRow(list);
350 
351  m_pInterpolationItemLeftCPU->setAlpha(1.0f);
352 
353  //Set material to enable sorting
354  QPointer<PerVertexPhongAlphaMaterial> pBemMaterial = new PerVertexPhongAlphaMaterial(true);
355  m_pInterpolationItemLeftCPU->setMaterial(pBemMaterial);
356  }
357 
360  Data3DTreeModelItemTypes::AbstractMeshItem,
361  QStringLiteral("3D Plot - Right"));
362 
363  m_pInterpolationItemRightCPU->setMeshData(tSurfSet[1].rr(),
364  tSurfSet[1].nn(),
365  tSurfSet[1].tris(),
367  Qt3DRender::QGeometryRenderer::Triangles);
368 
369  m_pInterpolationItemRightCPU->setPosition(QVector3D(-tSurfSet[1].offset()(0),
370  -tSurfSet[1].offset()(1),
371  -tSurfSet[1].offset()(2)));
372 
373  QList<QStandardItem*> list;
375  list << new QStandardItem(m_pInterpolationItemRightCPU->toolTip());
376  this->appendRow(list);
377 
378  m_pInterpolationItemRightCPU->setAlpha(1.0f);
379 
380  //Set material to enable sorting
381  QPointer<PerVertexPhongAlphaMaterial> pBemMaterial = new PerVertexPhongAlphaMaterial(true);
382  m_pInterpolationItemRightCPU->setMaterial(pBemMaterial);
383  }
384 
387  }
388 
389  m_pRtSourceDataController->setInterpolationInfo(tForwardSolution.src[0].rr,
390  tForwardSolution.src[1].rr,
391  tForwardSolution.src[0].neighbor_vert,
392  tForwardSolution.src[1].neighbor_vert,
393  clustVertNoLeft,
394  clustVertNoRight);
395 
396  m_pRtSourceDataController->setSurfaceColor(FsSurfaceTreeItem::createCurvatureVertColor(tSurfSet[0].curv()),
397  FsSurfaceTreeItem::createCurvatureVertColor(tSurfSet[1].curv()));
398 
399  m_pRtSourceDataController->setAnnotationInfo(vecLabelIdsLeftHemi,
400  vecLabelIdsRightHemi,
401  qListLabelsLeft,
402  qListLabelsRight,
403  clustVertNoLeft,
404  clustVertNoRight);
405 
406  m_bIsDataInit = true;
407 }
408 
409 //=============================================================================================================
410 
411 void MneDataTreeItem::addData(const MNESourceEstimate& tSourceEstimate)
412 {
413  if(!m_bIsDataInit) {
414  qDebug() << "MneDataTreeItem::addData - Item has not been initialized yet!";
415  return;
416  }
417 
418  //Set new data into item's data. The set data is for example needed in the delegate to calculate the histogram.
419  QVariant data;
420  data.setValue(tSourceEstimate.data);
421  this->setData(data, Data3DTreeModelItemRoles::Data);
422 
423  // Only draw activation if item is checked
424  if(m_pRtSourceDataController && this->checkState() == Qt::Checked) {
425  m_pRtSourceDataController->addData(tSourceEstimate.data);
426  }
427 }
428 
429 //=============================================================================================================
430 
432 {
433  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::LoopedStreaming);
434 
435  for(int i = 0; i < lItems.size(); i++) {
436  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
437  pAbstractItem->setCheckState(state == true ? Qt::Checked : Qt::Unchecked);
438  QVariant data;
439  data.setValue(state);
440  pAbstractItem->setData(data, MetaTreeItemRoles::LoopedStreaming);
441  }
442  }
443 }
444 
445 //=============================================================================================================
446 
448 {
449  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::StreamStatus);
450 
451  for(int i = 0; i < lItems.size(); i++) {
452  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
453  pAbstractItem->setCheckState(state == true ? Qt::Checked : Qt::Unchecked);
454  QVariant data;
455  data.setValue(state);
456  pAbstractItem->setData(data, MetaTreeItemRoles::StreamStatus);
457  }
458  }
459 }
460 
461 //=============================================================================================================
462 
464 {
465  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::StreamingTimeInterval);
466 
467  for(int i = 0; i < lItems.size(); i++) {
468  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
469  QVariant data;
470  data.setValue(iMSec);
471  pAbstractItem->setData(data, MetaTreeItemRoles::StreamingTimeInterval);
472  pAbstractItem->setData(data, Qt::DisplayRole);
473  }
474  }
475 }
476 
477 //=============================================================================================================
478 
479 void MneDataTreeItem::setNumberAverages(int iNumberAverages)
480 {
481  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::NumberAverages);
482 
483  for(int i = 0; i < lItems.size(); i++) {
484  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
485  QVariant data;
486  data.setValue(iNumberAverages);
487  pAbstractItem->setData(data, MetaTreeItemRoles::NumberAverages);
488  pAbstractItem->setData(data, Qt::DisplayRole);
489  }
490  }
491 }
492 
493 //=============================================================================================================
494 
495 void MneDataTreeItem::setColormapType(const QString& sColormap)
496 {
497  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::ColormapType);
498 
499  for(int i = 0; i < lItems.size(); i++) {
500  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
501  QVariant data;
502  data.setValue(sColormap);
503  pAbstractItem->setData(data, MetaTreeItemRoles::ColormapType);
504  pAbstractItem->setData(data, Qt::DisplayRole);
505  }
506  }
507 }
508 
509 //=============================================================================================================
510 
511 void MneDataTreeItem::setVisualizationType(const QString& sVisualizationType)
512 {
513  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::VisualizationType);
514 
515  for(int i = 0; i < lItems.size(); i++) {
516  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
517  QVariant data;
518  data.setValue(sVisualizationType);
519  pAbstractItem->setData(data, MetaTreeItemRoles::VisualizationType);
520  pAbstractItem->setData(data, Qt::DisplayRole);
521  }
522  }
523 }
524 
525 //=============================================================================================================
526 
527 void MneDataTreeItem::setThresholds(const QVector3D& vecThresholds)
528 {
529  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::DataThreshold);
530 
531  for(int i = 0; i < lItems.size(); i++) {
532  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
533  QVariant data;
534  data.setValue(vecThresholds);
535  pAbstractItem->setData(data, MetaTreeItemRoles::DataThreshold);
536 
537  QString sTemp = QString("%1,%2,%3").arg(vecThresholds.x()).arg(vecThresholds.y()).arg(vecThresholds.z());
538  data.setValue(sTemp);
539  pAbstractItem->setData(data, Qt::DisplayRole);
540  }
541  }
542 }
543 
544 //=============================================================================================================
545 
546 //void MneDataTreeItem::setCancelDistance(double dCancelDist)
547 //{
548 // QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::CancelDistance);
549 
550 // for(int i = 0; i < lItems.size(); i++) {
551 // if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
552 // QVariant data;
553 // data.setValue(dCancelDist);
554 // pAbstractItem->setData(data, MetaTreeItemRoles::CancelDistance);
555 // pAbstractItem->setData(data, Qt::DisplayRole);
556 // }
557 // }
558 //}
559 
560 //=============================================================================================================
561 
562 void MneDataTreeItem::setInterpolationFunction(const QString &sInterpolationFunction)
563 {
564  QList<QStandardItem*> lItems = this->findChildren(MetaTreeItemTypes::InterpolationFunction);
565 
566  for(int i = 0; i < lItems.size(); i++) {
567  if(MetaTreeItem* pAbstractItem = dynamic_cast<MetaTreeItem*>(lItems.at(i))) {
568  QVariant data;
569  data.setValue(sInterpolationFunction);
570  pAbstractItem->setData(data, MetaTreeItemRoles::InterpolationFunction);
571  pAbstractItem->setData(data, Qt::DisplayRole);
572  }
573  }
574 }
575 
576 //=============================================================================================================
577 
578 void MneDataTreeItem::setSFreq(const double dSFreq)
579 {
581  m_pRtSourceDataController->setSFreq(dSFreq);
582  }
583 }
584 
585 //=============================================================================================================
586 
587 void MneDataTreeItem::setAlpha(float fAlpha)
588 {
590  m_pInterpolationItemLeftCPU->setAlpha(fAlpha);
591  }
593  m_pInterpolationItemLeftGPU->setAlpha(fAlpha);
594  }
596  m_pInterpolationItemRightCPU->setAlpha(fAlpha);
597  }
599  m_pInterpolationItemRightGPU->setAlpha(fAlpha);
600  }
601 }
602 
603 //=============================================================================================================
604 
605 void MneDataTreeItem::setTransform(const Qt3DCore::QTransform& transform)
606 {
608  m_pInterpolationItemLeftCPU->setTransform(transform);
609  }
610 
612  m_pInterpolationItemLeftGPU->setTransform(transform);
613  }
614 
616  m_pInterpolationItemRightCPU->setTransform(transform);
617  }
618 
620  m_pInterpolationItemRightGPU->setTransform(transform);
621  }
622 }
623 
624 //=============================================================================================================
625 
626 void MneDataTreeItem::setTransform(const FiffCoordTrans& transform, bool bApplyInverse)
627 {
629  m_pInterpolationItemLeftCPU->setTransform(transform, bApplyInverse);
630  }
631 
633  m_pInterpolationItemLeftGPU->setTransform(transform, bApplyInverse);
634  }
635 
637  m_pInterpolationItemRightCPU->setTransform(transform, bApplyInverse);
638  }
639 
641  m_pInterpolationItemRightGPU->setTransform(transform, bApplyInverse);
642  }
643 }
644 
645 //=============================================================================================================
646 
647 void MneDataTreeItem::applyTransform(const Qt3DCore::QTransform& transform)
648 {
650  m_pInterpolationItemLeftCPU->applyTransform(transform);
651  }
652 
654  m_pInterpolationItemLeftGPU->applyTransform(transform);
655  }
656 
658  m_pInterpolationItemRightCPU->applyTransform(transform);
659  }
660 
662  m_pInterpolationItemRightGPU->applyTransform(transform);
663  }
664 }
665 
666 //=============================================================================================================
667 
668 void MneDataTreeItem::applyTransform(const FiffCoordTrans& transform, bool bApplyInverse)
669 {
671  m_pInterpolationItemLeftCPU->applyTransform(transform, bApplyInverse);
672  }
673 
675  m_pInterpolationItemLeftGPU->applyTransform(transform, bApplyInverse);
676  }
677 
679  m_pInterpolationItemRightCPU->applyTransform(transform, bApplyInverse);
680  }
681 
683  m_pInterpolationItemRightGPU->applyTransform(transform, bApplyInverse);
684  }
685 }
686 
687 //=============================================================================================================
688 
689 void MneDataTreeItem::onCheckStateWorkerChanged(const Qt::CheckState& checkState)
690 {
692  if(checkState == Qt::Checked) {
693  m_pRtSourceDataController->setStreamingState(true);
694  } else if(checkState == Qt::Unchecked) {
695  m_pRtSourceDataController->setStreamingState(false);
696  }
697  }
698 }
699 
700 //=============================================================================================================
701 
702 void MneDataTreeItem::onNewRtSmoothedDataAvailable(const Eigen::MatrixX4f &matColorMatrixLeftHemi,
703  const Eigen::MatrixX4f &matColorMatrixRightHemi)
704 {
706  m_pInterpolationItemLeftCPU->setVertColor(matColorMatrixLeftHemi);
707  }
708 
710  m_pInterpolationItemRightCPU->setVertColor(matColorMatrixRightHemi);
711  }
712 }
713 
714 //=============================================================================================================
715 
716 void MneDataTreeItem::onNewInterpolationMatrixLeftAvailable(QSharedPointer<Eigen::SparseMatrix<float> > pMatInterpolationMatrixLeftHemi)
717 {
718  //qDebug()<<"MneDataTreeItem::onNewInterpolationMatrixLeftAvailable";
720  m_pInterpolationItemLeftGPU->setInterpolationMatrix(pMatInterpolationMatrixLeftHemi);
721  }
722 }
723 
724 //=============================================================================================================
725 
726 void MneDataTreeItem::onNewInterpolationMatrixRightAvailable(QSharedPointer<Eigen::SparseMatrix<float> > pMatInterpolationMatrixRightHemi)
727 {
728  //qDebug()<<"MneDataTreeItem::onNewInterpolationMatrixRightAvailable";
730  m_pInterpolationItemRightGPU->setInterpolationMatrix(pMatInterpolationMatrixRightHemi);
731  }
732 }
733 
734 //=============================================================================================================
735 
736 void MneDataTreeItem::onNewRtRawData(const Eigen::VectorXd &vecDataVectorLeftHemi,
737  const Eigen::VectorXd &vecDataVectorRightHemi)
738 {
740  m_pInterpolationItemLeftGPU->addNewRtData(vecDataVectorLeftHemi.cast<float>());
741  }
742 
744  m_pInterpolationItemRightGPU->addNewRtData(vecDataVectorRightHemi.cast<float>());
745  }
746 }
747 
748 //=============================================================================================================
749 
750 void MneDataTreeItem::onColormapTypeChanged(const QVariant& sColormapType)
751 {
752  if(sColormapType.canConvert<QString>()) {
753  if(m_bUseGPU) {
755  m_pInterpolationItemLeftGPU->setColormapType(sColormapType.toString());
756  }
757 
759  m_pInterpolationItemRightGPU->setColormapType(sColormapType.toString());
760  }
761  } else {
763  m_pRtSourceDataController->setColormapType(sColormapType.toString());
764  }
765  }
766  }
767 }
768 
769 //=============================================================================================================
770 
771 void MneDataTreeItem::onTimeIntervalChanged(const QVariant& iMSec)
772 {
773  if(iMSec.canConvert<int>()) {
775  m_pRtSourceDataController->setTimeInterval(iMSec.toInt());
776  }
777  }
778 }
779 
780 //=============================================================================================================
781 
782 void MneDataTreeItem::onDataThresholdChanged(const QVariant& vecThresholds)
783 {
784  if(vecThresholds.canConvert<QVector3D>()) {
785  if(m_bUseGPU) {
787  m_pInterpolationItemLeftGPU->setThresholds(vecThresholds.value<QVector3D>());
788  }
789 
791  m_pInterpolationItemRightGPU->setThresholds(vecThresholds.value<QVector3D>());
792  }
793  } else {
795  m_pRtSourceDataController->setThresholds(vecThresholds.value<QVector3D>());
796  }
797  }
798  }
799 }
800 
801 //=============================================================================================================
802 
803 void MneDataTreeItem::onVisualizationTypeChanged(const QVariant& sVisType)
804 {
805  if(sVisType.canConvert<QString>()) {
806  int iVisType = Data3DTreeModelItemRoles::InterpolationBased;
807 
808  if(sVisType.toString() == "Annotation based") {
809  iVisType = Data3DTreeModelItemRoles::AnnotationBased;
810  }
811 
813  m_pRtSourceDataController->setVisualizationType(iVisType);
814  }
815  }
816 }
817 
818 //=============================================================================================================
819 
820 void MneDataTreeItem::onCheckStateLoopedStateChanged(const Qt::CheckState& checkState)
821 {
823  if(checkState == Qt::Checked) {
824  m_pRtSourceDataController->setLoopState(true);
825  } else if(checkState == Qt::Unchecked) {
826  m_pRtSourceDataController->setLoopState(false);
827  }
828  }
829 }
830 
831 //=============================================================================================================
832 
833 void MneDataTreeItem::onNumberAveragesChanged(const QVariant& iNumAvr)
834 {
835  if(iNumAvr.canConvert<int>()) {
837  m_pRtSourceDataController->setNumberAverages(iNumAvr.toInt());
838  }
839  }
840 }
841 
842 //=============================================================================================================
843 
844 //void MneDataTreeItem::onCancelDistanceChanged(const QVariant &dCancelDist)
845 //{
846 // if(dCancelDist.canConvert<double>())
847 // {
848 // if(m_pRtSourceDataController) {
849 // m_pRtSourceDataController->setCancelDistance(dCancelDist.toDouble());
850 // }
851 // }
852 //}
853 
854 //=============================================================================================================
855 
856 void MneDataTreeItem::onInterpolationFunctionChanged(const QVariant &sInterpolationFunction)
857 {
858  if(sInterpolationFunction.canConvert<QString>()) {
860  m_pRtSourceDataController->setInterpolationFunction(sInterpolationFunction.toString());
861  }
862  }
863 }
FSLIB::AnnotationSet::toLabels
bool toLabels(const SurfaceSet &p_surfSet, QList< Label > &p_qListLabels, QList< Eigen::RowVector4i > &p_qListLabelRGBAs, const QStringList &lLabelPicks=QStringList()) const
Definition: annotationset.cpp:172
mnedatatreeitem.h
MneDataTreeItem class declaration.
DISP3DLIB::MneDataTreeItem::onVisualizationTypeChanged
void onVisualizationTypeChanged(const QVariant &sVisType)
Definition: mnedatatreeitem.cpp:803
DISP3DLIB::MneDataTreeItem::setLoopState
void setLoopState(bool state)
Definition: mnedatatreeitem.cpp:431
DISP3DLIB::MneDataTreeItem::initItem
void initItem()
Definition: mnedatatreeitem.cpp:100
DISP3DLIB::RtSourceDataController::newInterpolationMatrixRightAvailable
void newInterpolationMatrixRightAvailable(QSharedPointer< Eigen::SparseMatrix< float > > pMatInterpolationMatrixRightHemi)
DISP3DLIB::FsSurfaceTreeItem::createCurvatureVertColor
static Eigen::MatrixX4f createCurvatureVertColor(const Eigen::VectorXf &curvature, const QColor &colSulci=QColor(50, 50, 50), const QColor &colGyri=QColor(125, 125, 125))
Definition: fssurfacetreeitem.cpp:189
DISP3DLIB::RtSourceDataController::newRtRawDataAvailable
void newRtRawDataAvailable(const Eigen::VectorXd &vecDataVectorLeftHemi, const Eigen::VectorXd &vecDataVectorRightHemi)
DISP3DLIB::MneDataTreeItem::m_pInterpolationItemLeftGPU
QPointer< GpuInterpolationItem > m_pInterpolationItemLeftGPU
Definition: mnedatatreeitem.h:399
DISP3DLIB::RtSourceDataController::newInterpolationMatrixLeftAvailable
void newInterpolationMatrixLeftAvailable(QSharedPointer< Eigen::SparseMatrix< float > > pMatInterpolationMatrixLeftHemi)
DISP3DLIB::PerVertexPhongAlphaMaterial
PerVertexPhongAlphaMaterial is provides a Qt3D material with own shader support.
Definition: pervertexphongalphamaterial.h:80
FSLIB::AnnotationSet
Annotation set.
Definition: annotationset.h:80
DISP3DLIB::MneDataTreeItem::m_bIsDataInit
bool m_bIsDataInit
Definition: mnedatatreeitem.h:393
annotationset.h
AnnotationSet class declaration.
MNELIB::MNEForwardSolution
Forward operator.
Definition: mne_forwardsolution.h:170
DISP3DLIB::MneDataTreeItem::applyTransform
virtual void applyTransform(const Qt3DCore::QTransform &transform)
Definition: mnedatatreeitem.cpp:647
DISP3DLIB::MneDataTreeItem::m_pRtSourceDataController
QPointer< RtSourceDataController > m_pRtSourceDataController
Definition: mnedatatreeitem.h:396
DISP3DLIB::MneDataTreeItem::onDataThresholdChanged
void onDataThresholdChanged(const QVariant &vecThresholds)
Definition: mnedatatreeitem.cpp:782
FSLIB::SurfaceSet::size
qint32 size() const
Definition: surfaceset.h:264
DISP3DLIB::MetaTreeItem::dataChanged
void dataChanged(const QVariant &data)
DISP3DLIB::AbstractTreeItem
Provides the basic tree item.
Definition: abstracttreeitem.h:76
DISP3DLIB::MneDataTreeItem::onTimeIntervalChanged
void onTimeIntervalChanged(const QVariant &iMSec)
Definition: mnedatatreeitem.cpp:771
DISP3DLIB::RtSourceDataController
This controller organizes data streaming and interpolation matrix calculations. It only uses Queued s...
Definition: rtsourcedatacontroller.h:83
DISP3DLIB::MneDataTreeItem::~MneDataTreeItem
~MneDataTreeItem()
Definition: mnedatatreeitem.cpp:93
DISP3DLIB::AbstractTreeItem::setData
void setData(const QVariant &value, int role=Qt::UserRole+1)
Definition: abstracttreeitem.cpp:78
DISP3DLIB::MneDataTreeItem::setThresholds
void setThresholds(const QVector3D &vecThresholds)
Definition: mnedatatreeitem.cpp:527
DISP3DLIB::MneDataTreeItem::onColormapTypeChanged
void onColormapTypeChanged(const QVariant &sColormapType)
Definition: mnedatatreeitem.cpp:750
DISP3DLIB::MneDataTreeItem::onNewRtRawData
virtual void onNewRtRawData(const Eigen::VectorXd &vecDataVectorLeftHemi, const Eigen::VectorXd &vecDataVectorRightHemi)
Definition: mnedatatreeitem.cpp:736
surfaceset.h
SurfaceSet class declaration.
DISP3DLIB::RtSourceDataController::newRtSmoothedDataAvailable
void newRtSmoothedDataAvailable(const Eigen::MatrixX4f &matColorMatrixLeftHemi, const Eigen::MatrixX4f &matColorMatrixRightHemi)
DISP3DLIB::AbstractTreeItem::findChildren
QList< QStandardItem * > findChildren(int type)
Definition: abstracttreeitem.cpp:112
DISP3DLIB::MneDataTreeItem::setInterpolationFunction
virtual void setInterpolationFunction(const QString &sInterpolationFunction)
Definition: mnedatatreeitem.cpp:562
MNELIB::MNESourceEstimate::data
Eigen::MatrixXd data
Definition: mne_sourceestimate.h:200
MNELIB::MNESourceEstimate
Source estimation.
Definition: mne_sourceestimate.h:84
DISP3DLIB::MneDataTreeItem::onInterpolationFunctionChanged
virtual void onInterpolationFunctionChanged(const QVariant &sInterpolationFunction)
Definition: mnedatatreeitem.cpp:856
MNELIB::MNEForwardSolution::src
MNESourceSpace src
Definition: mne_forwardsolution.h:529
FSLIB::AnnotationSet::size
qint32 size() const
Definition: annotationset.h:267
DISP3DLIB::MneDataTreeItem::onCheckStateWorkerChanged
void onCheckStateWorkerChanged(const Qt::CheckState &checkState)
Definition: mnedatatreeitem.cpp:689
DISP3DLIB::MetaTreeItem
Provides a generic brain tree item.
Definition: metatreeitem.h:74
FSLIB::SurfaceSet
A hemisphere set of surfaces.
Definition: surfaceset.h:71
DISP3DLIB::MneDataTreeItem::onNewRtSmoothedDataAvailable
void onNewRtSmoothedDataAvailable(const Eigen::MatrixX4f &matColorMatrixLeftHemi, const Eigen::MatrixX4f &matColorMatrixRightHemi)
Definition: mnedatatreeitem.cpp:702
DISP3DLIB::AbstractMeshTreeItem
Provides a generic mesh tree item.
Definition: abstractmeshtreeitem.h:90
DISP3DLIB::MneDataTreeItem::onCheckStateLoopedStateChanged
void onCheckStateLoopedStateChanged(const Qt::CheckState &checkState)
Definition: mnedatatreeitem.cpp:820
DISP3DLIB::MneDataTreeItem::m_pInterpolationItemRightGPU
QPointer< GpuInterpolationItem > m_pInterpolationItemRightGPU
Definition: mnedatatreeitem.h:401
mne_forwardsolution.h
MNEForwardSolution class declaration, which provides the forward solution including the source space ...
DISP3DLIB::MneDataTreeItem::m_pInterpolationItemLeftCPU
QPointer< AbstractMeshTreeItem > m_pInterpolationItemLeftCPU
Definition: mnedatatreeitem.h:398
DISP3DLIB::MneDataTreeItem::initData
void initData(const MNELIB::MNEForwardSolution &tForwardSolution, const FSLIB::SurfaceSet &tSurfSet, const FSLIB::AnnotationSet &tAnnotSet, Qt3DCore::QEntity *p3DEntityParent)
Definition: mnedatatreeitem.cpp:207
FIFFLIB::FiffCoordTrans
Coordinate transformation description.
Definition: fiff_coord_trans.h:74
DISP3DLIB::GpuInterpolationItem
This item is used for signal interpolation with GPU support.
Definition: gpuinterpolationitem.h:98
DISP3DLIB::MneDataTreeItem::setTransform
virtual void setTransform(const Qt3DCore::QTransform &transform)
Definition: mnedatatreeitem.cpp:605
DISP3DLIB::AbstractTreeItem::checkStateChanged
void checkStateChanged(const Qt::CheckState &checkState)
MNELIB::MNESourceSpace::size
qint32 size() const
Definition: mne_sourcespace.h:333
DISP3DLIB::MneDataTreeItem::m_pInterpolationItemRightCPU
QPointer< AbstractMeshTreeItem > m_pInterpolationItemRightCPU
Definition: mnedatatreeitem.h:400
DISP3DLIB::MneDataTreeItem::setAlpha
void setAlpha(float fAlpha)
Definition: mnedatatreeitem.cpp:587
DISP3DLIB::MneDataTreeItem::m_bUseGPU
bool m_bUseGPU
Definition: mnedatatreeitem.h:394
mne_sourceestimate.h
MNESourceEstimate class declaration.
DISP3DLIB::MneDataTreeItem::setSFreq
void setSFreq(const double dSFreq)
Definition: mnedatatreeitem.cpp:578
DISP3DLIB::MneDataTreeItem::setStreamingState
void setStreamingState(bool state)
Definition: mnedatatreeitem.cpp:447
DISP3DLIB::MneDataTreeItem::onNumberAveragesChanged
void onNumberAveragesChanged(const QVariant &iNumAvr)
Definition: mnedatatreeitem.cpp:833
DISP3DLIB::MneDataTreeItem::setTimeInterval
void setTimeInterval(int iMSec)
Definition: mnedatatreeitem.cpp:463
DISP3DLIB::MneDataTreeItem::setColormapType
void setColormapType(const QString &sColormap)
Definition: mnedatatreeitem.cpp:495
DISP3DLIB::MneDataTreeItem::setVisualizationType
void setVisualizationType(const QString &sVisualizationType)
Definition: mnedatatreeitem.cpp:511
DISP3DLIB::MneDataTreeItem::addData
void addData(const MNELIB::MNESourceEstimate &tSourceEstimate)
Definition: mnedatatreeitem.cpp:411
DISP3DLIB::MneDataTreeItem::onNewInterpolationMatrixRightAvailable
virtual void onNewInterpolationMatrixRightAvailable(QSharedPointer< Eigen::SparseMatrix< float > > pMatInterpolationMatrixRightHemi)
Definition: mnedatatreeitem.cpp:726
DISP3DLIB::MneDataTreeItem::onNewInterpolationMatrixLeftAvailable
virtual void onNewInterpolationMatrixLeftAvailable(QSharedPointer< Eigen::SparseMatrix< float > > pMatInterpolationMatrixLeftHemi)
Definition: mnedatatreeitem.cpp:716
DISP3DLIB::MneDataTreeItem::setNumberAverages
void setNumberAverages(int iNumberAverages)
Definition: mnedatatreeitem.cpp:479