MNE-CPP  beta 1.0
babymeg.h
1 //=============================================================================================================
37 #ifndef BABYMEG_H
38 #define BABYMEG_H
39 
40 
41 //*************************************************************************************************************
42 //=============================================================================================================
43 // INCLUDES
44 //=============================================================================================================
45 
46 #include "babymeg_global.h"
47 #include "babymegclient.h"
48 
50 
51 
56 
57 
58 //*************************************************************************************************************
59 //=============================================================================================================
60 // FIFF INCLUDES
61 //=============================================================================================================
62 
63 #include <fiff/fiff_info.h>
64 #include <fiff/fiff.h>
65 
66 
67 //*************************************************************************************************************
68 //=============================================================================================================
69 // MNE INCLUDES
70 //=============================================================================================================
71 
72 #include <rtClient/rtcmdclient.h>
73 
74 
75 //*************************************************************************************************************
76 //=============================================================================================================
77 // Eigen INCLUDES
78 //=============================================================================================================
79 
80 #include <Eigen/Core>
81 #include <Eigen/SparseCore>
82 
83 
84 //*************************************************************************************************************
85 //=============================================================================================================
86 // QT INCLUDES
87 //=============================================================================================================
88 
89 #include <QtWidgets>
90 #include <QVector>
91 #include <QTimer>
92 
93 #define MAX_DATA_LEN 2000000000L
94 #define MAX_POS 2000000000L
95 
96 
97 //*************************************************************************************************************
98 //=============================================================================================================
99 // DEFINE NAMESPACE BabyMEGPlugin
100 //=============================================================================================================
101 
102 namespace BabyMEGPlugin
103 {
104 
105 
106 //*************************************************************************************************************
107 //=============================================================================================================
108 // USED NAMESPACES
109 //=============================================================================================================
110 
111 using namespace MNEX;
112 using namespace IOBuffer;
113 using namespace RTCLIENTLIB;
114 using namespace FIFFLIB;
115 using namespace XMEASLIB;
116 
117 
118 //*************************************************************************************************************
119 //=============================================================================================================
120 // FORWARD DECLARATIONS
121 //=============================================================================================================
122 
123 class BabyMEGProjectDialog;
124 
125 
126 //=============================================================================================================
132 class BABYMEGSHARED_EXPORT BabyMEG : public ISensor
133 {
134  Q_OBJECT
135  Q_PLUGIN_METADATA(IID "mne_x/1.0" FILE "babymeg.json") //NEw Qt5 Plugin system replaces Q_EXPORT_PLUGIN2 macro
136  // Use the Q_INTERFACES() macro to tell Qt's meta-object system about the interfaces
137  Q_INTERFACES(MNEX::ISensor)
138 
139  friend class BabyMEGSetupWidget;
140  friend class BabyMEGProjectDialog;
141  friend class BabyMEGSQUIDControlDgl;
142 
143 public:
144 
145  //=========================================================================================================
149  BabyMEG();
150 
151  //=========================================================================================================
155  virtual ~BabyMEG();
156 
157  //=========================================================================================================
161  void clear();
162 
163  //=========================================================================================================
167  virtual QSharedPointer<IPlugin> clone() const;
168 
169  //=========================================================================================================
177  QString getFilePath(bool currentTime = false) const;
178 
179  //=========================================================================================================
183  virtual void init();
184 
185  //=========================================================================================================
189  virtual void unload();
190 
191  void showProjectDialog();
192 
193  void showSqdCtrlDialog();
194 
195  //=========================================================================================================
199  void splitRecordingFile();
200 
201  //=========================================================================================================
205  void toggleRecordingFile();
206 
207 
208  virtual bool start();
209  virtual bool stop();
210 
211  virtual IPlugin::PluginType getType() const;
212  virtual QString getName() const;
213 
214  virtual QWidget* setupWidget();
215 
216  void setFiffInfo(FIFFLIB::FiffInfo);
217  void setFiffData(QByteArray DATA);
218  void setCMDData(QByteArray DATA);
219  void setFiffGainInfo(QStringList);
220 
221 
222  //=========================================================================================================
228  void comFLL(QString t_sFLLControlCommand);
229 
230  //=========================================================================================================
235  void UpdateFiffInfo();
236 
237 
238 signals:
239  //=========================================================================================================
245  void cmdConnectionChanged(bool p_bStatus);
246 
247  //=========================================================================================================
251  void fiffInfoAvailable();
252 
253  //=========================================================================================================
257  void DataToSquidCtrlGUI(MatrixXf tmp);
258  //=========================================================================================================
262  void SendCMDDataToSQUIDControl(QByteArray DATA);
263 
264 
265 protected:
266  virtual void run();
267 
268 private:
269  MatrixXd calibrate(const MatrixXf& data);
270 
271  bool readProjectors();
272 
273  bool readBadChannels();
274 
275  void changeRecordingButton();
276 
277  QSharedPointer<QTimer> m_pTimerRecordingChange;
278  qint16 m_iBlinkStatus;
279 
280  //=========================================================================================================
284  void initConnector();
285 
286  PluginOutputData<NewRealTimeMultiSampleArray>::SPtr m_pRTMSABabyMEG;
288  QMutex mutex;
289 
290  QSharedPointer<BabyMEGClient> myClient;
291  QSharedPointer<BabyMEGClient> myClientComm;
292  QSharedPointer<BabyMEGInfo> pInfo;
293  bool DataStartFlag;
294 
295  QSharedPointer<BabyMEGSQUIDControlDgl> SQUIDCtrlDlg; // added by Dr. Limin Sun for nonmodal dialog
296 
297  FiffInfo::SPtr m_pFiffInfo;
298  qint32 m_iBufferSize;
300  bool m_bWriteToFile;
302  QString m_sBabyMEGDataPath;
303  QString m_sCurrentProject;
304  QString m_sCurrentSubject;
305  QString m_sCurrentParadigm;
306  QString m_sRecordFile;
307  qint32 m_iSplitCount;
308  QFile m_qFileOut;
309  FiffStream::SPtr m_pOutfid;
311  QString m_sFiffHeader;
312  QString m_sBadChannels;
313  RowVectorXd m_cals;
314  SparseMatrix<double> m_sparseMatCals;
315 
316  bool m_bIsRunning;
317 
318  QSharedPointer<RawMatrixBuffer> m_pRawMatrixBuffer;
320  QAction* m_pActionSetupProject;
321  QAction* m_pActionRecordFile;
322  QAction* m_pActionSqdCtrl;
323  QAction* m_pActionUpdateFiffInfo;
325 public:
326  double sfreq;
327 };
328 
329 } // NAMESPACE
330 
331 #endif // BABYMEG_H
FIFF measurement file information.
Definition: fiff_info.h:96
The BabyMEGClient class provides a TCP/IP communication between Qt and Labview.
Definition: babymeginfo.h:70
CircularMatrixBuffer class declaration.
The IPlugin class is the base interface class of all plugins.
Definition: IPlugin.h:92
The ISensor class provides an interface for a sensor plugin.
Definition: ISensor.h:63
FiffInfo class declaration.
Contains the declaration of the CircularBuffer_old class.
Definition: arrow.h:75
The BabyMEGClient class provides a TCP/IP communication between Qt and Labview.
Definition: babymegclient.h:70
PluginOutputConnector with specified Measurement.
Definition: fiff.h:98
Contains the declaration of the NewRealTimeMultiSampleArray class.
Contains the declaration of the BabyMEGSQUIDControlDGL class.
declaration of the RtCmdClient Class.
FIFF class declaration, which provides static wrapper functions to stay consistent with mne matlab to...
FIFF File I/O routines.
Definition: fiff_stream.h:129
Contains declaration of IIinverseAlgorithm interface class.
The RealTimeMultiSampleArrayNew class is the base class of every RealTimeMultiSampleArrayNew Measurem...