MNE-CPP  beta 1.0
bci.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef BCI_H
38 #define BCI_H
39 
40 
41 //*************************************************************************************************************
42 //=============================================================================================================
43 // INCLUDES
44 //=============================================================================================================
45 #include "bci_global.h"
46 
48 
50 
54 
55 #include <utils/filterdata.h>
56 
57 #include <fstream>
58 
59 //*************************************************************************************************************
60 //=============================================================================================================
61 // QT STL INCLUDES
62 //=============================================================================================================
63 
64 #include <QtWidgets>
65 #include <QtConcurrent/QtConcurrent>
66 
69 
70 //*************************************************************************************************************
71 //=============================================================================================================
72 // DEFINE NAMESPACE TMSIPlugin
73 //=============================================================================================================
74 
75 namespace BCIPlugin
76 {
77 
78 //*************************************************************************************************************
79 //=============================================================================================================
80 // TypeDefs
81 //=============================================================================================================
82 
83 typedef QList< QList<double> > MyQList;
84 
85 //*************************************************************************************************************
86 //=============================================================================================================
87 // USED NAMESPACES
88 //=============================================================================================================
89 
90 using namespace MNEX;
91 using namespace XMEASLIB;
92 using namespace IOBuffer;
93 using namespace UTILSLIB;
94 using namespace std;
95 
96 
97 //=============================================================================================================
104 {
105  Q_OBJECT
106  Q_PLUGIN_METADATA(IID "mne_x/1.0" FILE "bci.json") //NEw Qt5 Plugin system replaces Q_EXPORT_PLUGIN2 macro
107  // Use the Q_INTERFACES() macro to tell Qt's meta-object system about the interfaces
108  Q_INTERFACES(MNEX::IAlgorithm)
109 
110  friend class BCISetupWidget;
111  friend class BCIFeatureWindow;
112 
113 public:
114  //=========================================================================================================
118  BCI();
119 
120  //=========================================================================================================
124  virtual ~BCI();
125 
126  //=========================================================================================================
130  virtual QSharedPointer<IPlugin> clone() const;
131 
132  //=========================================================================================================
136  virtual void init();
137 
138  //=========================================================================================================
142  virtual void unload();
143 
144  //=========================================================================================================
148  virtual bool start();
149 
150  //=========================================================================================================
154  virtual bool stop();
155 
156  virtual IPlugin::PluginType getType() const;
157  virtual QString getName() const;
158 
159  virtual QWidget* setupWidget();
160 
161 protected:
167  void updateSensor(XMEASLIB::NewMeasurement::SPtr pMeasurement);
168 
169  //=========================================================================================================
175  void updateSource(XMEASLIB::NewMeasurement::SPtr pMeasurement);
176 
177  //=========================================================================================================
183  void applyMeanCorrectionConcurrently(QPair<int,RowVectorXd>& rowdata);
184 
185  //=========================================================================================================
191  void applyFilterOperatorConcurrently(QPair<int,RowVectorXd> &chdata);
192 
193  //=========================================================================================================
200  QPair< int,QList<double> > applyFeatureCalcConcurrentlyOnSensorLevel(const QPair<int,RowVectorXd> &chdata);
201 
202  //=========================================================================================================
209  double applyClassificationCalcConcurrentlyOnSensorLevel(QList<double> &featData);
210 
211  //=========================================================================================================
218  double classificationBoundaryValue(const QList<double> &featData);
219 
220  //=========================================================================================================
225  void clearFeatures();
226 
227  //=========================================================================================================
232  void clearClassifications();
233 
234  //=========================================================================================================
239  bool hasThresholdArtefact(const QList<QPair<int, RowVectorXd> > &data);
240 
241  //=========================================================================================================
246  bool lookForTrigger(const MatrixXd &data);
247 
248  //=========================================================================================================
254  virtual void run();
255 
256  //=========================================================================================================
261  void BCIOnSensorLevel();
262 
263  //=========================================================================================================
268  void BCIOnSourceLevel();
269 
270 signals:
271  void paintFeatures(MyQList features, bool bTrigerActivated);
272 
273 private:
283  CircularMatrixBuffer<double>::SPtr m_pBCIBuffer_Sensor;
284  CircularMatrixBuffer<double>::SPtr m_pBCIBuffer_Source;
286  QSharedPointer<FilterData> m_filterOperator;
288  QSharedPointer<BCIFeatureWindow> m_BCIFeatureWindow;
290  ofstream m_outStreamDebug;
292  bool m_bIsRunning;
293  QString m_qStringResourcePath;
294  bool m_bProcessData;
295  bool m_bTriggerActivated;
296  QMutex m_qMutex;
298  // Sensor level
299  FiffInfo::SPtr m_pFiffInfo_Sensor;
300  bool m_bFiffInfoInitialised_Sensor;
301  bool m_bFillSensorWindowFirstTime;
302  MatrixXd m_matSlidingWindowSensor;
303  MatrixXd m_matTimeBetweenWindowsSensor;
304  int m_iTBWIndexSensor;
305  int m_iNumberOfCalculatedFeatures;
306  QVector< VectorXd > m_vLoadedSensorBoundary;
307  QStringList m_slChosenFeatureSensor;
308  QMap<QString, int> m_mapElectrodePinningScheme;
309  QList< QPair< int,QList<double> > > m_lFeaturesSensor;
310  QList<double> m_lClassResultsSensor;
311  MatrixXd m_matStimChannelSensor;
312  MatrixXd m_matTimeBetweenWindowsStimSensor;
314  // Source level
315  QVector< VectorXd > m_vLoadedSourceBoundary;
316  QStringList m_slChosenFeatureSource;
317  QMap<QString, int> m_mapDestrieuxAtlasRegions;
319  // GUI stuff
320  bool m_bSubtractMean;
321  bool m_bUseFilter;
322  bool m_bUseSensorData;
323  bool m_bUseSourceData;
324  bool m_bDisplayFeatures;
325  bool m_bUseArtefactThresholdReduction;
326  double m_dSlidingWindowSize;
327  double m_dTimeBetweenWindows;
328  double m_dFilterLowerBound;
329  double m_dFilterUpperBound;
330  double m_dParcksWidth;
331  double m_dThresholdValue;
332  double m_dDisplayRangeBoundary;
333  double m_dDisplayRangeVariances;
334  double m_dDisplayRangeElectrodes;
335  int m_iFilterOrder;
336  int m_iNumberFeatures;
337  int m_iNumberFeaturesToDisplay;
338  int m_iFeatureCalculationType;
339 };
340 
341 } // NAMESPACE
342 
343 #endif // BCI_H
Contains the declaration of the RealTimeSourceEstimate class.
Contains declaration of IAlgorithm interface class.
CircularMatrixBuffer class declaration.
The BCIFeatureWindow class provides a visualization tool for calculated features. ...
The TMSISetupWidget class provides the TMSI configuration window.
QSharedPointer< PluginOutputData< T > > SPtr
The circular matrix buffer.
QSharedPointer< FiffInfo > SPtr
Definition: fiff_info.h:99
The FilterData class represents a derived class from an arbitrary MNEOperator class object...
Definition: bci.h:75
The IAlgorithm class provides an interface for a real-time algorithm plugin.
Definition: IAlgorithm.h:70
Contains the declaration of the NewRealTimeSampleArray class.
QSharedPointer< PluginInputData > SPtr
Definition: arrow.h:75
QSharedPointer< NewMeasurement > SPtr
Contains the declaration of the NewRealTimeMultiSampleArray class.
#define BCISHARED_EXPORT
Definition: bci_global.h:57
Contains the BCI library export/import macros.
The BCI class provides an EEG BCI.
Definition: bci.h:103
Contains the declaration of the BCISetupWidget class.
Contains the declaration of the BCIAboutWidget class.