MNE-CPP  beta 1.0
rtnoise.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef RTNOISE_H
38 #define RTNOISE_H
39 
40 //*************************************************************************************************************
41 //=============================================================================================================
42 // INCLUDES
43 //=============================================================================================================
44 
45 #include "rtinv_global.h"
46 
47 
48 //*************************************************************************************************************
49 //=============================================================================================================
50 // FIFF INCLUDES
51 //=============================================================================================================
52 
53 #include <fiff/fiff_cov.h>
54 #include <fiff/fiff_info.h>
55 
56 
57 //*************************************************************************************************************
58 //=============================================================================================================
59 // Generics INCLUDES
60 //=============================================================================================================
61 
63 
64 
65 //*************************************************************************************************************
66 //=============================================================================================================
67 // QT INCLUDES
68 //=============================================================================================================
69 
70 #include <QThread>
71 #include <QMutex>
72 #include <QSharedPointer>
73 
74 
75 //*************************************************************************************************************
76 //=============================================================================================================
77 // Eigen INCLUDES
78 //=============================================================================================================
79 
80 #include <Eigen/Core>
81 #include <unsupported/Eigen/FFT>
82 
83 //*************************************************************************************************************
84 //=============================================================================================================
85 // DEFINE NAMESPACE INVRTLIB
86 //=============================================================================================================
87 
88 namespace RTINVLIB
89 {
90 
91 
92 //*************************************************************************************************************
93 //=============================================================================================================
94 // USED NAMESPACES
95 //=============================================================================================================
96 
97 using namespace Eigen;
98 using namespace IOBuffer;
99 using namespace FIFFLIB;
100 
101 
102 //=============================================================================================================
108 class RTINVSHARED_EXPORT RtNoise : public QThread
109 {
110  Q_OBJECT
111 public:
112  typedef QSharedPointer<RtNoise> SPtr;
113  typedef QSharedPointer<const RtNoise> ConstSPtr;
115  //=========================================================================================================
123  explicit RtNoise(qint32 p_iMaxSamples, FiffInfo::SPtr p_pFiffInfo, qint32 p_dataLen, QObject *parent = 0);
124 
125  //=========================================================================================================
129  ~RtNoise();
130 
131  //=========================================================================================================
137  void append(const MatrixXd &p_DataSegment);
138 
139  //=========================================================================================================
145  inline bool isRunning();
146 
147 
148  //=========================================================================================================
154  virtual bool start();
155 
156  //=========================================================================================================
162  virtual bool stop();
163 
164 signals:
165  //=========================================================================================================
171  void SpecCalculated(Eigen::MatrixXd);
172 
173 protected:
174  //=========================================================================================================
180  virtual void run();
181 
182  QVector <float> hanning(int N, short itype);
183 
184 private:
185  QMutex mutex;
187  quint32 m_iMaxSamples;
189  quint32 m_iNewMaxSamples;
191  FiffInfo::SPtr m_pFiffInfo;
193  bool m_bIsRunning;
195  CircularMatrixBuffer<double>::SPtr m_pRawMatrixBuffer;
197  QVector <float> m_fWin;
198 
199  double m_Fs;
200 
201  qint32 m_iFFTlength;
202  qint32 m_dataLength;
203 
204 protected:
205  int NumOfBlocks;
206  int BlockSize ;
207  int Sensors ;
208  int BlockIndex ;
209 
210  MatrixXd CircBuf;
211 
212 public:
213  MatrixXd SpecData;
214  QMutex ReadMutex;
215 
216  bool SendDataToBuffer;
217 
218 };
219 
220 //*************************************************************************************************************
221 //=============================================================================================================
222 // INLINE DEFINITIONS
223 //=============================================================================================================
224 
225 inline bool RtNoise::isRunning()
226 {
227  return m_bIsRunning;
228 }
229 
230 } // NAMESPACE
231 
232 #ifndef metatype_matrix
233 #define metatype_matrix
234 Q_DECLARE_METATYPE(Eigen::MatrixXd);
235 #endif
236 
237 #endif // RtNoise_H
Q_DECLARE_METATYPE(Eigen::MatrixXd)
CircularMatrixBuffer class declaration.
rtinv library export/import macros.
The circular matrix buffer.
QSharedPointer< FiffInfo > SPtr
Definition: fiff_info.h:99
Real-time Noise estimation.
Definition: rtnoise.h:108
FiffInfo class declaration.
bool isRunning()
Definition: rtnoise.h:225
Definition: fiff.h:98
QSharedPointer< RtNoise > SPtr
Definition: rtnoise.h:112
#define RTINVSHARED_EXPORT
Definition: rtinv_global.h:58
Definition: rtave.h:89
QSharedPointer< const RtNoise > ConstSPtr
Definition: rtnoise.h:113
FiffCov class declaration.