MNE-CPP  beta 1.0
scalewindow.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "scalewindow.h"
43 
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // USED NAMESPACES
48 //=============================================================================================================
49 
50 using namespace MNEBrowseRawQt;
51 
52 
53 //*************************************************************************************************************
54 //=============================================================================================================
55 // DEFINE MEMBER METHODS
56 //=============================================================================================================
57 
58 ScaleWindow::ScaleWindow(QWidget *parent) :
59  QDockWidget(parent),
60  ui(new Ui::ScaleWindow)
61 {
62  ui->setupUi(this);
63 }
64 
65 
66 //*************************************************************************************************************
67 
69 {
70  delete ui;
71 }
72 
73 
74 //*************************************************************************************************************
75 
77 {
78  //Connect data scaling spin boxes
79  connect(ui->m_doubleSpinBox_MEG_grad,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
80  this,&ScaleWindow::scaleChannelValueChanged);
81  connect(ui->m_doubleSpinBox_MEG_mag,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
82  this,&ScaleWindow::scaleChannelValueChanged);
83  connect(ui->m_doubleSpinBox_EEG,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
84  this,&ScaleWindow::scaleChannelValueChanged);
85  connect(ui->m_doubleSpinBox_EOG,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
86  this,&ScaleWindow::scaleChannelValueChanged);
87  connect(ui->m_doubleSpinBox_EMG,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
88  this,&ScaleWindow::scaleChannelValueChanged);
89  connect(ui->m_doubleSpinBox_ECG,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
90  this,&ScaleWindow::scaleChannelValueChanged);
91  connect(ui->m_doubleSpinBox_MISC,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
92  this,&ScaleWindow::scaleChannelValueChanged);
93  connect(ui->m_doubleSpinBox_STIM,static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
94  this,&ScaleWindow::scaleChannelValueChanged);
95 
96  //Connect view scaling spin boxes
97  connect(ui->m_SpinBox_channelHeight,static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
98  this,&ScaleWindow::scaleViewValueChanged);
99 }
100 
101 
102 //*************************************************************************************************************
103 
104 QMap<QString,double> ScaleWindow::genereateScalingMap()
105 {
106  QMap<QString,double> scaleMap;
107 
108  scaleMap["MEG_grad"] = ui->m_doubleSpinBox_MEG_grad->value() * 1e-15 * 100; //*100 because data in fiff files is stored as fT/m not fT/cm
109  scaleMap["MEG_mag"] = ui->m_doubleSpinBox_MEG_mag->value() * 1e-12;
110  scaleMap["MEG_EEG"] = ui->m_doubleSpinBox_EEG->value() * 1e-06;
111  scaleMap["MEG_EOG"] = ui->m_doubleSpinBox_EOG->value() * 1e-06;
112  scaleMap["MEG_EMG"] = ui->m_doubleSpinBox_EMG->value() * 1e-03;
113  scaleMap["MEG_ECG"] = ui->m_doubleSpinBox_ECG->value() * 1e-03;
114  scaleMap["MEG_MISC"] = ui->m_doubleSpinBox_MISC->value() * 1;
115  scaleMap["MEG_STIM"] = ui->m_doubleSpinBox_STIM->value() * 1;
116 
117  return scaleMap;
118 }
119 
120 
121 //*************************************************************************************************************
122 
124 {
125  //Hide all spin boxes and labels
126  ui->m_doubleSpinBox_MEG_grad->hide();
127  ui->m_doubleSpinBox_MEG_mag->hide();
128  ui->m_doubleSpinBox_EEG->hide();
129  ui->m_doubleSpinBox_EOG->hide();
130  ui->m_doubleSpinBox_EMG->hide();
131  ui->m_doubleSpinBox_ECG->hide();
132  ui->m_doubleSpinBox_MISC->hide();
133  ui->m_doubleSpinBox_STIM->hide();
134 
135  ui->m_label_MEG_grad->hide();
136  ui->m_label_MEG_mag->hide();
137  ui->m_label_EEG->hide();
138  ui->m_label_EOG->hide();
139  ui->m_label_EMG->hide();
140  ui->m_label_ECG->hide();
141  ui->m_label_MISC->hide();
142  ui->m_label_STIM->hide();
143 
144  //Show only spin boxes and labels which type are present in the current loaded fiffinfo
145  QList<FiffChInfo> channelList = currentFiffInfo.chs;
146  for(int i = 0; i<channelList.size(); i++) {
147  switch(channelList.at(i).kind) {
148  case FIFFV_MEG_CH: {
149  qint32 unit = channelList.at(i).unit;
150  if(unit == FIFF_UNIT_T_M) {
151  //Gradiometers
152  ui->m_doubleSpinBox_MEG_grad->show();
153  ui->m_label_MEG_grad->show();
154  }
155  else if(unit == FIFF_UNIT_T) {
156  //Magnitometers
157  ui->m_doubleSpinBox_MEG_mag->show();
158  ui->m_label_MEG_mag->show();
159  }
160 
161  break;
162  }
163 
164  case FIFFV_EEG_CH: {
165  ui->m_label_EEG->show();
166  ui->m_doubleSpinBox_EEG->show();
167  break;
168  }
169 
170  case FIFFV_EOG_CH: {
171  ui->m_label_EOG->show();
172  ui->m_doubleSpinBox_EOG->show();
173  break;
174  }
175 
176  case FIFFV_EMG_CH: {
177  ui->m_label_EMG->show();
178  ui->m_doubleSpinBox_EMG->show();
179  break;
180  }
181 
182  case FIFFV_ECG_CH: {
183  ui->m_label_ECG->show();
184  ui->m_doubleSpinBox_ECG->show();
185  break;
186  }
187 
188  case FIFFV_MISC_CH: {
189  ui->m_label_MISC->show();
190  ui->m_doubleSpinBox_MISC->show();
191  break;
192  }
193 
194  case FIFFV_STIM_CH: {
195  ui->m_label_STIM->show();
196  ui->m_doubleSpinBox_STIM->show();
197  break;
198  }
199 
200  }
201  }
202 }
203 
204 
205 //*************************************************************************************************************
206 
207 void ScaleWindow::scaleAllChannels(double scaleValue)
208 {
209  qDebug()<<scaleValue;
210 
211  scaleValue = (scaleValue - 1)*-4;
212 
213  ui->m_doubleSpinBox_MEG_grad->setValue((scaleValue*ui->m_doubleSpinBox_MEG_grad->singleStep()) + ui->m_doubleSpinBox_MEG_grad->value());
214  ui->m_doubleSpinBox_MEG_mag->setValue((scaleValue*ui->m_doubleSpinBox_MEG_mag->singleStep()) + ui->m_doubleSpinBox_MEG_mag->value());
215  ui->m_doubleSpinBox_EEG->setValue((scaleValue*ui->m_doubleSpinBox_EEG->singleStep()) + ui->m_doubleSpinBox_EEG->value());
216  ui->m_doubleSpinBox_EOG->setValue((scaleValue*ui->m_doubleSpinBox_EOG->singleStep()) + ui->m_doubleSpinBox_EOG->value());
217  ui->m_doubleSpinBox_EMG->setValue((scaleValue*ui->m_doubleSpinBox_EMG->singleStep()) + ui->m_doubleSpinBox_EMG->value());
218  ui->m_doubleSpinBox_ECG->setValue((scaleValue*ui->m_doubleSpinBox_ECG->singleStep()) + ui->m_doubleSpinBox_ECG->value());
219  ui->m_doubleSpinBox_MISC->setValue((scaleValue*ui->m_doubleSpinBox_MISC->singleStep()) + ui->m_doubleSpinBox_MISC->value());
220  ui->m_doubleSpinBox_STIM->setValue((scaleValue*ui->m_doubleSpinBox_STIM->singleStep()) + ui->m_doubleSpinBox_STIM->value());
221 }
222 
223 
224 //*************************************************************************************************************
225 
226 void ScaleWindow::scaleChannelValueChanged()
227 {
228  emit scalingChannelValueChanged(genereateScalingMap());
229 }
230 
231 
232 //*************************************************************************************************************
233 
234 void ScaleWindow::scaleViewValueChanged()
235 {
236  emit scalingViewValueChanged(ui->m_SpinBox_channelHeight->value());
237 }
FIFF measurement file information.
Definition: fiff_info.h:96
Definition: aboutwindow.h:52
void scaleAllChannels(double scaleValue)
void scalingChannelValueChanged(QMap< QString, double >)
#define FIFF_UNIT_T_M
QList< FiffChInfo > chs
ScaleWindow(QWidget *parent=0)
Definition: scalewindow.cpp:58
void hideSpinBoxes(FiffInfo currentFiffInfo)
The ScaleWindow class provides the scale window.
Definition: scalewindow.h:84
Contains the declaration of the ScaleWindow class.