62 using namespace Eigen;
77 connect(ui.m_checkBox_UseSourceData, static_cast<void (QCheckBox::*)(
bool)>(&QCheckBox::clicked),
78 this, &BCISetupWidget::setGeneralOptions);
79 connect(ui.m_checkBox_UseSensorData, static_cast<void (QCheckBox::*)(
bool)>(&QCheckBox::clicked),
80 this, &BCISetupWidget::setGeneralOptions);
81 connect(ui.m_checkBox_DisplayFeatures, static_cast<void (QCheckBox::*)(
bool)>(&QCheckBox::clicked),
82 this, &BCISetupWidget::setGeneralOptions);
83 connect(ui.m_SpinBox_NumberFeaturesToDisplay, static_cast<void (QSpinBox::*)()>(&QSpinBox::editingFinished),
84 this, &BCISetupWidget::setGeneralOptions);
85 connect(ui.m_doubleSpinBox_Boundary, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
86 this, &BCISetupWidget::setGeneralOptions);
87 connect(ui.m_doubleSpinBox_Variances, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
88 this, &BCISetupWidget::setGeneralOptions);
89 connect(ui.m_doubleSpinBox_Electrodes, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
90 this, &BCISetupWidget::setGeneralOptions);
91 connect(ui.m_spinBox_exponentBoundary, static_cast<void (QSpinBox::*)()>(&QSpinBox::editingFinished),
92 this, &BCISetupWidget::setGeneralOptions);
93 connect(ui.m_spinBox_exponentVariances, static_cast<void (QSpinBox::*)()>(&QSpinBox::editingFinished),
94 this, &BCISetupWidget::setGeneralOptions);
95 connect(ui.m_spinBox_exponentElectrodes, static_cast<void (QSpinBox::*)()>(&QSpinBox::editingFinished),
96 this, &BCISetupWidget::setGeneralOptions);
99 connect(ui.m_checkBox_SubtractMean, static_cast<void (QCheckBox::*)(
bool)>(&QCheckBox::clicked),
100 this, &BCISetupWidget::setProcessingOptions);
101 connect(ui.m_doubleSpinBox_SlidingWindowSize, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
102 this, &BCISetupWidget::setProcessingOptions);
103 connect(ui.m_spinBox_NumberFeatures, static_cast<void (QSpinBox::*)()>(&QSpinBox::editingFinished),
104 this, &BCISetupWidget::setProcessingOptions);
105 connect(ui.m_doubleSpinBox_TimeBetweenWindows, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
106 this, &BCISetupWidget::setProcessingOptions);
107 connect(ui.m_checkBox_UseThresholdArtefactReduction, static_cast<void (QCheckBox::*)(
bool)>(&QCheckBox::clicked),
108 this, &BCISetupWidget::setProcessingOptions);
109 connect(ui.m_SpinBox_ThresholdValue, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
110 this, &BCISetupWidget::setProcessingOptions);
113 connect(ui.m_comboBox_featureCalculationType, static_cast<void (QComboBox::*)(
int)>(&QComboBox::currentIndexChanged),
114 this, &BCISetupWidget::setClassificationOptions);
116 connect(ui.m_pushButton_LoadSensorBoundary, &QPushButton::released,
117 this, &BCISetupWidget::changeLoadSensorBoundary);
118 connect(ui.m_pushButton_LoadSourceBoundary, &QPushButton::released,
119 this, &BCISetupWidget::changeLoadSourceBoundary);
122 ui.m_listWidget_ChosenFeaturesOnSensorLevel->installEventFilter(
this);
123 ui.m_listWidget_ChosenFeaturesOnSourceLevel->installEventFilter(
this);
124 ui.m_listWidget_AvailableFeaturesOnSensorLevel->installEventFilter(
this);
125 ui.m_listWidget_AvailableFeaturesOnSourceLevel->installEventFilter(
this);
128 connect(ui.m_checkBox_UseFilter, static_cast<void (QCheckBox::*)(
bool)>(&QCheckBox::clicked),
129 this, &BCISetupWidget::setFilterOptions);
130 connect(ui.m_doubleSpinBox_FilterLowerBound, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
131 this, &BCISetupWidget::setFilterOptions);
132 connect(ui.m_doubleSpinBox_FilterUpperBound, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
133 this, &BCISetupWidget::setFilterOptions);
134 connect(ui.m_SpinBox_FilterOrder, static_cast<void (QSpinBox::*)()>(&QSpinBox::editingFinished),
135 this, &BCISetupWidget::setFilterOptions);
136 connect(ui.m_doubleSpinBox_ParcksWidth, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
137 this, &BCISetupWidget::setFilterOptions);
140 connect(ui.m_qPushButton_About, &QPushButton::released,
this, &BCISetupWidget::showAboutDialog);
143 QFile file(m_pBCI->m_qStringResourcePath+
"readme.txt");
144 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
147 QTextStream in(&file);
150 QString line = in.readLine();
151 ui.m_qTextBrowser_Information->insertHtml(line);
152 ui.m_qTextBrowser_Information->insertHtml(
"<br>");
169 ui.m_checkBox_UseSensorData->setChecked(m_pBCI->m_bUseSensorData);
170 ui.m_checkBox_UseSourceData->setChecked(m_pBCI->m_bUseSourceData);
171 ui.m_checkBox_DisplayFeatures->setChecked(m_pBCI->m_bDisplayFeatures);
172 ui.m_SpinBox_NumberFeaturesToDisplay->setValue(m_pBCI->m_iNumberFeaturesToDisplay);
173 ui.m_doubleSpinBox_Boundary->setValue(m_pBCI->m_dDisplayRangeBoundary);
174 ui.m_doubleSpinBox_Variances->setValue(m_pBCI->m_dDisplayRangeVariances);
175 ui.m_doubleSpinBox_Electrodes->setValue(m_pBCI->m_dDisplayRangeElectrodes);
180 ui.m_checkBox_SubtractMean->setChecked(m_pBCI->m_bSubtractMean);
181 ui.m_doubleSpinBox_SlidingWindowSize->setValue(m_pBCI->m_dSlidingWindowSize);
182 ui.m_doubleSpinBox_TimeBetweenWindows->setValue(m_pBCI->m_dTimeBetweenWindows);
183 ui.m_spinBox_NumberFeatures->setValue(m_pBCI->m_iNumberFeatures);
184 ui.m_checkBox_UseThresholdArtefactReduction->setChecked(m_pBCI->m_bUseArtefactThresholdReduction);
185 ui.m_SpinBox_ThresholdValue->setValue(m_pBCI->m_dThresholdValue);
188 double totalProcessingTime = ui.m_doubleSpinBox_SlidingWindowSize->value() + (ui.m_doubleSpinBox_TimeBetweenWindows->value() * (ui.m_spinBox_NumberFeatures->value()-1));
189 ui.m_label_TotalProcessedTimeDisplay->setNum(totalProcessingTime);
190 ui.m_label_TotalProcessedTimeDisplay->setText(ui.m_label_TotalProcessedTimeDisplay->text().append(
" s"));
192 double timeForNextResult = ui.m_doubleSpinBox_TimeBetweenWindows->value() * ui.m_spinBox_NumberFeatures->value();
193 ui.m_label_TimeNeededForResultsDisplay->setNum(timeForNextResult);
194 ui.m_label_TimeNeededForResultsDisplay->setText(ui.m_label_TimeNeededForResultsDisplay->text().append(
" s"));
197 ui.m_comboBox_featureCalculationType->setCurrentIndex(m_pBCI->m_iFeatureCalculationType);
198 QString temp = m_pBCI->m_qStringResourcePath;
199 temp.append(QString(
"LDA_linear_boundary_Sensor.txt"));
200 ui.m_lineEdit_SensorBoundary->setText(temp);
201 ui.m_lineEdit_SourceBoundary->setText(temp);
202 m_pBCI->m_vLoadedSensorBoundary = readBoundaryInformation(temp);
203 m_pBCI->m_vLoadedSourceBoundary = readBoundaryInformation(temp);
206 ui.m_checkBox_UseFilter->setChecked(m_pBCI->m_bUseFilter);
207 ui.m_doubleSpinBox_FilterLowerBound->setValue(m_pBCI->m_dFilterLowerBound);
208 ui.m_doubleSpinBox_FilterUpperBound->setValue(m_pBCI->m_dFilterUpperBound);
209 ui.m_SpinBox_FilterOrder->setValue(m_pBCI->m_iFilterOrder);
210 ui.m_doubleSpinBox_ParcksWidth->setValue(m_pBCI->m_dParcksWidth);
213 initSelectedFeaturesSensor();
219 void BCISetupWidget::setGeneralOptions()
221 m_pBCI->m_bUseSensorData = ui.m_checkBox_UseSensorData->isChecked();
222 m_pBCI->m_bUseSourceData = ui.m_checkBox_UseSourceData->isChecked();
223 m_pBCI->m_bDisplayFeatures = ui.m_checkBox_DisplayFeatures->isChecked();
224 m_pBCI->m_iNumberFeaturesToDisplay = ui.m_SpinBox_NumberFeaturesToDisplay->value();
226 m_pBCI->m_dDisplayRangeBoundary = ui.m_doubleSpinBox_Boundary->value() * std::pow(10, ui.m_spinBox_exponentBoundary->value());
227 m_pBCI->m_dDisplayRangeVariances = ui.m_doubleSpinBox_Variances->value() * std::pow(10, ui.m_spinBox_exponentVariances->value());
228 m_pBCI->m_dDisplayRangeElectrodes = ui.m_doubleSpinBox_Electrodes->value() * std::pow(10, ui.m_spinBox_exponentElectrodes->value());
234 void BCISetupWidget::setProcessingOptions()
236 m_pBCI->m_bSubtractMean = ui.m_checkBox_SubtractMean->isChecked();
237 m_pBCI->m_dSlidingWindowSize = ui.m_doubleSpinBox_SlidingWindowSize->value();
238 m_pBCI->m_dTimeBetweenWindows = ui.m_doubleSpinBox_TimeBetweenWindows->value();
239 m_pBCI->m_iNumberFeatures = ui.m_spinBox_NumberFeatures->value();
240 m_pBCI->m_bUseArtefactThresholdReduction = ui.m_checkBox_UseThresholdArtefactReduction->isChecked();
241 m_pBCI->m_dThresholdValue = ui.m_SpinBox_ThresholdValue->value();
243 double totalProcessingTime = ui.m_doubleSpinBox_SlidingWindowSize->value() + (ui.m_doubleSpinBox_TimeBetweenWindows->value() * (ui.m_spinBox_NumberFeatures->value()-1));
244 ui.m_label_TotalProcessedTimeDisplay->setNum(totalProcessingTime);
245 ui.m_label_TotalProcessedTimeDisplay->setText(ui.m_label_TotalProcessedTimeDisplay->text().append(
" s"));
247 double timeForNextResult = ui.m_doubleSpinBox_TimeBetweenWindows->value() * ui.m_spinBox_NumberFeatures->value();
248 ui.m_label_TimeNeededForResultsDisplay->setNum(timeForNextResult);
249 ui.m_label_TimeNeededForResultsDisplay->setText(ui.m_label_TimeNeededForResultsDisplay->text().append(
" s"));
255 void BCISetupWidget::changeLoadSensorBoundary()
257 QString path = QFileDialog::getOpenFileName(
259 "Load decision boundary for sensor level",
260 "mne_x_plugins/resources/bci/LDA_linear_boundary.txt",
261 tr(
"Text files (*.txt)"));
264 path = ui.m_lineEdit_SensorBoundary->text();
266 m_pBCI->m_vLoadedSensorBoundary = readBoundaryInformation(path);
268 ui.m_lineEdit_SensorBoundary->setText(path);
274 void BCISetupWidget::changeLoadSourceBoundary()
276 QString path = QFileDialog::getOpenFileName(
278 "Load decision boundary for source level",
279 "mne_x_plugins/resources/bci/LDA_linear_boundary.txt",
280 tr(
"Text files (*.txt)"));
283 path = ui.m_lineEdit_SourceBoundary->text();
286 m_pBCI->m_vLoadedSourceBoundary = readBoundaryInformation(path);
288 ui.m_lineEdit_SourceBoundary->setText(path);
294 QVector<VectorXd> BCISetupWidget::readBoundaryInformation(QString path)
296 QVector<VectorXd> boundary_final;
300 if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
303 VectorXd const_temp(1);
305 VectorXd linear_temp(2);
306 linear_temp << 1.0, 1.0;
308 boundary_final.push_back(const_temp);
309 boundary_final.push_back(linear_temp);
311 return boundary_final;
316 VectorXd linear_temp;
318 QTextStream in(&file);
322 QString line = in.readLine();
324 if(line.contains(QString(
"const")))
326 QStringList list_temp = line.split(QRegExp(
"\\s+"));
328 const_temp.resize(list_temp.at(1).toInt());
330 for(
int i = 0; i<list_temp.at(1).toInt(); i++)
332 QString line_temp = in.readLine();
333 const_temp(i) = line_temp.toDouble();
337 if(line.contains(QString(
"linear")))
339 QStringList list_temp = line.split(QRegExp(
"\\s+"));
341 linear_temp.resize(list_temp.at(1).toInt());
343 for(
int i = 0; i<list_temp.at(1).toInt(); i++)
345 QString line_temp = in.readLine();
346 linear_temp(i) = line_temp.toDouble();
353 boundary_final.push_back(const_temp);
354 boundary_final.push_back(linear_temp);
356 return boundary_final;
362 void BCISetupWidget::initSelectedFeaturesSensor()
366 path.prepend(m_pBCI->m_qStringResourcePath);
367 path.append(
"Pinning_Scheme_Duke_128.txt");
369 if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
373 m_vAvailableFeaturesSensor.clear();
374 QMap<QString, int> mapElectrodePinningScheme;
376 QTextStream in(&file);
380 QString line = in.readLine();
382 QStringList list_temp = line.split(QRegExp(
"\\s+"));
384 if(list_temp.size() >= 2)
385 mapElectrodePinningScheme.insert(list_temp.at(1), list_temp.at(0).toInt()-1);
387 m_vAvailableFeaturesSensor.append(list_temp.at(1));
392 m_pBCI->m_mapElectrodePinningScheme = mapElectrodePinningScheme;
395 for(
int i=0; i<m_pBCI->m_slChosenFeatureSensor.size(); i++)
396 m_vAvailableFeaturesSensor.removeAt(m_vAvailableFeaturesSensor.indexOf(m_pBCI->m_slChosenFeatureSensor.at(i)));
398 ui.m_listWidget_AvailableFeaturesOnSensorLevel->addItems(m_vAvailableFeaturesSensor);
399 ui.m_listWidget_ChosenFeaturesOnSensorLevel->addItems(m_pBCI->m_slChosenFeatureSensor);
405 void BCISetupWidget::setFeatureSelection()
407 QStringList ChosenFeaturesOnSensorLevel;
408 for(
int i=0; i< ui.m_listWidget_ChosenFeaturesOnSensorLevel->count(); i++)
409 ChosenFeaturesOnSensorLevel << ui.m_listWidget_ChosenFeaturesOnSensorLevel->item(i)->text();
411 QStringList ChosenFeaturesOnSourceLevel;
412 for(
int i=0; i< ui.m_listWidget_ChosenFeaturesOnSourceLevel->count(); i++)
413 ChosenFeaturesOnSourceLevel << ui.m_listWidget_ChosenFeaturesOnSourceLevel->item(i)->text();
415 m_pBCI->m_slChosenFeatureSensor = ChosenFeaturesOnSensorLevel;
416 m_pBCI->m_slChosenFeatureSource = ChosenFeaturesOnSourceLevel;
422 void BCISetupWidget::setFilterOptions()
424 m_pBCI->m_bUseFilter = ui.m_checkBox_UseFilter->isChecked();
425 m_pBCI->m_dFilterLowerBound = ui.m_doubleSpinBox_FilterLowerBound->value();
426 m_pBCI->m_dFilterUpperBound = ui.m_doubleSpinBox_FilterUpperBound->value();
427 m_pBCI->m_iFilterOrder = ui.m_SpinBox_FilterOrder->value();
428 m_pBCI->m_dParcksWidth = ui.m_doubleSpinBox_ParcksWidth->value();
434 void BCISetupWidget::setClassificationOptions()
436 m_pBCI->m_iFeatureCalculationType = ui.m_comboBox_featureCalculationType->currentIndex();
442 void BCISetupWidget::showAboutDialog()
453 if ((
object == ui.m_listWidget_ChosenFeaturesOnSensorLevel ||
454 object == ui.m_listWidget_ChosenFeaturesOnSourceLevel ||
455 object == ui.m_listWidget_AvailableFeaturesOnSensorLevel ||
456 object == ui.m_listWidget_AvailableFeaturesOnSourceLevel) && event->type() == QEvent::Leave)
457 setFeatureSelection();
459 return QObject::eventFilter(
object, event);;
The BCI class provides an EEG BCI.