41 #include "ui_averagingsettingsview.h"
59 using namespace DISPLIB;
60 using namespace FIFFLIB;
66 AveragingSettingsView::AveragingSettingsView(
const QString& sSettingsPath,
67 const QMap<QString, int> &mapStimChsIndexNames,
70 , m_pUi(new Ui::AverageSettingsViewWidget)
71 , m_mapStimChsIndexNames(mapStimChsIndexNames)
76 this->setWindowTitle(
"Averaging Settings");
77 this->setMinimumWidth(330);
94 void AveragingSettingsView::setStimChannels(
const QMap<QString,int>& mapStimChsIndexNames)
96 if(!mapStimChsIndexNames.isEmpty()) {
97 m_mapStimChsIndexNames = mapStimChsIndexNames;
99 m_pUi->m_pComboBoxChSelection->clear();
101 QMapIterator<QString, int> i(mapStimChsIndexNames);
102 while (i.hasNext()) {
104 m_pUi->m_pComboBoxChSelection->insertItem(
m_pUi->m_pComboBoxChSelection->count(),i.key());
107 m_pUi->m_pComboBoxChSelection->setCurrentText(m_sCurrentStimChan);
109 connect(
m_pUi->m_pComboBoxChSelection, &QComboBox::currentTextChanged,
110 this, &AveragingSettingsView::onChangeStimChannel);
116 QString AveragingSettingsView::getCurrentStimCh()
118 return m_sCurrentStimChan;
123 bool AveragingSettingsView::getDoBaselineCorrection()
125 return m_bDoBaselineCorrection;
130 int AveragingSettingsView::getNumAverages()
132 return m_iNumAverages;
137 int AveragingSettingsView::getBaselineFromSeconds()
139 return m_iBaselineFromSeconds;
144 int AveragingSettingsView::getBaselineToSeconds()
146 return m_iBaselineToSeconds;
151 int AveragingSettingsView::getPreStimMSeconds()
153 return m_iPreStimSeconds;
158 int AveragingSettingsView::getPostStimMSeconds()
160 return m_iPostStimSeconds;
165 int AveragingSettingsView::getStimChannelIdx()
167 return m_pUi->m_pComboBoxChSelection->currentData().toInt();
174 if(!m_mapStimChsIndexNames.isEmpty()) {
175 m_pUi->m_pComboBoxChSelection->clear();
177 QMapIterator<QString, int> i(m_mapStimChsIndexNames);
178 while (i.hasNext()) {
180 m_pUi->m_pComboBoxChSelection->insertItem(
m_pUi->m_pComboBoxChSelection->count(),i.key());
183 m_pUi->m_pComboBoxChSelection->setCurrentText(m_sCurrentStimChan);
185 connect(
m_pUi->m_pComboBoxChSelection, &QComboBox::currentTextChanged,
186 this, &AveragingSettingsView::changeStimChannel);
189 m_pUi->m_pSpinBoxNumAverages->setValue(m_iNumAverages);
190 connect(
m_pUi->m_pSpinBoxNumAverages,
static_cast<void (QSpinBox::*)()
>(&QSpinBox::editingFinished),
191 this, &AveragingSettingsView::onChangeNumAverages);
194 m_pUi->m_pSpinBoxPreStimMSeconds->setValue(m_iPreStimSeconds);
195 connect(
m_pUi->m_pSpinBoxPreStimMSeconds,
static_cast<void (QSpinBox::*)()
>(&QSpinBox::editingFinished),
196 this, &AveragingSettingsView::onChangePreStim);
198 m_pUi->m_pSpinBoxPostStimMSeconds->setValue(m_iPostStimSeconds);
199 connect(
m_pUi->m_pSpinBoxPostStimMSeconds,
static_cast<void (QSpinBox::*)()
>(&QSpinBox::editingFinished),
200 this, &AveragingSettingsView::onChangePostStim);
203 m_pUi->m_pcheckBoxBaselineCorrection->setChecked(m_bDoBaselineCorrection);
204 connect(
m_pUi->m_pcheckBoxBaselineCorrection, &QCheckBox::clicked,
205 this, &AveragingSettingsView::changeBaselineActive);
207 m_pUi->m_pSpinBoxBaselineFromMSeconds->setMinimum(
m_pUi->m_pSpinBoxPreStimMSeconds->value()*-1);
208 m_pUi->m_pSpinBoxBaselineFromMSeconds->setMaximum(
m_pUi->m_pSpinBoxPostStimMSeconds->value());
209 m_pUi->m_pSpinBoxBaselineFromMSeconds->setValue(m_iBaselineFromSeconds);
210 connect(
m_pUi->m_pSpinBoxBaselineFromMSeconds,
static_cast<void (QSpinBox::*)()
>(&QSpinBox::editingFinished),
211 this, &AveragingSettingsView::onChangeBaselineFrom);
213 m_pUi->m_pSpinBoxBaselineToMSeconds->setMinimum(
m_pUi->m_pSpinBoxPreStimMSeconds->value()*-1);
214 m_pUi->m_pSpinBoxBaselineToMSeconds->setMaximum(
m_pUi->m_pSpinBoxPostStimMSeconds->value());
215 m_pUi->m_pSpinBoxBaselineToMSeconds->setValue(m_iBaselineToSeconds);
216 connect(
m_pUi->m_pSpinBoxBaselineToMSeconds,
static_cast<void (QSpinBox::*)()
>(&QSpinBox::editingFinished),
217 this, &AveragingSettingsView::onChangeBaselineTo);
219 connect(
m_pUi->m_pushButton_reset,
static_cast<void (QPushButton::*)(
bool)
>(&QPushButton::clicked),
220 this, &AveragingSettingsView::resetAverage);
222 connect(
m_pUi->m_pushButton_compute,
static_cast<void (QPushButton::*)(
bool)
>(&QPushButton::clicked),
223 this, &AveragingSettingsView::calculateAverage);
224 connect(
m_pUi->m_checkBox_reject, &QCheckBox::clicked,
225 this, &AveragingSettingsView::changeDropActive);
227 connect(
m_pUi->checkBox_autoCompute, &QCheckBox::clicked,
228 this, &AveragingSettingsView::setAutoCompute);
230 m_pUi->m_pushButton_compute->hide();
231 m_pUi->m_checkBox_reject->hide();
232 m_pUi->m_pushButton_compute->hide();
234 setWindowFlags(Qt::WindowStaysOnTopHint);
236 m_pUi->m_groupBox_detectedTrials->hide();
241 void AveragingSettingsView::setDetectedEpochs(
const FiffEvokedSet& evokedSet)
243 if(evokedSet.
evoked.isEmpty()) {
244 m_pUi->m_groupBox_detectedTrials->hide();
247 m_pUi->m_groupBox_detectedTrials->show();
250 QGridLayout* topLayout =
static_cast<QGridLayout*
>(
m_pUi->m_groupBox_detectedTrials->layout());
252 topLayout =
new QGridLayout();
256 while ((child = topLayout->takeAt(0)) != 0) {
257 delete child->widget();
261 topLayout->addWidget(
new QLabel(
"Type"),0,0);
262 topLayout->addWidget(
new QLabel(
"#"),0,1);
264 for(
int i = 0; i < evokedSet.
evoked.size(); i++) {
267 topLayout->addWidget(
new QLabel(evokedSet.
evoked.at(i).comment),i+1,0);
268 topLayout->addWidget(
new QLabel(QString::number(evokedSet.
evoked.at(i).nave)),i+1,1);
273 m_pUi->m_groupBox_detectedTrials->setLayout(topLayout);
285 QSettings settings(
"MNECPP");
287 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/preStimSeconds"), m_iPreStimSeconds);
288 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/postStimSeconds"), m_iPostStimSeconds);
289 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/numAverages"), m_iNumAverages);
290 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/currentStimChannel"), m_sCurrentStimChan);
291 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/baselineFromSeconds"), m_iBaselineFromSeconds);
292 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/baselineToSeconds"), m_iBaselineToSeconds);
293 settings.setValue(
m_sSettingsPath + QString(
"/AveragingSettingsView/doBaselineCorrection"), m_bDoBaselineCorrection);
305 QSettings settings(
"MNECPP");
307 m_iPreStimSeconds = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/preStimSeconds"), 100).toInt();
308 m_iPostStimSeconds = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/postStimSeconds"), 400).toInt();
309 m_iBaselineFromSeconds = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/baselineFromSeconds"), 0).toInt();
310 m_iBaselineToSeconds = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/baselineToSeconds"), 0).toInt();
312 if(m_iBaselineFromSeconds < -1 * m_iPreStimSeconds || m_iBaselineFromSeconds > m_iPostStimSeconds) {
313 m_iBaselineFromSeconds = -1 * m_iPreStimSeconds;
316 if(m_iBaselineToSeconds > m_iPostStimSeconds || m_iBaselineToSeconds < m_iPreStimSeconds) {
317 m_iBaselineToSeconds = 0;
320 m_iNumAverages = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/numAverages"), 10).toInt();
321 m_sCurrentStimChan = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/currentStimChannel"),
"STI014").toString();
322 m_bDoBaselineCorrection = settings.value(
m_sSettingsPath + QString(
"/AveragingSettingsView/doBaselineCorrection"),
false).toBool();
330 case GuiMode::Clinical:
342 case ProcessingMode::Offline:
343 m_pUi->m_pSpinBoxNumAverages->hide();
344 m_pUi->m_pComboBoxChSelection->hide();
345 m_pUi->m_pushButton_reset->hide();
346 m_pUi->label->hide();
347 m_pUi->m_label_numberAverages->hide();
348 m_pUi->m_pushButton_compute->show();
349 m_pUi->m_checkBox_reject->show();
350 m_pUi->checkBox_autoCompute->show();
353 m_pUi->m_pSpinBoxNumAverages->show();
354 m_pUi->m_pComboBoxChSelection->show();
355 m_pUi->m_pushButton_reset->show();
356 m_pUi->label->show();
357 m_pUi->m_label_numberAverages->show();
358 m_pUi->m_pushButton_compute->hide();
359 m_pUi->m_checkBox_reject->hide();
360 m_pUi->checkBox_autoCompute->hide();
366 void AveragingSettingsView::onChangePreStim()
368 qint32 mSeconds =
m_pUi->m_pSpinBoxPreStimMSeconds->value();
369 m_pUi->m_pSpinBoxBaselineToMSeconds->setMinimum(
m_pUi->m_pSpinBoxPreStimMSeconds->value()*-1);
370 m_pUi->m_pSpinBoxBaselineFromMSeconds->setMinimum(
m_pUi->m_pSpinBoxPreStimMSeconds->value()*-1);
372 m_iPreStimSeconds = mSeconds;
374 emit changePreStim(mSeconds);
381 void AveragingSettingsView::onChangePostStim()
383 qint32 mSeconds =
m_pUi->m_pSpinBoxPostStimMSeconds->value();
384 m_pUi->m_pSpinBoxBaselineToMSeconds->setMaximum(
m_pUi->m_pSpinBoxPostStimMSeconds->value());
385 m_pUi->m_pSpinBoxBaselineFromMSeconds->setMaximum(
m_pUi->m_pSpinBoxPostStimMSeconds->value());
387 m_iPostStimSeconds = mSeconds;
389 emit changePostStim(mSeconds);
396 void AveragingSettingsView::onChangeBaselineFrom()
398 qint32 mSeconds =
m_pUi->m_pSpinBoxBaselineFromMSeconds->value();
399 m_pUi->m_pSpinBoxBaselineToMSeconds->setMinimum(mSeconds);
401 m_iBaselineFromSeconds = mSeconds;
403 emit changeBaselineFrom(mSeconds);
410 void AveragingSettingsView::onChangeBaselineTo()
412 qint32 mSeconds =
m_pUi->m_pSpinBoxBaselineToMSeconds->value();
413 m_pUi->m_pSpinBoxBaselineFromMSeconds->setMaximum(mSeconds);
415 m_iBaselineToSeconds = mSeconds;
417 emit changeBaselineTo(mSeconds);
424 void AveragingSettingsView::onChangeNumAverages()
426 m_iNumAverages =
m_pUi->m_pSpinBoxNumAverages->value();
428 emit changeNumAverages(
m_pUi->m_pSpinBoxNumAverages->value());
435 void AveragingSettingsView::onChangeStimChannel()
437 m_sCurrentStimChan =
m_pUi->m_pComboBoxChSelection->currentText();
439 emit changeStimChannel(m_sCurrentStimChan);
453 bool AveragingSettingsView::getAutoComputeStatus()
455 return m_pUi->checkBox_autoCompute->isChecked();