MNE-CPP  beta 0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
brainmonitor.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "brainmonitor.h"
42 
44 
45 #include <xMeas/Measurement/realtimesamplearray.h>
46 
49 
50 #include <fs/label.h>
51 #include <fs/surface.h>
52 #include <fs/annotationset.h>
53 
54 #include <fiff/fiff_evoked.h>
55 #include <inverse/sourceestimate.h>
57 
58 #include <disp3D/inverseview.h>
59 
60 
61 //*************************************************************************************************************
62 //=============================================================================================================
63 // QT INCLUDES
64 //=============================================================================================================
65 
66 #include <QtCore/QtPlugin>
67 #include <QDebug>
68 
69 
70 //*************************************************************************************************************
71 //=============================================================================================================
72 // USED NAMESPACES
73 //=============================================================================================================
74 
75 using namespace BrainMonitorPlugin;
76 using namespace MNEX;
77 using namespace XMEASLIB;
78 
79 using namespace MNELIB;
80 using namespace FSLIB;
81 using namespace FIFFLIB;
82 using namespace INVERSELIB;
83 using namespace DISP3DLIB;
84 
85 
86 //*************************************************************************************************************
87 //=============================================================================================================
88 // DEFINE MEMBER METHODS
89 //=============================================================================================================
90 
91 BrainMonitor::BrainMonitor()
92 {
93 
94  // This needs Qt 5.1
95 
96 // //########################################################################################
97 // // Source Estimate
98 
99 // QFile t_fileFwd("./MNE-sample-data/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif");
100 // QFile t_fileCov("./MNE-sample-data/MEG/sample/sample_audvis-cov.fif");
101 // QFile t_fileEvoked("./MNE-sample-data/MEG/sample/sample_audvis-ave.fif");
102 
103 // QFile t_fileClusteredInverse("./clusteredInverse-inv.fif");
104 
105 // double snr = 3.0;
106 // double lambda2 = 1.0 / pow(snr, 2);
107 // QString method("dSPM"); //"MNE" | "dSPM" | "sLORETA"
108 
109 // // Load data
110 // fiff_int_t setno = 0;
111 // QPair<QVariant, QVariant> baseline(QVariant(), 0);
112 // FiffEvoked evoked(t_fileEvoked, setno, baseline);
113 // if(evoked.isEmpty())
114 // return;
115 
116 // MNEForwardSolution t_Fwd(t_fileFwd);
117 // if(t_Fwd.isEmpty())
118 // return;
119 
120 // AnnotationSet t_annotationSet("./MNE-sample-data/subjects/sample/label/lh.aparc.a2009s.annot", "./MNE-sample-data/subjects/sample/label/rh.aparc.a2009s.annot");
121 
122 // FiffCov noise_cov(t_fileCov);
123 
124 // // regularize noise covariance
125 // noise_cov = noise_cov.regularize(evoked.info, 0.05, 0.05, 0.1, true);
126 
127 // //
128 // // Cluster forward solution;
129 // //
130 // MNEForwardSolution t_clusteredFwd = t_Fwd.cluster_forward_solution(t_annotationSet, 40);
131 
132 // //
133 // // make an inverse operators
134 // //
135 // FiffInfo info = evoked.info;
136 
137 // MNEInverseOperator inverse_operator(info, t_clusteredFwd, noise_cov, 0.2f, 0.8f);
138 
139 // inverse_operator.write_inverse_operator(t_fileClusteredInverse);
140 
141 // //
142 // // Compute inverse solution
143 // //
144 // MinimumNorm minimumNorm(inverse_operator, lambda2, method);
145 // SourceEstimate sourceEstimate = minimumNorm.calculateInverse(evoked);
146 
147 // if(sourceEstimate.isEmpty())
148 // return;
149 
150 // // View activation time-series
151 // std::cout << "\nsourceEstimate:\n" << sourceEstimate.data.block(0,0,10,10) << std::endl;
152 // std::cout << "time\n" << sourceEstimate.times.block(0,0,1,10) << std::endl;
153 // std::cout << "timeMin\n" << sourceEstimate.times[0] << std::endl;
154 // std::cout << "timeMax\n" << sourceEstimate.times[sourceEstimate.times.size()-1] << std::endl;
155 // std::cout << "time step\n" << sourceEstimate.tstep << std::endl;
156 
157 // //Source Estimate end
158 // //########################################################################################
159 
160 // AnnotationSet t_annotSet("./MNE-sample-data/subjects/sample/label/lh.aparc.a2009s.annot","./MNE-sample-data/subjects/sample/label/rh.aparc.a2009s.annot");
161 // SurfaceSet t_surfSet("./MNE-sample-data/subjects/sample/surf/lh.white", "./MNE-sample-data/subjects/sample/surf/rh.white");
162 
163 // QList<Label> t_qListLabels;
164 // QList<RowVector4i> t_qListRGBAs;
165 
166 // //ToDo overload toLabels using instead of t_surfSet rr of MNESourceSpace
167 // t_annotSet.toLabels(t_surfSet, t_qListLabels, t_qListRGBAs);
168 
169 // InverseView view(minimumNorm.getSourceSpace(), t_qListLabels, t_qListRGBAs);
170 
171 // if (view.stereoType() != QGLView::RedCyanAnaglyph)
172 // view.camera()->setEyeSeparation(0.3f);
173 // QStringList args = QCoreApplication::arguments();
174 // int w_pos = args.indexOf("-width");
175 // int h_pos = args.indexOf("-height");
176 // if (w_pos >= 0 && h_pos >= 0)
177 // {
178 // bool ok = true;
179 // int w = args.at(w_pos + 1).toInt(&ok);
180 // if (!ok)
181 // {
182 // qWarning() << "Could not parse width argument:" << args;
183 // return;
184 // }
185 // int h = args.at(h_pos + 1).toInt(&ok);
186 // if (!ok)
187 // {
188 // qWarning() << "Could not parse height argument:" << args;
189 // return;
190 // }
191 // view.resize(w, h);
192 // }
193 // else
194 // {
195 // view.resize(800, 600);
196 // }
197 // view.show();
198 
199 
200 }
201 
202 
203 //*************************************************************************************************************
204 
205 BrainMonitor::~BrainMonitor()
206 {
207  stop();
208 
209 }
210 
211 
212 //*************************************************************************************************************
213 
214 bool BrainMonitor::start()
215 {
216  // Initialize displaying widgets
217  init();
218 
219  QThread::start();
220  return true;
221 }
222 
223 
224 //*************************************************************************************************************
225 
226 bool BrainMonitor::stop()
227 {
228  // Stop threads
229  QThread::terminate();
230  QThread::wait();
231 
232 
233  return true;
234 }
235 
236 
237 //*************************************************************************************************************
238 
239 Type BrainMonitor::getType() const
240 {
241  return _IRTVisualization;
242 }
243 
244 
245 //*************************************************************************************************************
246 
247 const char* BrainMonitor::getName() const
248 {
249  return "Brain Monitor";
250 }
251 
252 
253 //*************************************************************************************************************
254 
255 QWidget* BrainMonitor::setupWidget()
256 {
257  BrainMonitorSetupWidget* setupWidget = new BrainMonitorSetupWidget(this);//widget is later distroyed by CentralWidget - so it has to be created everytime new
258  return setupWidget;
259 }
260 
261 
262 //*************************************************************************************************************
263 
264 QWidget* BrainMonitor::runWidget()
265 {
266  BrainMonitorRunWidget* runWidget = new BrainMonitorRunWidget(this);//widget is later distroyed by CentralWidget - so it has to be created everytime new
267  return runWidget;
268 }
269 
270 
271 //*************************************************************************************************************
272 
273 void BrainMonitor::update(Subject* pSubject)
274 {
275 
276 }
277 
278 
279 //*************************************************************************************************************
280 
281 void BrainMonitor::run()
282 {
283  while (true)
284  {
285 // double v_one = m_pDummyMultiChannelBuffer->pop(0);
286 
287 // double v_two = m_pDummyMultiChannelBuffer->pop(1);
288 
289  }
290 }
291 
292 
293 //*************************************************************************************************************
294 //=============================================================================================================
295 // Creating required display instances and set configurations
296 //=============================================================================================================
297 
298 void BrainMonitor::init()
299 {
300 
301 }
Contains the declaration of the BrainMonitorSetupWidget class.
Contains the declaration of the BrainMonitor class.
The BrainMonitorRunWidget class provides the DummyToolbox configuration window for the run mode...
Minimum norm class declaration.
The Subject class provides the base class of every subject of the observer design pattern...
Surface class declaration.
AnnotationSet class declaration.
Contains the declaration of the BrainMonitorRunWidget class.
InverseView class declaration.
Label class declaration.
The BrainMonitorSetupWidget class provides the DummyToolbox configuration window. ...
Contains the declaration of the SngChnMeasurement base class.