MNE-CPP  0.1.9
A Framework for Electrophysiology
dipolefitview.cpp
Go to the documentation of this file.
1 //=============================================================================================================
35 //=============================================================================================================
36 // INCLUDES
37 //=============================================================================================================
38 
39 #include "dipolefitview.h"
40 #include "ui_dipolefitview.h"
41 
42 //=============================================================================================================
43 // QT INCLUDES
44 //=============================================================================================================
45 
46 #include <QDateTime>
47 #include <QtDebug>
48 
49 //=============================================================================================================
50 // USED NAMESPACES
51 //=============================================================================================================
52 
53 using namespace DISPLIB;
54 
55 //=============================================================================================================
56 // DEFINE MEMBER METHODS
57 //=============================================================================================================
58 
59 DipoleFitView::DipoleFitView(QWidget *parent,
60  Qt::WindowFlags)
61 : AbstractView(parent)
62 , m_pUi(new Ui::DipoleFitViewWidget)
63 {
64  m_pUi->setupUi(this);
65  this->setMinimumWidth(330);
66 
67  initGui();
68 }
69 
70 //=============================================================================================================
71 
73 {
74 
75 }
76 
77 //=============================================================================================================
78 
80 {
81 
82 }
83 
84 //=============================================================================================================
85 
86 void DipoleFitView::updateGuiMode(GuiMode mode)
87 {
88  switch(mode) {
89  case GuiMode::Clinical:
90  break;
91  default: // default is research mode
92  break;
93  }
94 }
95 
96 //=============================================================================================================
97 
98 void DipoleFitView::updateProcessingMode(ProcessingMode mode)
99 {
100  switch(mode) {
101  case ProcessingMode::Offline:
102  break;
103  default: // default is realtime mode
104  break;
105  }
106 }
107 
108 //=============================================================================================================
109 
110 void DipoleFitView::addBem(const QString &sFileName)
111 {
112  m_pUi->comboBox_bem->addItem(sFileName);
113 }
114 
115 //=============================================================================================================
116 
117 void DipoleFitView::addMri(const QString &sFileName)
118 {
119  m_pUi->comboBox_mri->addItem(sFileName);
120 }
121 
122 //=============================================================================================================
123 
124 void DipoleFitView::addNoise(const QString &sFileName)
125 {
126  m_pUi->comboBox_noise->addItem(sFileName);
127 }
128 
129 //=============================================================================================================
130 
132 {
133  emit timeChanged(m_pUi->spinBox_tmin->value(),
134  m_pUi->spinBox_tmax->value(),
135  m_pUi->spinBox_tstep->value(),
136  m_pUi->spinBox_tint->value());
137 
138  emit modalityChanged(m_pUi->checkBox_EEG->isChecked(), m_pUi->checkBox_MEG->isChecked());
139 
140  emit fittingChanged(m_pUi->doubleSpinBox_dist->value(),
141  m_pUi->doubleSpinBox_grid->value());
142 
143  emit baselineChanged(m_pUi->spinBox_bmax->value(),
144  m_pUi->spinBox_bmax->value());
145 
146  emit noiseChanged(m_pUi->doubleSpinBox_gradnoise->value(),
147  m_pUi->doubleSpinBox_magnoise->value(),
148  m_pUi->doubleSpinBox_eegnoise->value());
149 
150  emit regChanged(m_pUi->doubleSpinBox_gradreg->value(),
151  m_pUi->doubleSpinBox_magreg->value(),
152  m_pUi->doubleSpinBox_eegreg->value());
153 
154  emit sphereChanged(m_pUi->doubleSpinBox_orgx->value(),
155  m_pUi->doubleSpinBox_orgy->value(),
156  m_pUi->doubleSpinBox_orgz->value(),
157  m_pUi->doubleSpinBox_rad->value());
158 }
159 
160 //=============================================================================================================
161 
162 void DipoleFitView::initGui()
163 {
164  //Init Combo boxes
165  m_pUi->comboBox_bem->addItem("None");
166  m_pUi->comboBox_noise->addItem("None");
167  m_pUi->comboBox_mri->addItem("None");
168  m_pUi->comboBox_meas->addItem("None");
169 
170  //Perform Fit
171  connect(m_pUi->pushButton_fit, &QPushButton::clicked, [=] {
172  emit performDipoleFit(m_pUi->lineEdit_name->text());
173  });
174 
175  connect(m_pUi->spinBox_set, QOverload<int>::of(&QSpinBox::valueChanged),
176  this, &DipoleFitView::setChanged, Qt::UniqueConnection);
177 
178  //Time settings
179  connect(m_pUi->spinBox_tmin, QOverload<int>::of(&QSpinBox::valueChanged), [=](int iValue){
180  emit timeChanged(iValue,
181  m_pUi->spinBox_tmax->value(),
182  m_pUi->spinBox_tstep->value(),
183  m_pUi->spinBox_tint->value());
184  });
185  connect(m_pUi->spinBox_tmax, QOverload<int>::of(&QSpinBox::valueChanged), [=](int iValue){
186  emit timeChanged(m_pUi->spinBox_tmin->value(),
187  iValue,
188  m_pUi->spinBox_tstep->value(),
189  m_pUi->spinBox_tint->value());
190  });
191  connect(m_pUi->spinBox_tstep, QOverload<int>::of(&QSpinBox::valueChanged), [=](int iValue){
192  emit timeChanged(m_pUi->spinBox_tmin->value(),
193  m_pUi->spinBox_tmax->value(),
194  iValue,
195  m_pUi->spinBox_tint->value());
196  });
197  connect(m_pUi->spinBox_tint, QOverload<int>::of(&QSpinBox::valueChanged), [=](int iValue){
198  emit timeChanged(m_pUi->spinBox_tmin->value(),
199  m_pUi->spinBox_tmax->value(),
200  m_pUi->spinBox_tstep->value(),
201  iValue);
202  });
203 
204  //Baseline
205  connect(m_pUi->spinBox_bmin, QOverload<int>::of(&QSpinBox::valueChanged), [=](int iValue){
206  if (iValue != m_pUi->spinBox_bmax->value()){
207  emit baselineChanged(iValue,
208  m_pUi->spinBox_bmax->value());
209  } else {
210  emit baselineChanged(1e6, 1e6);
211  }
212  });
213  connect(m_pUi->spinBox_bmax, QOverload<int>::of(&QSpinBox::valueChanged), [=](int iValue){
214  if (iValue != m_pUi->spinBox_bmin->value()){
215  emit baselineChanged(m_pUi->spinBox_bmin->value(),
216  iValue);
217  } else {
218  emit baselineChanged(1e6, 1e6);
219  }
220  });
221 
222  //Modality
223  connect(m_pUi->checkBox_EEG, &QCheckBox::toggled, [=](bool bChecked){
224  emit modalityChanged(bChecked, m_pUi->checkBox_MEG->isChecked());
225  });
226  connect(m_pUi->checkBox_MEG, &QCheckBox::toggled, [=](bool bChecked){
227  emit modalityChanged(m_pUi->checkBox_EEG->isChecked(), bChecked);
228  });
229 
230  //Fittings
231  connect(m_pUi->doubleSpinBox_dist, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
232  emit fittingChanged(dValue,
233  m_pUi->doubleSpinBox_grid->value());
234  });
235  connect(m_pUi->doubleSpinBox_grid, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
236  emit fittingChanged(m_pUi->doubleSpinBox_dist->value(),
237  dValue);
238  });
239 
240  //Noise
241  connect(m_pUi->doubleSpinBox_gradnoise, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
242  emit noiseChanged(dValue,
243  m_pUi->doubleSpinBox_magnoise->value(),
244  m_pUi->doubleSpinBox_eegnoise->value());
245  });
246  connect(m_pUi->doubleSpinBox_magnoise, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
247  emit noiseChanged(m_pUi->doubleSpinBox_gradnoise->value(),
248  dValue,
249  m_pUi->doubleSpinBox_eegnoise->value());
250  });
251  connect(m_pUi->doubleSpinBox_eegnoise, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
252  emit noiseChanged(m_pUi->doubleSpinBox_gradnoise->value(),
253  m_pUi->doubleSpinBox_magnoise->value(),
254  dValue);
255  });
256 
257  //Reg
258  connect(m_pUi->doubleSpinBox_gradreg, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
259  emit regChanged(dValue,
260  m_pUi->doubleSpinBox_magreg->value(),
261  m_pUi->doubleSpinBox_eegreg->value());
262  });
263  connect(m_pUi->doubleSpinBox_magreg, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
264  emit regChanged(m_pUi->doubleSpinBox_gradreg->value(),
265  dValue,
266  m_pUi->doubleSpinBox_eegreg->value());
267  });
268  connect(m_pUi->doubleSpinBox_eegreg, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
269  emit regChanged(m_pUi->doubleSpinBox_gradreg->value(),
270  m_pUi->doubleSpinBox_magreg->value(),
271  dValue);
272  });
273 
274  //Sphere model
275  connect(m_pUi->doubleSpinBox_orgx, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
276  emit sphereChanged(dValue,
277  m_pUi->doubleSpinBox_orgy->value(),
278  m_pUi->doubleSpinBox_orgz->value(),
279  m_pUi->doubleSpinBox_rad->value());
280  });
281  connect(m_pUi->doubleSpinBox_orgy, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
282  emit sphereChanged(m_pUi->doubleSpinBox_orgx->value(),
283  dValue,
284  m_pUi->doubleSpinBox_orgz->value(),
285  m_pUi->doubleSpinBox_rad->value());
286  });
287  connect(m_pUi->doubleSpinBox_orgz, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
288  emit sphereChanged(m_pUi->doubleSpinBox_orgx->value(),
289  m_pUi->doubleSpinBox_orgy->value(),
290  dValue,
291  m_pUi->doubleSpinBox_rad->value());
292  });
293  connect(m_pUi->doubleSpinBox_rad, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [=](double dValue){
294  emit sphereChanged(m_pUi->doubleSpinBox_orgx->value(),
295  m_pUi->doubleSpinBox_orgy->value(),
296  m_pUi->doubleSpinBox_orgz->value(),
297  dValue);
298  });
299 
300  //Models
301  connect(m_pUi->comboBox_bem, &QComboBox::currentTextChanged,
302  this, &DipoleFitView::selectedBem, Qt::UniqueConnection);
303  connect(m_pUi->comboBox_noise, &QComboBox::currentTextChanged,
304  this, &DipoleFitView::selectedNoise, Qt::UniqueConnection);
305  connect(m_pUi->comboBox_mri, &QComboBox::currentTextChanged,
306  this, &DipoleFitView::selectedMri, Qt::UniqueConnection);
307  connect(m_pUi->comboBox_meas, &QComboBox::currentTextChanged, [=](const QString& sFileName){
308 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
309  auto skip = QString::SkipEmptyParts;
310 #else
311  auto skip = Qt::SkipEmptyParts;
312 #endif
313  QString sName = sFileName.split(".",skip).at(0);
314  if(sName.endsWith("-ave") || sName.endsWith("_ave") || sName.endsWith("-raw") || sName.endsWith("_raw")){
315  sName.chop(4);
316  }
317  m_pUi->lineEdit_name->setText("Dipole Fit - " + sName + " - " + QDateTime::currentDateTime().toString("MMMM d yyyy hh:mm:ss"));
318  emit selectedMeas(sFileName);
319  });
320 
321 }
322 
323 //=============================================================================================================
324 
325 void DipoleFitView::addMeas(const QString &sFileName)
326 {
327  m_pUi->comboBox_meas->addItem(sFileName);
328 
329 // QString sName = sFileName.split(".",QString::SkipEmptyParts).at(0);
330 // if(sName.endsWith("-ave") || sName.endsWith("_ave") || sName.endsWith("-raw") || sName.endsWith("_raw")){
331 // sName.chop(4);
332 // }
333 
334 // m_pUi->lineEdit_name->setText("Dipole Fit - " + sName + " - " + QDateTime::currentDateTime().toString("MMMM d yyyy hh:mm:ss"));
335 }
336 
337 //=============================================================================================================
338 
340 {
341  m_pUi->comboBox_meas->clear();
342  m_pUi->comboBox_bem->clear();
343  m_pUi->comboBox_mri->clear();
344  m_pUi->comboBox_noise->clear();
345 }
346 
347 //=============================================================================================================
348 
349 void DipoleFitView::removeModel(const QString &sModelName, int iType)
350 {
351  switch (iType){
352  case 1: {
353  int iIndex = m_pUi->comboBox_meas->findText(sModelName);
354  if(iIndex != -1){
355  m_pUi->comboBox_meas->removeItem(iIndex);
356  }
357  break;
358  }
359  case 2: {
360  int iIndex = m_pUi->comboBox_bem->findText(sModelName);
361  if(iIndex != -1){
362  m_pUi->comboBox_bem->removeItem(iIndex);
363  }
364  break;
365  }
366  case 3: {
367  int iIndex = m_pUi->comboBox_mri->findText(sModelName);
368  if(iIndex != -1){
369  m_pUi->comboBox_mri->removeItem(iIndex);
370  }
371  break;
372  }
373  case 4: {
374  int iIndex = m_pUi->comboBox_noise->findText(sModelName);
375  if(iIndex != -1){
376  m_pUi->comboBox_noise->removeItem(iIndex);
377  }
378  break;
379  }
380  default:{
381  qWarning() << "[DipoleFitView::removeModel] Model type not recognized";
382  break;
383  }
384  }
385 }
DISPLIB::DipoleFitView::removeModel
void removeModel(const QString &sModelName, int iType)
Definition: dipolefitview.cpp:349
DISPLIB::AbstractView
The AbstractView class provides the base calss for all Disp viewers.
Definition: abstractview.h:75
DISPLIB::DipoleFitView::regChanged
void regChanged(double dRegGrad, double dRegMag, double dRegEeg)
DISPLIB::DipoleFitView::fittingChanged
void fittingChanged(int iMinDistance, int iSize)
DISPLIB::DipoleFitView::noiseChanged
void noiseChanged(double dGrad, double dMag, double dEeg)
DISPLIB::DipoleFitView::setChanged
void setChanged(int iSet)
DISPLIB::DipoleFitView::addBem
void addBem(const QString &sFileName)
Definition: dipolefitview.cpp:110
DISPLIB::DipoleFitView::loadSettings
void loadSettings()
Definition: dipolefitview.cpp:79
DISPLIB::DipoleFitView::addMri
void addMri(const QString &sFileName)
Definition: dipolefitview.cpp:117
DISPLIB::DipoleFitView::updateGuiMode
void updateGuiMode(GuiMode mode)
Definition: dipolefitview.cpp:86
DISPLIB::DipoleFitView::timeChanged
void timeChanged(int iMin, int iMax, int iStep, int iInt)
DISPLIB::DipoleFitView::sphereChanged
void sphereChanged(double dX, double dY, double dZ, double dRadius)
DISPLIB::DipoleFitView::baselineChanged
void baselineChanged(int iBMin, int iBMax)
DISPLIB::DipoleFitView::modalityChanged
void modalityChanged(bool bEEG, bool bMEG)
dipolefitview.h
Declaration of the DipoleFitView Class.
DISPLIB::DipoleFitView::updateProcessingMode
void updateProcessingMode(ProcessingMode mode)
Definition: dipolefitview.cpp:98
DISPLIB::DipoleFitView::saveSettings
void saveSettings()
Definition: dipolefitview.cpp:72
DISPLIB::DipoleFitView::requestParams
void requestParams()
Definition: dipolefitview.cpp:131
DISPLIB::DipoleFitView::addNoise
void addNoise(const QString &sFileName)
Definition: dipolefitview.cpp:124
DISPLIB::DipoleFitView::clearView
void clearView()
Definition: dipolefitview.cpp:339