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;
73 fMaxScale = m_fScaleMAG;
79 fMaxScale = m_fScaleMAG;
84 fMaxScale = m_fScaleEEG;
89 fMaxScale = m_fScaleECG;
93 fMaxScale = m_fScaleEMG;
97 fMaxScale = m_fScaleEOG;
102 fMaxScale = m_fScaleSTIM;
107 fMaxScale = m_fScaleMISC;
121 float fMaxScale = qMapChScaling.value(iChannelKind);
124 fMaxScale = qMapChScaling.value(iChannelUnit);
127 if (qIsNaN(fMaxScale) || fMaxScale == 0) {
140 const QStringList& lChannelsToShow)
142, m_lChannelTypesToShow(lChannelsToShow)
143, m_pUi(new Ui::ScalingViewWidget)
144, m_bLinkMAGtoGRAD(false)
145, m_bIsShiftKeyPressed(false)
146, m_bManagingSpinBoxChange(false)
147, m_bManagingSliderChange(false)
148, m_bManagingLinkMagToGrad(false)
150 m_sSettingsPath = sSettingsPath;
151 m_pUi->setupUi(
this);
153 this->setWindowTitle(
"Scaling");
154 this->setMinimumWidth(230);
157 createScaleControls();
169 for (
auto& control : m_qMapScaleControls) {
176void ScalingView::keyReleaseEvent(QKeyEvent* event)
178 if (event->key() == Qt::Key_Shift) {
179 m_bIsShiftKeyPressed =
false;
181 QWidget::keyReleaseEvent(event);
186void ScalingView::keyPressEvent(QKeyEvent* event)
188 if (event->key() == Qt::Key_Shift) {
189 m_bIsShiftKeyPressed =
true;
191 QWidget::keyPressEvent(event);
198 return m_qMapChScaling;
205 m_qMapChScaling = qMapChScaling;
207 createScaleControls();
214 if (m_sSettingsPath.isEmpty()) {
218 QSettings settings(
"MNECPP");
221 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleMAG"), m_qMapChScaling[
FIFF_UNIT_T]);
225 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleGRAD"), m_qMapChScaling[
FIFF_UNIT_T_M]);
229 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleEEG"), m_qMapChScaling[
FIFFV_EEG_CH]);
233 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleEOG"), m_qMapChScaling[
FIFFV_EOG_CH]);
237 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleECG"), m_qMapChScaling[
FIFFV_ECG_CH]);
241 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleSTIM"), m_qMapChScaling[
FIFFV_STIM_CH]);
245 settings.setValue(m_sSettingsPath + QString(
"/ScalingView/scaleMISC"), m_qMapChScaling[
FIFFV_MISC_CH]);
253 if (m_sSettingsPath.isEmpty()) {
257 QSettings settings(
"MNECPP");
259 float val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleMAG"), m_fScaleMAG * 3).toFloat();
262 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleGRAD"), m_fScaleGRAD * 300 * 100 ).toFloat();
265 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleEEG"), m_fScaleEEG * 10).toFloat();
268 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleEOG"), m_fScaleEOG).toFloat();
271 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleECG"), m_fScaleECG).toFloat();
274 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleSTIM"), m_fScaleSTIM).toFloat();
277 val = settings.value(m_sSettingsPath + QString(
"/ScalingView/scaleMISC"), m_fScaleMISC).toFloat();
283void ScalingView::updateGuiMode(GuiMode mode)
295void ScalingView::updateProcessingMode(ProcessingMode mode)
307void ScalingView::processScalingChange()
315void ScalingView::updateMAGScale(
double dScale)
317 m_qMapChScaling.insert(
FIFF_UNIT_T, dScale * m_fScaleMAG);
319 processScalingChange();
324void ScalingView::linkMagToGrad()
326 if (m_bLinkMAGtoGRAD && !m_bManagingLinkMagToGrad) {
327 m_bManagingLinkMagToGrad =
true;
328 m_qMapScaleControls[
FIFF_UNIT_T_M]->setValue(m_qMapScaleControls[
FIFF_UNIT_T]->value() / (m_qMapScaleControls[MAG_TO_GRAD_LINK]->value() / 100.f));
329 m_bManagingLinkMagToGrad =
false;
335void ScalingView::linkGradToMag()
337 if (m_bLinkMAGtoGRAD && !m_bManagingLinkMagToGrad) {
338 m_bManagingLinkMagToGrad =
true;
339 m_qMapScaleControls[
FIFF_UNIT_T]->setValue(m_qMapScaleControls[
FIFF_UNIT_T_M]->value() * (m_qMapScaleControls[MAG_TO_GRAD_LINK]->value() / 100.0f));
340 m_bManagingLinkMagToGrad =
false;
346void ScalingView::updateGRADScale(
double dScale)
348 m_qMapChScaling.insert(
FIFF_UNIT_T_M, dScale * m_fScaleGRAD * 100.0);
350 processScalingChange();
355void ScalingView::updateEEGScale(
double dScale)
357 m_qMapChScaling.insert(
FIFFV_EEG_CH, dScale * m_fScaleEEG);
358 processScalingChange();
363void ScalingView::updateEOGScale(
double dScale)
365 m_qMapChScaling.insert(
FIFFV_EOG_CH, dScale * m_fScaleEOG);
366 processScalingChange();
371void ScalingView::updateEMGScale(
double dScale)
373 m_qMapChScaling.insert(
FIFFV_EMG_CH, dScale * m_fScaleEMG);
374 processScalingChange();
379void ScalingView::updateECGScale(
double dScale)
381 m_qMapChScaling.insert(
FIFFV_ECG_CH, dScale * m_fScaleECG);
382 processScalingChange();
387void ScalingView::updateMISCScale(
double dScale)
389 m_qMapChScaling.insert(
FIFFV_MISC_CH, dScale * m_fScaleMISC);
390 processScalingChange();
395void ScalingView::updateSTIMScale(
double scale)
398 processScalingChange();
403void ScalingView::updateMAGtoGRADlink(
double dScale)
412void ScalingView::drawScalingGUI()
423 for (
int c : controls) {
424 if (m_qMapScaleControls.contains(c)) {
425 m_pUi->verticalLayout->insertWidget(i++, m_qMapScaleControls[c].data());
428 createLinkMagGradCheckBox();
435 if (m_qMapScaleControls.contains(MAG_TO_GRAD_LINK)) {
436 m_bLinkMAGtoGRAD = (l == Qt::Checked);
438 m_bLinkMAGtoGRAD =
false;
440 if (m_bLinkMAGtoGRAD) {
441 m_qMapScaleControls[MAG_TO_GRAD_LINK]->setValue(100 * m_qMapScaleControls[
FIFF_UNIT_T]->value() / m_qMapScaleControls[
FIFF_UNIT_T_M]->value());
448void ScalingView::showLinkControl()
450 if (m_qMapScaleControls.contains(MAG_TO_GRAD_LINK)) {
451 m_qMapScaleControls[MAG_TO_GRAD_LINK]->setVisible(m_bLinkMAGtoGRAD);
457void ScalingView::createScaleControls()
460 if (m_qMapChScaling.contains(
FIFF_UNIT_T) && (m_lChannelTypesToShow.contains(
"mag") || m_lChannelTypesToShow.contains(
"all"))) {
461 QPointer<ScaleControl> pControlMAG = QPointer<ScaleControl>(
new ScaleControl(
"MAG [pT])"));
462 pControlMAG->setRange(0.2f, 20.0f);
463 pControlMAG->setMaxSensitivityPoint(1.5);
464 pControlMAG->setValue(m_qMapChScaling[
FIFF_UNIT_T] / m_fScaleMAG);
465 pControlMAG->setSensitivity(0.7f);
466 pControlMAG->invertSlider(
true);
468 m_qMapScaleControls.insert(
FIFF_UNIT_T, pControlMAG);
472 if (m_qMapChScaling.contains(
FIFF_UNIT_T_M) && (m_lChannelTypesToShow.contains(
"grad") || m_lChannelTypesToShow.contains(
"all"))) {
473 QPointer<ScaleControl> pControlGRAD = QPointer<ScaleControl>(
new ScaleControl(
"GRAD [fT/cm]"));
474 pControlGRAD->setRange(30.0f, 5000.0f);
475 pControlGRAD->setMaxSensitivityPoint(100.0f);
476 pControlGRAD->setValue(m_qMapChScaling[
FIFF_UNIT_T_M] / m_fScaleGRAD);
477 pControlGRAD->setSensitivity(0.7f);
478 pControlGRAD->invertSlider(
true);
485 QPointer<ScaleControl> pControlMAGtoGRADlink = QPointer<ScaleControl>(
new ScaleControl(
"MAG-GRAD link [cm]"));
486 pControlMAGtoGRADlink->setRange(0.10f, 8.0f);
487 pControlMAGtoGRADlink->setMaxSensitivityPoint(2.0f);
488 pControlMAGtoGRADlink->setValue(2.0f);
489 pControlMAGtoGRADlink->setSensitivity(0.7f);
491 pControlMAGtoGRADlink->setVisible(m_bLinkMAGtoGRAD);
492 m_qMapScaleControls.insert(MAG_TO_GRAD_LINK, pControlMAGtoGRADlink);
496 if (m_qMapChScaling.contains(
FIFFV_EEG_CH) && (m_lChannelTypesToShow.contains(
"eeg") || m_lChannelTypesToShow.contains(
"all"))) {
497 QPointer<ScaleControl> pControlEEG = QPointer<ScaleControl>(
new ScaleControl(
"EEG [uV]"));
498 pControlEEG->setRange(3.0f, 100.0f);
499 pControlEEG->setMaxSensitivityPoint(14.0f);
500 pControlEEG->setValue(m_qMapChScaling[
FIFFV_EEG_CH] / m_fScaleEEG);
501 pControlEEG->setSensitivity(0.4f);
502 pControlEEG->invertSlider(
true);
508 if (m_qMapChScaling.contains(
FIFFV_EOG_CH) && (m_lChannelTypesToShow.contains(
"eog") || m_lChannelTypesToShow.contains(
"all"))) {
509 QPointer<ScaleControl> pControlEOG = QPointer<ScaleControl>(
new ScaleControl(
"EOG [uV]"));
510 pControlEOG->setRange(3.0f, 100.0f);
511 pControlEOG->setMaxSensitivityPoint(14.0f);
512 pControlEOG->setValue(m_qMapChScaling[
FIFFV_EOG_CH] / m_fScaleEOG);
513 pControlEOG->setSensitivity(0.4f);
514 pControlEOG->invertSlider(
true);
520 if (m_qMapChScaling.contains(
FIFFV_ECG_CH) && (m_lChannelTypesToShow.contains(
"ecg") || m_lChannelTypesToShow.contains(
"all"))) {
521 QPointer<ScaleControl> pControlECG = QPointer<ScaleControl>(
new ScaleControl(
"ECG [uV]"));
522 pControlECG->setRange(3.0f, 100.0f);
523 pControlECG->setMaxSensitivityPoint(14.0f);
524 pControlECG->setValue(m_qMapChScaling[
FIFFV_ECG_CH] / m_fScaleECG);
525 pControlECG->setSensitivity(0.4f);
526 pControlECG->invertSlider(
true);
532 if (m_qMapChScaling.contains(
FIFFV_STIM_CH) && (m_lChannelTypesToShow.contains(
"stim") || m_lChannelTypesToShow.contains(
"all"))) {
533 QPointer<ScaleControl> pControlSTIM = QPointer<ScaleControl>(
new ScaleControl(
"STIM"));
534 pControlSTIM->setRange(1.0f, 99999.0f);
535 pControlSTIM->setMaxSensitivityPoint(5000.0f);
536 pControlSTIM->setValue(m_qMapChScaling[
FIFFV_STIM_CH] / m_fScaleSTIM);
537 pControlSTIM->setSensitivity(0.8f);
538 pControlSTIM->invertSlider(
true);
544 if (m_qMapChScaling.contains(
FIFFV_MISC_CH) && (m_lChannelTypesToShow.contains(
"misc") || m_lChannelTypesToShow.contains(
"all"))) {
545 QPointer<ScaleControl> pControlMISC = QPointer<ScaleControl>(
new ScaleControl(
"MISC"));
546 pControlMISC->setRange(3.0f, 100.0f);
547 pControlMISC->setMaxSensitivityPoint(14.0f);
548 pControlMISC->setValue(m_qMapChScaling[
FIFFV_MISC_CH] / m_fScaleMISC);
549 pControlMISC->setSensitivity(0.4f);
550 pControlMISC->invertSlider(
true);
564void ScalingView::createLinkMagGradCheckBox()
566 m_pCheckBox = QPointer<QCheckBox>(
new QCheckBox(
"Link MAGs -> GRADs"));
567 m_pCheckBox->setChecked(m_bLinkMAGtoGRAD);
569 m_pUi->verticalLayout->addWidget(m_pCheckBox);
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
Per-modality vertical-scale spinbox panel (one spin per channel type).
Composite slider + spinbox widget for picking a (possibly logarithmic) scale value.
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