22#include "ui_scalingview.h"
53const static float m_fScaleMAG = 1e-12f;
54const static float m_fScaleGRAD = 1e-15f;
55const static float m_fScaleEEG = 1e-5f;
56const static float m_fScaleEOG = 1e-6f;
57const static float m_fScaleECG = 1e-2f;
58const static float m_fScaleSTIM = 1e-3f;
59const static float m_fScaleMISC = 1e-3f;
60const static float m_fScaleEMG = 1e-3f;
61const static int MAG_TO_GRAD_LINK = 31337;
66 float fMaxScale(1e-9f);
68 switch(iChannelKind) {
71 fMaxScale = m_fScaleGRAD;
74 fMaxScale = m_fScaleMAG;
80 fMaxScale = m_fScaleMAG;
85 fMaxScale = m_fScaleEEG;
90 fMaxScale = m_fScaleECG;
94 fMaxScale = m_fScaleEMG;
98 fMaxScale = m_fScaleEOG;
103 fMaxScale = m_fScaleSTIM;
108 fMaxScale = m_fScaleMISC;
122 float fMaxScale = qMapChScaling.value(iChannelKind);
125 fMaxScale = qMapChScaling.value(iChannelUnit);
128 if(qIsNaN(fMaxScale) || fMaxScale == 0) {
141 const QStringList& lChannelsToShow)
143, m_lChannelTypesToShow(lChannelsToShow)
144, m_pUi(new Ui::ScalingViewWidget)
145, m_bLinkMAGtoGRAD(false)
146, m_bIsShiftKeyPressed(false)
147, m_bManagingSpinBoxChange(false)
148, m_bManagingSliderChange(false)
149, m_bManagingLinkMagToGrad(false)
151 m_sSettingsPath = sSettingsPath;
152 m_pUi->setupUi(
this);
154 this->setWindowTitle(
"Scaling");
155 this->setMinimumWidth(230);
158 createScaleControls();
170 for(
auto& control : m_qMapScaleControls)
178void ScalingView::keyReleaseEvent(QKeyEvent *event)
180 if(event->key() == Qt::Key_Shift)
182 m_bIsShiftKeyPressed =
false;
184 QWidget::keyReleaseEvent(event);
189void ScalingView::keyPressEvent(QKeyEvent *event)
191 if(event->key() == Qt::Key_Shift)
193 m_bIsShiftKeyPressed =
true;
195 QWidget::keyPressEvent(event);
202 return m_qMapChScaling;
209 m_qMapChScaling = qMapChScaling;
211 createScaleControls();
218 if(m_sSettingsPath.isEmpty()) {
222 QSettings settings(
"MNECPP");
225 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleMAG"), m_qMapChScaling[
FIFF_UNIT_T]);
229 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleGRAD"), m_qMapChScaling[
FIFF_UNIT_T_M]);
233 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleEEG"), m_qMapChScaling[
FIFFV_EEG_CH]);
237 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleEOG"), m_qMapChScaling[
FIFFV_EOG_CH]);
241 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleECG"), m_qMapChScaling[
FIFFV_ECG_CH]);
245 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleSTIM"), m_qMapChScaling[
FIFFV_STIM_CH]);
249 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleMISC"), m_qMapChScaling[
FIFFV_MISC_CH]);
257 if(m_sSettingsPath.isEmpty()) {
261 QSettings settings(
"MNECPP");
263 float val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleMAG"), m_fScaleMAG * 3).toFloat();
266 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleGRAD"), m_fScaleGRAD * 300 * 100).toFloat();
269 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleEEG"), m_fScaleEEG * 10).toFloat();
272 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleEOG"), m_fScaleEOG).toFloat();
275 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleECG"), m_fScaleECG).toFloat();
278 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleSTIM"), m_fScaleSTIM).toFloat();
281 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleMISC"), m_fScaleMISC).toFloat();
287void ScalingView::updateGuiMode(GuiMode mode)
299void ScalingView::updateProcessingMode(ProcessingMode mode)
311void ScalingView::processScalingChange()
319void ScalingView::updateMAGScale(
double dScale)
321 m_qMapChScaling.insert(
FIFF_UNIT_T, dScale * m_fScaleMAG);
323 processScalingChange();
328void ScalingView::linkMagToGrad()
330 if(m_bLinkMAGtoGRAD && !m_bManagingLinkMagToGrad)
332 m_bManagingLinkMagToGrad =
true;
333 m_qMapScaleControls[
FIFF_UNIT_T_M]->setValue(m_qMapScaleControls[
FIFF_UNIT_T]->value() / (m_qMapScaleControls[MAG_TO_GRAD_LINK]->value() / 100.f));
334 m_bManagingLinkMagToGrad =
false;
340void ScalingView::linkGradToMag()
342 if(m_bLinkMAGtoGRAD && !m_bManagingLinkMagToGrad)
344 m_bManagingLinkMagToGrad =
true;
345 m_qMapScaleControls[
FIFF_UNIT_T]->setValue(m_qMapScaleControls[
FIFF_UNIT_T_M]->value() * (m_qMapScaleControls[MAG_TO_GRAD_LINK]->value() / 100.0f));
346 m_bManagingLinkMagToGrad =
false;
352void ScalingView::updateGRADScale(
double dScale)
354 m_qMapChScaling.insert(
FIFF_UNIT_T_M, dScale * m_fScaleGRAD * 100.0);
356 processScalingChange();
361void ScalingView::updateEEGScale(
double dScale)
363 m_qMapChScaling.insert(
FIFFV_EEG_CH, dScale * m_fScaleEEG);
364 processScalingChange();
369void ScalingView::updateEOGScale(
double dScale)
371 m_qMapChScaling.insert(
FIFFV_EOG_CH, dScale * m_fScaleEOG);
372 processScalingChange();
377void ScalingView::updateEMGScale(
double dScale)
379 m_qMapChScaling.insert(
FIFFV_EMG_CH, dScale * m_fScaleEMG);
380 processScalingChange();
385void ScalingView::updateECGScale(
double dScale)
387 m_qMapChScaling.insert(
FIFFV_ECG_CH, dScale * m_fScaleECG);
388 processScalingChange();
393void ScalingView::updateMISCScale(
double dScale)
395 m_qMapChScaling.insert(
FIFFV_MISC_CH, dScale * m_fScaleMISC);
396 processScalingChange();
401void ScalingView::updateSTIMScale(
double scale)
404 processScalingChange();
409void ScalingView::updateMAGtoGRADlink(
double dScale)
418void ScalingView::drawScalingGUI()
431 if(m_qMapScaleControls.contains(c))
433 m_pUi->verticalLayout->insertWidget(i++, m_qMapScaleControls[c].data());
436 createLinkMagGradCheckBox();
443 if(m_qMapScaleControls.contains(MAG_TO_GRAD_LINK))
445 m_bLinkMAGtoGRAD = (l == Qt::Checked);
447 m_bLinkMAGtoGRAD =
false;
451 m_qMapScaleControls[MAG_TO_GRAD_LINK]->setValue(100 * m_qMapScaleControls[
FIFF_UNIT_T]->value() / m_qMapScaleControls[
FIFF_UNIT_T_M]->value());
458void ScalingView::showLinkControl()
460 if(m_qMapScaleControls.contains(MAG_TO_GRAD_LINK))
462 m_qMapScaleControls[MAG_TO_GRAD_LINK]->setVisible(m_bLinkMAGtoGRAD);
468void ScalingView::createScaleControls()
471 if(m_qMapChScaling.contains(
FIFF_UNIT_T) && (m_lChannelTypesToShow.contains(
"mag") || m_lChannelTypesToShow.contains(
"all")))
473 QPointer<ScaleControl> pControlMAG = QPointer<ScaleControl>(
new ScaleControl(
"MAG [pT])"));
474 pControlMAG->setRange(0.2f, 20.0f);
475 pControlMAG->setMaxSensitivityPoint(1.5);
476 pControlMAG->setValue(1.5f);
477 pControlMAG->setSensitivity(0.7f);
478 pControlMAG->invertSlider(
true);
480 m_qMapScaleControls.insert(
FIFF_UNIT_T, pControlMAG);
484 if(m_qMapChScaling.contains(
FIFF_UNIT_T_M) && (m_lChannelTypesToShow.contains(
"grad") || m_lChannelTypesToShow.contains(
"all")))
486 QPointer<ScaleControl> pControlGRAD = QPointer<ScaleControl>(
new ScaleControl(
"GRAD [fT/cm]"));
487 pControlGRAD->setRange(30.0f, 5000.0f);
488 pControlGRAD->setMaxSensitivityPoint(100.0f);
489 pControlGRAD->setValue(240.0f);
490 pControlGRAD->setSensitivity(0.7f);
491 pControlGRAD->invertSlider(
true);
499 QPointer<ScaleControl> pControlMAGtoGRADlink = QPointer<ScaleControl>(
new ScaleControl(
"MAG-GRAD link [cm]"));
500 pControlMAGtoGRADlink->setRange(0.10f, 8.0f);
501 pControlMAGtoGRADlink->setMaxSensitivityPoint(2.0f);
502 pControlMAGtoGRADlink->setValue(2.0f);
503 pControlMAGtoGRADlink->setSensitivity(0.7f);
505 pControlMAGtoGRADlink->setVisible(m_bLinkMAGtoGRAD);
506 m_qMapScaleControls.insert(MAG_TO_GRAD_LINK,pControlMAGtoGRADlink);
510 if(m_qMapChScaling.contains(
FIFFV_EEG_CH) && (m_lChannelTypesToShow.contains(
"eeg") || m_lChannelTypesToShow.contains(
"all")))
512 QPointer<ScaleControl> pControlEEG = QPointer<ScaleControl>(
new ScaleControl(
"EEG [uV]"));
513 pControlEEG->setRange(3.0f, 100.0f);
514 pControlEEG->setMaxSensitivityPoint(14.0f);
515 pControlEEG->setValue(14.0f);
516 pControlEEG->setSensitivity(0.4f);
517 pControlEEG->invertSlider(
true);
523 if(m_qMapChScaling.contains(
FIFFV_EOG_CH) && (m_lChannelTypesToShow.contains(
"eog") || m_lChannelTypesToShow.contains(
"all")))
525 QPointer<ScaleControl> pControlEOG = QPointer<ScaleControl>(
new ScaleControl(
"EOG [uV]"));
526 pControlEOG->setRange(3.0f, 100.0f);
527 pControlEOG->setMaxSensitivityPoint(14.0f);
528 pControlEOG->setValue(14.0f);
529 pControlEOG->setSensitivity(0.4f);
530 pControlEOG->invertSlider(
true);
536 if(m_qMapChScaling.contains(
FIFFV_ECG_CH) && (m_lChannelTypesToShow.contains(
"ecg") || m_lChannelTypesToShow.contains(
"all")))
538 QPointer<ScaleControl> pControlECG = QPointer<ScaleControl>(
new ScaleControl(
"ECG [uV]"));
539 pControlECG->setRange(3.0f, 100.0f);
540 pControlECG->setMaxSensitivityPoint(14.0f);
541 pControlECG->setValue(14.0f);
542 pControlECG->setSensitivity(0.4f);
543 pControlECG->invertSlider(
true);
549 if(m_qMapChScaling.contains(
FIFFV_STIM_CH) && (m_lChannelTypesToShow.contains(
"stim") || m_lChannelTypesToShow.contains(
"all")))
551 QPointer<ScaleControl> pControlSTIM = QPointer<ScaleControl>(
new ScaleControl(
"STIM"));
552 pControlSTIM->setRange(1.0f, 99999.0f);
553 pControlSTIM->setMaxSensitivityPoint(5000.0f);
554 pControlSTIM->setValue(5000.0f);
555 pControlSTIM->setSensitivity(0.8f);
556 pControlSTIM->invertSlider(
true);
562 if(m_qMapChScaling.contains(
FIFFV_MISC_CH) && (m_lChannelTypesToShow.contains(
"misc") || m_lChannelTypesToShow.contains(
"all")))
564 QPointer<ScaleControl> pControlMISC = QPointer<ScaleControl>(
new ScaleControl(
"MISC"));
565 pControlMISC->setRange(3.0f, 100.0f);
566 pControlMISC->setMaxSensitivityPoint(14.0f);
567 pControlMISC->setValue(14.0f);
568 pControlMISC->setSensitivity(0.4f);
569 pControlMISC->invertSlider(
true);
584void ScalingView::createLinkMagGradCheckBox()
586 m_pCheckBox = QPointer<QCheckBox>(
new QCheckBox(
"Link MAGs -> GRADs"));
587 m_pCheckBox->setChecked(m_bLinkMAGtoGRAD);
589 m_pUi->verticalLayout->addWidget(m_pCheckBox);
Per-modality vertical-scale spinbox panel (one spin per channel type).
Composite slider + spinbox widget for picking a (possibly logarithmic) scale value.
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
FIFF file I/O, in-memory data structures and high-level readers/writers.
2-D display widgets and visualisation helpers (charts, topography, colour maps).
float getScalingValue(const QMap< qint32, float > &qMapChScaling, int iChannelKind, int iChannelUnit)
float getDefaultScalingValue(int iChannelKind, int iChannelUnit)
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
void valueChanged(double dScale)
void scalingChanged(const QMap< qint32, float > &scalingMap)
void saveSettings() override
void setMagGradLink(Qt::CheckState l)
void loadSettings() override
void clearView() override
ScalingView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget, const QStringList &lChannelsToShow=QStringList()<< "all")
void setScaleMap(const QMap< qint32, float > &qMapChScaling)
QMap< qint32, float > getScaleMap() const