MNE-CPP  beta 1.0
stcdatamodel.h
Go to the documentation of this file.
1 //=============================================================================================================
36 #ifndef STCDATAMODEL_H
37 #define STCDATAMODEL_H
38 
39 //*************************************************************************************************************
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "../disp3DNew_global.h"
45 
46 #include "stcdataworker.h"
47 
48 #include <fs/label.h>
49 #include <fs/surfaceset.h>
50 #include <fs/annotationset.h>
51 
52 #include <iostream>
53 
55 
56 
57 //*************************************************************************************************************
58 //=============================================================================================================
59 // Qt INCLUDES
60 //=============================================================================================================
61 
62 #include <QAbstractTableModel>
63 #include <QVector3D>
64 #include <QMap>
65 
66 
67 //*************************************************************************************************************
68 //=============================================================================================================
69 // Eigen INCLUDES
70 //=============================================================================================================
71 
72 #include <Eigen/Core>
73 
74 
75 //*************************************************************************************************************
76 //=============================================================================================================
77 // FORWARD DECLARATIONS
78 //=============================================================================================================
79 
80 namespace MNELIB
81 {
82  class MNESourceEstimate;
83 }
84 
85 
86 //*************************************************************************************************************
87 //=============================================================================================================
88 // DEFINE NAMESPACE DISP3DLIB
89 //=============================================================================================================
90 
91 namespace DISP3DNEWLIB
92 {
93 
94 //*************************************************************************************************************
95 //=============================================================================================================
96 // USED NAMESPACES
97 //=============================================================================================================
98 
99 using namespace Eigen;
100 using namespace MNELIB;
101 using namespace FSLIB;
102 
103 
104 //*************************************************************************************************************
105 //=============================================================================================================
106 // Define model roles
107 //=============================================================================================================
108 
109 namespace StcDataModelRoles
110 {
111  enum ItemRole{GetIndexLH = Qt::UserRole + 1001,
112  GetIndexRH = Qt::UserRole + 1002,
113  GetStcValLH = Qt::UserRole + 1003,
114  GetStcValRH = Qt::UserRole + 1004,
115  GetRelStcValLH = Qt::UserRole + 1005,
116  GetRelStcValRH = Qt::UserRole + 1006,
117  GetSmoothedStcValLH = Qt::UserRole + 1007,
118  GetSmoothedStcValRH = Qt::UserRole + 1008};
119 }
120 
121 //=============================================================================================================
127 class DISP3DNEWSHARED_EXPORT StcDataModel : public QAbstractTableModel
128 {
129  Q_OBJECT
130 public:
131  typedef QSharedPointer<StcDataModel> SPtr;
132  typedef QSharedPointer<const StcDataModel> ConstSPtr;
134  StcDataModel(QObject *parent = 0);
135 
136  ~StcDataModel();
137 
138  virtual int rowCount(const QModelIndex &parent = QModelIndex()) const ;
139  virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
140 
141  //=========================================================================================================
151  inline QVariant data(int row, int column, int role = Qt::DisplayRole) const;
152 
153  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
154  virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
155 
156  void addData(const MNESourceEstimate &stc);
157 
158  void init(const QString &subject_id, qint32 hemi, const QString &surf, const QString &subjects_dir, const QString &atlas, const MNEForwardSolution &forwardSolution);
159 
160  inline QVector3D getMin() const;
161  inline QVector3D getMax() const;
162 
163  //1..10000
164  void setAverage(qint32 samples);
165 
166  void setLoop(bool looping);
167 
168  //1..100
169  void setNormalization(qint32 fraction);
170 
171  void setStcSample(const VectorXd &sample);
172 
173  void setVertLabelIDs(const VectorXi &vertLabelIDs);
174 
175  VectorXd smoothEstimates(int niter, int hemi) const;
176 
177 private:
178  StcDataWorker::SPtr m_pWorker;
179 
180  bool m_bRTMode;
181  bool m_bModelInit;
182  bool m_bDataInit;
183  bool m_bIntervallSet;
184 
185  VectorXi m_vertLabelIds;
186 
187  QMap<qint32, qint32> m_qMapLabelIdChannelLH;
188  QMap<qint32, qint32> m_qMapLabelIdChannelRH;
189 
190  VectorXd m_vecCurStc;
191  VectorXd m_vecCurRelStc;
192 
193  double m_dStcNormMax;
194  double m_dStcNorm;
195 
196  //ToDo implement this model as a state pattern -> to be used as ROIStc model and full Stc model
197 
198  //ROI Stuff
199  QList<Label> m_qListLabels;
200  qint32 m_iLHSize;
201  QList<RowVector4i> m_qListRGBAs;
202  QList<Matrix3Xf> m_qListTriRRs;
203 
204  AnnotationSet m_annotationSet;
205  SurfaceSet m_surfSet;
206  MNEForwardSolution m_forwardSolution;
207 
208  QVector3D m_vecMinRR;
209  QVector3D m_vecMaxRR;
210 };
211 
212 
213 //*************************************************************************************************************
214 //=============================================================================================================
215 // INLINE DEFINITIONS
216 //=============================================================================================================
217 
218 inline QVariant StcDataModel::data(int row, int column, int role) const
219 {
220  return data(index(row, column), role);
221 }
222 
223 
224 //*************************************************************************************************************
225 
226 inline QVector3D StcDataModel::getMin() const
227 {
228  return m_vecMinRR;
229 }
230 
231 
232 //*************************************************************************************************************
233 
234 inline QVector3D StcDataModel::getMax() const
235 {
236  return m_vecMaxRR;
237 }
238 
239 } // NAMESPACE
240 
241 Q_DECLARE_METATYPE(Eigen::Matrix3Xf);
242 Q_DECLARE_METATYPE(Eigen::VectorXd);
243 Q_DECLARE_METATYPE(FSLIB::Label);
244 
245 #endif // STCDATAMODEL_H
QVariant data(int row, int column, int role=Qt::DisplayRole) const
Definition: stcdatamodel.h:218
Table model which prepares source estimate information.
Definition: stcdatamodel.h:127
QSharedPointer< const StcDataModel > ConstSPtr
Definition: stcdatamodel.h:132
QSharedPointer< StcDataModel > SPtr
Definition: stcdatamodel.h:131
SurfaceSet class declaration.
QSharedPointer< StcDataWorker > SPtr
Definition: stcdataworker.h:92
MNEForwardSolution class declaration, which provides the forward solution including the source space ...
Annotation set.
Definition: annotationset.h:96
AnnotationSet class declaration.
Label class declaration.
Freesurfer/MNE label.
Definition: label.h:97
A hemisphere set of surfaces.
Definition: surfaceset.h:83
StcDataWorker class declaration.