40 #include "ui_scalingview.h"
61 using namespace DISPLIB;
62 using namespace FIFFLIB;
71 const static float m_fScaleMAG = 1e-12f;
72 const static float m_fScaleGRAD = 1e-15f;
73 const static float m_fScaleEEG = 1e-5f;
74 const static float m_fScaleEOG = 1e-6f;
75 const static float m_fScaleECG = 1e-2f;
76 const static float m_fScaleSTIM = 1e-3f;
77 const static float m_fScaleMISC = 1e-3f;
78 const static float m_fScaleEMG = 1e-3f;
79 const static int MAG_TO_GRAD_LINK = 31337;
84 float fMaxScale(1e-9f);
86 switch(iChannelKind) {
88 if( iChannelUnit == FIFF_UNIT_T_M ) {
89 fMaxScale = m_fScaleGRAD;
91 else if( iChannelUnit == FIFF_UNIT_T ) {
92 fMaxScale = m_fScaleMAG;
98 fMaxScale = m_fScaleMAG;
103 fMaxScale = m_fScaleEEG;
108 fMaxScale = m_fScaleECG;
112 fMaxScale = m_fScaleEMG;
116 fMaxScale = m_fScaleEOG;
120 case FIFFV_STIM_CH: {
121 fMaxScale = m_fScaleSTIM;
125 case FIFFV_MISC_CH: {
126 fMaxScale = m_fScaleMISC;
140 float fMaxScale = qMapChScaling.value(iChannelKind);
142 if(iChannelKind == FIFFV_MEG_CH) {
143 fMaxScale = qMapChScaling.value(iChannelUnit);
146 if(qIsNaN(fMaxScale) || fMaxScale == 0) {
159 const QStringList& lChannelsToShow)
161 , m_lChannelTypesToShow(lChannelsToShow)
162 , m_pUi(new Ui::ScalingViewWidget)
163 , m_bLinkMAGtoGRAD(false)
164 , m_bIsShiftKeyPressed(false)
165 , m_bManagingSpinBoxChange(false)
166 , m_bManagingSliderChange(false)
167 , m_bManagingLinkMagToGrad(false)
169 m_sSettingsPath = sSettingsPath;
170 m_pUi->setupUi(
this);
172 this->setWindowTitle(
"Scaling");
173 this->setMinimumWidth(230);
176 createScaleControls();
188 for(
auto& control : m_qMapScaleControls)
196 void ScalingView::keyReleaseEvent(QKeyEvent *event)
198 if(event->key() == Qt::Key_Shift)
200 m_bIsShiftKeyPressed =
false;
202 QWidget::keyReleaseEvent(event);
207 void ScalingView::keyPressEvent(QKeyEvent *event)
209 if(event->key() == Qt::Key_Shift)
211 m_bIsShiftKeyPressed =
true;
213 QWidget::keyPressEvent(event);
220 return m_qMapChScaling;
227 m_qMapChScaling = qMapChScaling;
229 createScaleControls();
236 if(m_sSettingsPath.isEmpty()) {
240 QSettings settings(
"MNECPP");
242 if(m_qMapChScaling.contains(FIFF_UNIT_T)) {
243 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleMAG"), m_qMapChScaling[FIFF_UNIT_T]);
246 if(m_qMapChScaling.contains(FIFF_UNIT_T_M)) {
247 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleGRAD"), m_qMapChScaling[FIFF_UNIT_T_M]);
250 if(m_qMapChScaling.contains(FIFFV_EEG_CH)) {
251 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleEEG"), m_qMapChScaling[FIFFV_EEG_CH]);
254 if(m_qMapChScaling.contains(FIFFV_EOG_CH)) {
255 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleEOG"), m_qMapChScaling[FIFFV_EOG_CH]);
258 if(m_qMapChScaling.contains(FIFFV_ECG_CH)) {
259 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleECG"), m_qMapChScaling[FIFFV_ECG_CH]);
262 if(m_qMapChScaling.contains(FIFFV_STIM_CH)) {
263 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleSTIM"), m_qMapChScaling[FIFFV_STIM_CH]);
266 if(m_qMapChScaling.contains(FIFFV_MISC_CH)) {
267 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleMISC"), m_qMapChScaling[FIFFV_MISC_CH]);
275 if(m_sSettingsPath.isEmpty()) {
279 QSettings settings(
"MNECPP");
281 float val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleMAG"), m_fScaleMAG * 3).toFloat();
282 m_qMapChScaling.insert(FIFF_UNIT_T, val);
284 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleGRAD"), m_fScaleGRAD * 300 * 100).toFloat();
285 m_qMapChScaling.insert(FIFF_UNIT_T_M, val);
287 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleEEG"), m_fScaleEEG * 10).toFloat();
288 m_qMapChScaling.insert(FIFFV_EEG_CH, val);
290 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleEOG"), m_fScaleEOG).toFloat();
291 m_qMapChScaling.insert(FIFFV_EOG_CH, val);
293 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleECG"), m_fScaleECG).toFloat();
294 m_qMapChScaling.insert(FIFFV_ECG_CH, val);
296 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleSTIM"), m_fScaleSTIM).toFloat();
297 m_qMapChScaling.insert(FIFFV_STIM_CH, val);
299 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleMISC"), m_fScaleMISC).toFloat();
300 m_qMapChScaling.insert(FIFFV_MISC_CH, val);
305 void ScalingView::updateGuiMode(GuiMode mode)
308 case GuiMode::Clinical:
317 void ScalingView::updateProcessingMode(ProcessingMode mode)
320 case ProcessingMode::Offline:
329 void ScalingView::processScalingChange()
337 void ScalingView::updateMAGScale(
double dScale)
339 m_qMapChScaling.insert(FIFF_UNIT_T, dScale * m_fScaleMAG);
341 processScalingChange();
346 void ScalingView::linkMagToGrad()
348 if(m_bLinkMAGtoGRAD && !m_bManagingLinkMagToGrad)
350 m_bManagingLinkMagToGrad =
true;
351 m_qMapScaleControls[FIFF_UNIT_T_M]->setValue(m_qMapScaleControls[FIFF_UNIT_T]->value() / (m_qMapScaleControls[MAG_TO_GRAD_LINK]->value() / 100.f));
352 m_bManagingLinkMagToGrad =
false;
358 void ScalingView::linkGradToMag()
360 if(m_bLinkMAGtoGRAD && !m_bManagingLinkMagToGrad)
362 m_bManagingLinkMagToGrad =
true;
363 m_qMapScaleControls[FIFF_UNIT_T]->setValue(m_qMapScaleControls[FIFF_UNIT_T_M]->value() * (m_qMapScaleControls[MAG_TO_GRAD_LINK]->value() / 100.0f));
364 m_bManagingLinkMagToGrad =
false;
370 void ScalingView::updateGRADScale(
double dScale)
372 m_qMapChScaling.insert(FIFF_UNIT_T_M, dScale * m_fScaleGRAD * 100.0);
374 processScalingChange();
379 void ScalingView::updateEEGScale(
double dScale)
381 m_qMapChScaling.insert(FIFFV_EEG_CH, dScale * m_fScaleEEG);
382 processScalingChange();
387 void ScalingView::updateEOGScale(
double dScale)
389 m_qMapChScaling.insert(FIFFV_EOG_CH, dScale * m_fScaleEOG);
390 processScalingChange();
395 void ScalingView::updateEMGScale(
double dScale)
397 m_qMapChScaling.insert(FIFFV_EMG_CH, dScale * m_fScaleEMG);
398 processScalingChange();
403 void ScalingView::updateECGScale(
double dScale)
405 m_qMapChScaling.insert(FIFFV_ECG_CH, dScale * m_fScaleECG);
406 processScalingChange();
411 void ScalingView::updateMISCScale(
double dScale)
413 m_qMapChScaling.insert(FIFFV_MISC_CH, dScale * m_fScaleMISC);
414 processScalingChange();
419 void ScalingView::updateSTIMScale(
double scale)
421 m_qMapChScaling.insert(FIFFV_STIM_CH, scale * m_fScaleSTIM);
422 processScalingChange();
427 void ScalingView::updateMAGtoGRADlink(
double dScale)
436 void ScalingView::drawScalingGUI()
439 int controls[] = {FIFF_UNIT_T,
449 if(m_qMapScaleControls.contains(c))
451 m_pUi->verticalLayout->insertWidget(i++, m_qMapScaleControls[c].data());
454 createLinkMagGradCheckBox();
461 if(m_qMapScaleControls.contains(MAG_TO_GRAD_LINK))
463 m_bLinkMAGtoGRAD = (l == 2)?
true:
false;
465 m_bLinkMAGtoGRAD =
false;
469 m_qMapScaleControls[MAG_TO_GRAD_LINK]->setValue(100 * m_qMapScaleControls[FIFF_UNIT_T]->value() / m_qMapScaleControls[FIFF_UNIT_T_M]->value());
476 void ScalingView::showLinkControl()
478 if(m_qMapScaleControls.contains(MAG_TO_GRAD_LINK))
480 m_qMapScaleControls[MAG_TO_GRAD_LINK]->setVisible(m_bLinkMAGtoGRAD);
486 void ScalingView::createScaleControls()
489 if(m_qMapChScaling.contains(FIFF_UNIT_T) && (m_lChannelTypesToShow.contains(
"mag") || m_lChannelTypesToShow.contains(
"all")))
491 QPointer<ScaleControl> pControlMAG = QPointer<ScaleControl>(
new ScaleControl(
"MAG [pT])"));
492 pControlMAG->setRange(0.2f, 20.0f);
493 pControlMAG->setMaxSensitivityPoint(1.5);
494 pControlMAG->setValue(1.5f);
495 pControlMAG->setSensitivity(0.7f);
496 pControlMAG->invertSlider(
true);
498 m_qMapScaleControls.insert(FIFF_UNIT_T, pControlMAG);
502 if(m_qMapChScaling.contains(FIFF_UNIT_T_M) && (m_lChannelTypesToShow.contains(
"grad") || m_lChannelTypesToShow.contains(
"all")))
504 QPointer<ScaleControl> pControlGRAD = QPointer<ScaleControl>(
new ScaleControl(
"GRAD [fT/cm]"));
505 pControlGRAD->setRange(30.0f, 5000.0f);
506 pControlGRAD->setMaxSensitivityPoint(100.0f);
507 pControlGRAD->setValue(240.0f);
508 pControlGRAD->setSensitivity(0.7f);
509 pControlGRAD->invertSlider(
true);
511 m_qMapScaleControls.insert(FIFF_UNIT_T_M, pControlGRAD);
515 if(m_qMapScaleControls.contains(FIFF_UNIT_T) && m_qMapScaleControls.contains(FIFF_UNIT_T_M))
517 QPointer<ScaleControl> pControlMAGtoGRADlink = QPointer<ScaleControl>(
new ScaleControl(
"MAG-GRAD link [cm]"));
518 pControlMAGtoGRADlink->setRange(0.10f, 8.0f);
519 pControlMAGtoGRADlink->setMaxSensitivityPoint(2.0f);
520 pControlMAGtoGRADlink->setValue(2.0f);
521 pControlMAGtoGRADlink->setSensitivity(0.7f);
523 pControlMAGtoGRADlink->setVisible(m_bLinkMAGtoGRAD);
524 m_qMapScaleControls.insert(MAG_TO_GRAD_LINK,pControlMAGtoGRADlink);
528 if(m_qMapChScaling.contains(FIFFV_EEG_CH) && (m_lChannelTypesToShow.contains(
"eeg") || m_lChannelTypesToShow.contains(
"all")))
530 QPointer<ScaleControl> pControlEEG = QPointer<ScaleControl>(
new ScaleControl(
"EEG [uV]"));
531 pControlEEG->setRange(3.0f, 100.0f);
532 pControlEEG->setMaxSensitivityPoint(14.0f);
533 pControlEEG->setValue(14.0f);
534 pControlEEG->setSensitivity(0.4f);
535 pControlEEG->invertSlider(
true);
537 m_qMapScaleControls.insert(FIFFV_EEG_CH, pControlEEG);
541 if(m_qMapChScaling.contains(FIFFV_EOG_CH) && (m_lChannelTypesToShow.contains(
"eog") || m_lChannelTypesToShow.contains(
"all")))
543 QPointer<ScaleControl> pControlEOG = QPointer<ScaleControl>(
new ScaleControl(
"EOG [uV]"));
544 pControlEOG->setRange(3.0f, 100.0f);
545 pControlEOG->setMaxSensitivityPoint(14.0f);
546 pControlEOG->setValue(14.0f);
547 pControlEOG->setSensitivity(0.4f);
548 pControlEOG->invertSlider(
true);
550 m_qMapScaleControls.insert(FIFFV_EOG_CH, pControlEOG);
554 if(m_qMapChScaling.contains(FIFFV_ECG_CH) && (m_lChannelTypesToShow.contains(
"ecg") || m_lChannelTypesToShow.contains(
"all")))
556 QPointer<ScaleControl> pControlECG = QPointer<ScaleControl>(
new ScaleControl(
"ECG [uV]"));
557 pControlECG->setRange(3.0f, 100.0f);
558 pControlECG->setMaxSensitivityPoint(14.0f);
559 pControlECG->setValue(14.0f);
560 pControlECG->setSensitivity(0.4f);
561 pControlECG->invertSlider(
true);
563 m_qMapScaleControls.insert(FIFFV_ECG_CH, pControlECG);
567 if(m_qMapChScaling.contains(FIFFV_STIM_CH) && (m_lChannelTypesToShow.contains(
"stim") || m_lChannelTypesToShow.contains(
"all")))
569 QPointer<ScaleControl> pControlSTIM = QPointer<ScaleControl>(
new ScaleControl(
"STIM"));
570 pControlSTIM->setRange(1.0f, 99999.0f);
571 pControlSTIM->setMaxSensitivityPoint(5000.0f);
572 pControlSTIM->setValue(5000.0f);
573 pControlSTIM->setSensitivity(0.8f);
574 pControlSTIM->invertSlider(
true);
576 m_qMapScaleControls.insert(FIFFV_STIM_CH, pControlSTIM);
580 if(m_qMapChScaling.contains(FIFFV_MISC_CH) && (m_lChannelTypesToShow.contains(
"misc") || m_lChannelTypesToShow.contains(
"all")))
582 QPointer<ScaleControl> pControlMISC = QPointer<ScaleControl>(
new ScaleControl(
"MISC"));
583 pControlMISC->setRange(3.0f, 100.0f);
584 pControlMISC->setMaxSensitivityPoint(14.0f);
585 pControlMISC->setValue(14.0f);
586 pControlMISC->setSensitivity(0.4f);
587 pControlMISC->invertSlider(
true);
589 m_qMapScaleControls.insert(FIFFV_MISC_CH, pControlMISC);
602 void ScalingView::createLinkMagGradCheckBox()
604 m_pCheckBox = QPointer<QCheckBox>(
new QCheckBox(
"Link MAGs -> GRADs"));
605 m_pCheckBox->setChecked(m_bLinkMAGtoGRAD);
607 m_pUi->verticalLayout->addWidget(m_pCheckBox);