MNE-CPP  0.1.9
A Framework for Electrophysiology
sensorsettreeitem.cpp
Go to the documentation of this file.
1 //=============================================================================================================
35 //=============================================================================================================
36 // INCLUDES
37 //=============================================================================================================
38 
39 #include "sensorsettreeitem.h"
40 #include "sensorsurfacetreeitem.h"
41 #include "sensorpositiontreeitem.h"
42 
43 #include "../../3dhelpers/renderable3Dentity.h"
44 
45 #include <mne/mne_bem.h>
46 #include <fiff/fiff_ch_info.h>
47 
48 //=============================================================================================================
49 // QT INCLUDES
50 //=============================================================================================================
51 
52 //=============================================================================================================
53 // EIGEN INCLUDES
54 //=============================================================================================================
55 
56 #include <Eigen/Core>
57 
58 //=============================================================================================================
59 // USED NAMESPACES
60 //=============================================================================================================
61 
62 using namespace FSLIB;
63 using namespace MNELIB;
64 using namespace DISP3DLIB;
65 using namespace FIFFLIB;
66 
67 //=============================================================================================================
68 // DEFINE MEMBER METHODS
69 //=============================================================================================================
70 
71 SensorSetTreeItem::SensorSetTreeItem(int iType, const QString& text)
72 : AbstractTreeItem(iType, text)
73 {
74  initItem();
75 }
76 
77 //=============================================================================================================
78 
80 {
81  this->setEditable(false);
82  this->setCheckable(true);
83  this->setCheckState(Qt::Checked);
84  this->setToolTip("Sensor item");
85 }
86 
87 //=============================================================================================================
88 
89 void SensorSetTreeItem::addData(const MNEBem &tSensor,
90  const QList<FiffChInfo>& lChInfo,
91  const QString& sDataType,
92  const QStringList& bads,
93  Qt3DCore::QEntity* p3DEntityParent)
94 {
96  m_pRenderable3DEntity = new Renderable3DEntity(p3DEntityParent);
97  }
98 
99  //Generate sensor surfaces as childs
100  for(int i = 0; i < tSensor.size(); ++i) {
101  SensorSurfaceTreeItem* pSurfItem = new SensorSurfaceTreeItem(m_pRenderable3DEntity, Data3DTreeModelItemTypes::SensorSurfaceItem);
102  pSurfItem->addData(tSensor[i]);
103 
104  QList<QStandardItem*> list;
105  list << pSurfItem;
106  list << new QStandardItem(pSurfItem->toolTip());
107  this->appendRow(list);
108  }
109 
110  //Sort MEG channel types
111  QList<FiffChInfo> lChInfoGrad;
112  QList<FiffChInfo> lChInfoMag;
113  QList<FiffChInfo> lChInfoEEG;
114 
115  for(int i = 0; i < lChInfo.size(); ++i) {
116  if(lChInfo.at(i).unit == FIFF_UNIT_T_M) {
117  lChInfoGrad << lChInfo.at(i);
118  } else if(lChInfo.at(i).unit == FIFF_UNIT_T) {
119  lChInfoMag << lChInfo.at(i);
120  } else if(lChInfo.at(i).kind == FIFFV_EEG_CH) {
121  lChInfoEEG << lChInfo.at(i);
122  }
123  }
124 
125  //Add sensor locations as child items
126  if(!lChInfoGrad.isEmpty() && sDataType == "MEG") {
127  SensorPositionTreeItem* pSensorPosItem = new SensorPositionTreeItem(m_pRenderable3DEntity, Data3DTreeModelItemTypes::SensorPositionItem, "Grad");
128  pSensorPosItem->addData(lChInfoGrad, "MEG", bads);
129 
130  QList<QStandardItem*> list;
131  list << pSensorPosItem;
132  list << new QStandardItem(pSensorPosItem->toolTip());
133  this->appendRow(list);
134  }
135 
136  if(!lChInfoMag.isEmpty() && sDataType == "MEG") {
137  SensorPositionTreeItem* pSensorPosItem = new SensorPositionTreeItem(m_pRenderable3DEntity, Data3DTreeModelItemTypes::SensorPositionItem, "Mag");
138  pSensorPosItem->addData(lChInfoMag, "MEG", bads);
139 
140  QList<QStandardItem*> list;
141  list << pSensorPosItem;
142  list << new QStandardItem(pSensorPosItem->toolTip());
143  this->appendRow(list);
144  }
145 
146  if(!lChInfoEEG.isEmpty() && sDataType == "EEG") {
147  SensorPositionTreeItem* pSensorPosItem = new SensorPositionTreeItem(m_pRenderable3DEntity, Data3DTreeModelItemTypes::SensorPositionItem, "EEG");
148  pSensorPosItem->addData(lChInfoEEG, "EEG", bads);
149 
150  QList<QStandardItem*> list;
151  list << pSensorPosItem;
152  list << new QStandardItem(pSensorPosItem->toolTip());
153  this->appendRow(list);
154  }
155 }
156 
157 //=============================================================================================================
158 
159 void SensorSetTreeItem::setTransform(const Qt3DCore::QTransform& transform)
160 {
162  m_pRenderable3DEntity->setTransform(transform);
163  }
164 }
165 
166 //=============================================================================================================
167 
168 void SensorSetTreeItem::setTransform(const FiffCoordTrans& transform, bool bApplyInverse)
169 {
171  m_pRenderable3DEntity->setTransform(transform, bApplyInverse);
172  }
173 }
174 
175 //=============================================================================================================
176 
177 void SensorSetTreeItem::applyTransform(const Qt3DCore::QTransform& transform)
178 {
180  m_pRenderable3DEntity->applyTransform(transform);
181  }
182 }
183 
184 //=============================================================================================================
185 
186 void SensorSetTreeItem::applyTransform(const FiffCoordTrans& transform, bool bApplyInverse)
187 {
189  m_pRenderable3DEntity->applyTransform(transform, bApplyInverse);
190  }
191 }
DISP3DLIB::SensorSetTreeItem::m_pRenderable3DEntity
QPointer< Renderable3DEntity > m_pRenderable3DEntity
Definition: sensorsettreeitem.h:166
DISP3DLIB::SensorSurfaceTreeItem
SensorSurfaceTreeItem provides a generic brain tree item to hold sensor surfaces.
Definition: sensorsurfacetreeitem.h:89
MNELIB::MNEBem
BEM descritpion.
Definition: mne_bem.h:89
DISP3DLIB::SensorPositionTreeItem
SensorPositionTreeItem provides a tree item to visualize sensor position data.
Definition: sensorpositiontreeitem.h:92
DISP3DLIB::SensorPositionTreeItem::addData
void addData(const QList< FIFFLIB::FiffChInfo > &lChInfo, const QString &sDataType, const QStringList &bads=QStringList())
Definition: sensorpositiontreeitem.cpp:91
DISP3DLIB::AbstractTreeItem
Provides the basic tree item.
Definition: abstracttreeitem.h:76
fiff_ch_info.h
FiffChInfo class declaration.
DISP3DLIB::SensorSetTreeItem::addData
void addData(const MNELIB::MNEBem &tSensor, const QList< FIFFLIB::FiffChInfo > &lChInfo, const QString &sDataType, const QStringList &bads=QStringList(), Qt3DCore::QEntity *p3DEntityParent=0)
Definition: sensorsettreeitem.cpp:89
DISP3DLIB::SensorSurfaceTreeItem::addData
void addData(const MNELIB::MNEBemSurface &tSensorSurface)
Definition: sensorsurfacetreeitem.cpp:90
sensorsettreeitem.h
SensorSetTreeItem class declaration.
DISP3DLIB::SensorSetTreeItem::initItem
void initItem()
Definition: sensorsettreeitem.cpp:79
MNELIB::MNEBem::size
qint32 size() const
Definition: mne_bem.h:271
mne_bem.h
MNEBem class declaration.
sensorsurfacetreeitem.h
SensorSurfaceTreeItem class declaration.
DISP3DLIB::Renderable3DEntity
Base class for renederable 3D QEntities.
Definition: renderable3Dentity.h:88
sensorpositiontreeitem.h
SensorPositionTreeItem class declaration.
FIFFLIB::FiffCoordTrans
Coordinate transformation description.
Definition: fiff_coord_trans.h:74
DISP3DLIB::SensorSetTreeItem::setTransform
virtual void setTransform(const Qt3DCore::QTransform &transform)
Definition: sensorsettreeitem.cpp:159
DISP3DLIB::SensorSetTreeItem::applyTransform
virtual void applyTransform(const Qt3DCore::QTransform &transform)
Definition: sensorsettreeitem.cpp:177