MNE-CPP  beta 1.0
rtave.h
Go to the documentation of this file.
1 //=============================================================================================================
36 #ifndef RTAVE_H
37 #define RTAVE_H
38 
39 //*************************************************************************************************************
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "rtinv_global.h"
45 
46 
47 //*************************************************************************************************************
48 //=============================================================================================================
49 // FIFF INCLUDES
50 //=============================================================================================================
51 
52 #include <fiff/fiff_evoked.h>
53 #include <fiff/fiff_info.h>
54 
55 
56 //*************************************************************************************************************
57 //=============================================================================================================
58 // Generics INCLUDES
59 //=============================================================================================================
60 
62 
63 
64 //*************************************************************************************************************
65 //=============================================================================================================
66 // QT INCLUDES
67 //=============================================================================================================
68 
69 #include <QThread>
70 #include <QMutex>
71 #include <QSharedPointer>
72 #include <QSet>
73 #include <QList>
74 
75 
76 //*************************************************************************************************************
77 //=============================================================================================================
78 // Eigen INCLUDES
79 //=============================================================================================================
80 
81 #include <Eigen/Core>
82 
83 
84 //*************************************************************************************************************
85 //=============================================================================================================
86 // DEFINE NAMESPACE INVRTLIB
87 //=============================================================================================================
88 
89 namespace RTINVLIB
90 {
91 
92 
93 //*************************************************************************************************************
94 //=============================================================================================================
95 // USED NAMESPACES
96 //=============================================================================================================
97 
98 using namespace Eigen;
99 using namespace IOBuffer;
100 using namespace FIFFLIB;
101 
102 
103 //=============================================================================================================
109 class RTINVSHARED_EXPORT RtAve : public QThread
110 {
111  Q_OBJECT
112 public:
113  typedef QSharedPointer<RtAve> SPtr;
114  typedef QSharedPointer<const RtAve> ConstSPtr;
116  //=========================================================================================================
126  explicit RtAve(quint32 numAverages, quint32 p_iPreStimSamples, quint32 p_iPostStimSamples, FiffInfo::SPtr p_pFiffInfo, QObject *parent = 0);
127 
128  //=========================================================================================================
132  ~RtAve();
133 
134  //=========================================================================================================
140  void append(const MatrixXd &p_DataSegment);
141 
142  //=========================================================================================================
148  void setAverages(qint32 numAve);
149 
150  //=========================================================================================================
156  void setPreStim(qint32 samples);
157 
158  //=========================================================================================================
164  void setPostStim(qint32 samples);
165 
166  //=========================================================================================================
170  virtual bool start();
171 
172  //=========================================================================================================
178  virtual bool stop();
179 
180  //=========================================================================================================
186  inline bool isRunning();
187 
188 signals:
189  //=========================================================================================================
195  void evokedPreStim(FIFFLIB::FiffEvoked::SPtr p_pEvokedPreStim);
196 
197  //=========================================================================================================
203  void evokedPostStim(FIFFLIB::FiffEvoked::SPtr p_pEvokedPostStim);
204 
205  //=========================================================================================================
211  void evokedStim(FIFFLIB::FiffEvoked::SPtr p_pEvokedStim);
212 
213  //=========================================================================================================
217  void numAveragesChanged();
218 
219 protected:
220  //=========================================================================================================
226  virtual void run();
227 
228 private:
229  //=========================================================================================================
236  void assemblePostStimulus(const QList<QPair<QList<qint32>, MatrixXd> > &p_qListRawMatBuf, qint32 p_iStimIdx);
237 
238  //=========================================================================================================
245  void assemblePreStimulus(const QList<QPair<QList<qint32>, MatrixXd> > &p_qListRawMatBuf, qint32 p_iStimIdx);
246 
247  QMutex m_qMutex;
249  qint32 m_iNumAverages;
251  qint32 m_iPreStimSamples;
252  qint32 m_iPostStimSamples;
254  qint32 m_iNewPreStimSamples;
255  qint32 m_iNewPostStimSamples;
258  FiffInfo::SPtr m_pFiffInfo;
260  bool m_bIsRunning;
262  CircularMatrixBuffer<double>::SPtr m_pRawMatrixBuffer;
264  bool m_bAutoAspect;
267  QList<qint32> m_qListStimChannelIdcs;
269 // QList<fiff_int_t> m_qSetAspectKinds; /**< List of aspects to average. Each aspect is averaged separetely and released stored in evoked data.*/
270 
271  QList<QList<MatrixXd> > m_qListQListPreStimBuf;
272  QList<QList<MatrixXd> > m_qListQListPostStimBuf;
274  QList<MatrixXd> m_qListPreStimAve;
275  QList<MatrixXd> m_qListPostStimAve;
276  QList<MatrixXd> m_qListStimAve;
277 };
278 
279 //*************************************************************************************************************
280 //=============================================================================================================
281 // INLINE DEFINITIONS
282 //=============================================================================================================
283 
284 inline bool RtAve::isRunning()
285 {
286  return m_bIsRunning;
287 }
288 
289 } // NAMESPACE
290 
291 #ifndef metatype_fiffevokedsptr
292 #define metatype_fiffevokedsptr
294 #endif
295 
296 #endif // RTAVE_H
QSharedPointer< const RtAve > ConstSPtr
Definition: rtave.h:114
Q_DECLARE_METATYPE(FIFFLIB::FiffEvoked::SPtr)
CircularMatrixBuffer class declaration.
rtinv library export/import macros.
The circular matrix buffer.
QSharedPointer< FiffInfo > SPtr
Definition: fiff_info.h:99
FiffInfo class declaration.
Real-time averaging helper.
Definition: rtave.h:109
QSharedPointer< FiffEvoked > SPtr
Definition: fiff_evoked.h:94
Definition: fiff.h:98
#define RTINVSHARED_EXPORT
Definition: rtinv_global.h:58
Definition: rtave.h:89
QSharedPointer< RtAve > SPtr
Definition: rtave.h:113
bool isRunning()
Definition: rtave.h:284