MNE-CPP  0.1.9
A Framework for Electrophysiology
modalityselectionview.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //=============================================================================================================
37 // INCLUDES
38 //=============================================================================================================
39 
40 #include "modalityselectionview.h"
41 
42 //=============================================================================================================
43 // QT INCLUDES
44 //=============================================================================================================
45 
46 #include <QGridLayout>
47 #include <QCheckBox>
48 #include <QLabel>
49 #include <QSettings>
50 #include <QMapIterator>
51 
52 //=============================================================================================================
53 // EIGEN INCLUDES
54 //=============================================================================================================
55 
56 //=============================================================================================================
57 // USED NAMESPACES
58 //=============================================================================================================
59 
60 using namespace DISPLIB;
61 
62 //=============================================================================================================
63 // DEFINE MEMBER METHODS
64 //=============================================================================================================
65 
66 ModalitySelectionView::ModalitySelectionView(const QList<FIFFLIB::FiffChInfo>& lChannelList,
67  const QString &sSettingsPath,
68  QWidget *parent,
69  Qt::WindowFlags f)
70 : AbstractView(parent, f)
71 {
72  m_sSettingsPath = sSettingsPath;
73  this->setWindowTitle("Modality Selection");
74  this->setMinimumWidth(330);
75  this->setMaximumWidth(330);
76 
77  // Specify which channel types are needed
78  for(int i = 0; i < lChannelList.size(); ++i) {
79  if(lChannelList.at(i).unit == FIFF_UNIT_T && !m_lChannelTypeList.contains("MAG")) {
80  m_lChannelTypeList << "MAG";
81  }
82  if(lChannelList.at(i).unit == FIFF_UNIT_T_M && !m_lChannelTypeList.contains("GRAD")) {
83  m_lChannelTypeList << "GRAD";
84  }
85  if(lChannelList.at(i).kind == FIFFV_EEG_CH && !m_lChannelTypeList.contains("EEG")) {
86  m_lChannelTypeList << "EEG";
87  }
88  if(lChannelList.at(i).kind == FIFFV_EOG_CH && !m_lChannelTypeList.contains("EOG")) {
89  m_lChannelTypeList << "EOG";
90  }
91  if(lChannelList.at(i).kind == FIFFV_STIM_CH && !m_lChannelTypeList.contains("STIM")) {
92  m_lChannelTypeList << "STIM";
93  }
94  if(lChannelList.at(i).kind == FIFFV_MISC_CH && !m_lChannelTypeList.contains("MISC")) {
95  m_lChannelTypeList << "MISC";
96  }
97  }
98 
99  loadSettings();
100  redrawGUI();
101 }
102 
103 //=============================================================================================================
104 
106 {
107  saveSettings();
108 }
109 
110 //=============================================================================================================
111 
113 {
114  return m_modalityMap;
115 }
116 
117 //=============================================================================================================
118 
120 {
121  if(m_sSettingsPath.isEmpty()) {
122  return;
123  }
124 
125  QSettings settings("MNECPP");
126 
127  if(m_modalityMap.contains("MAG")) {
128  settings.setValue(m_sSettingsPath + QString("/ModalitySelectionView/modalityMAG"), m_modalityMap["MAG"]);
129  }
130  if(m_modalityMap.contains("GRAD")) {
131  settings.setValue(m_sSettingsPath + QString("/ModalitySelectionView/modalityGRAD"), m_modalityMap["GRAD"]);
132  }
133  if(m_modalityMap.contains("EEG")) {
134  settings.setValue(m_sSettingsPath + QString("/ModalitySelectionView/modalityEEG"), m_modalityMap["EEG"]);
135  }
136  if(m_modalityMap.contains("EOG")) {
137  settings.setValue(m_sSettingsPath + QString("/ModalitySelectionView/modalityEOG"), m_modalityMap["EOG"]);
138  }
139  if(m_modalityMap.contains("STIM")) {
140  settings.setValue(m_sSettingsPath + QString("/ModalitySelectionView/modalitySTIM"), m_modalityMap["STIM"]);
141  }
142  if(m_modalityMap.contains("MISC")) {
143  settings.setValue(m_sSettingsPath + QString("/ModalitySelectionView/modalityMISC"), m_modalityMap["MISC"]);
144  }
145 }
146 
147 //=============================================================================================================
148 
150 {
151  if(m_sSettingsPath.isEmpty()) {
152  return;
153  }
154 
155  QSettings settings("MNECPP");
156 
157  bool flag = settings.value(m_sSettingsPath + QString("/ModalitySelectionView/modalityMAG"), true).toBool();
158  m_modalityMap.insert("MAG", flag);
159 
160  flag = settings.value(m_sSettingsPath + QString("/ModalitySelectionView/modalityGRAD"), true).toBool();
161  m_modalityMap.insert("GRAD", flag);
162 
163  flag = settings.value(m_sSettingsPath + QString("/ModalitySelectionView/modalityEEG"), true).toBool();
164  m_modalityMap.insert("EEG", flag);
165 
166  flag = settings.value(m_sSettingsPath + QString("/ModalitySelectionView/modalityEOG"), true).toBool();
167  m_modalityMap.insert("EOG", flag);
168 
169  flag = settings.value(m_sSettingsPath + QString("/ModalitySelectionView/modalitySTIM"), true).toBool();
170  m_modalityMap.insert("STIM", flag);
171 
172  flag = settings.value(m_sSettingsPath + QString("/ModalitySelectionView/modalityMISC"), true).toBool();
173  m_modalityMap.insert("MISC", flag);
174 }
175 
176 //=============================================================================================================
177 
179 {
180  switch(mode) {
181  case GuiMode::Clinical:
182  break;
183  default: // default is research mode
184  break;
185  }
186 }
187 
188 //=============================================================================================================
189 
191 {
192  switch(mode) {
193  case ProcessingMode::Offline:
194  break;
195  default: // default is realtime mode
196  break;
197  }
198 }
199 
200 //=============================================================================================================
201 
202 void ModalitySelectionView::setModalityMap(const QMap<QString, bool> &modalityMap)
203 {
204  m_modalityMap = modalityMap;
205 
206  redrawGUI();
207 }
208 
209 //=============================================================================================================
210 
212 {
213  m_qListModalityCheckBox.clear();
214 
215  //Delete all widgets in the averages layout
216  QGridLayout* topLayout = static_cast<QGridLayout*>(this->layout());
217  if(!topLayout) {
218  topLayout = new QGridLayout();
219  }
220 
221  QLayoutItem *child;
222  while ((child = topLayout->takeAt(0)) != 0) {
223  delete child->widget();
224  delete child;
225  }
226 
227  QMapIterator<QString, bool> i(m_modalityMap);
228 
229  int count = 0;
230  while (i.hasNext()) {
231  i.next();
232 
233  if(m_lChannelTypeList.contains(i.key(), Qt::CaseInsensitive)) {
234  QCheckBox* t_pCheckBoxModality = new QCheckBox(i.key());
235  t_pCheckBoxModality->setChecked(i.value());
236  m_qListModalityCheckBox << t_pCheckBoxModality;
237  connect(t_pCheckBoxModality,&QCheckBox::stateChanged,
239  topLayout->addWidget(t_pCheckBoxModality,count,0);
240  count++;
241  }
242  }
243 
244  //Find Modalities tab and add current layout
245  this->setLayout(topLayout);
246 }
247 
248 //=============================================================================================================
249 
251 {
252  Q_UNUSED(state)
253 
254  for(qint32 i = 0; i < m_qListModalityCheckBox.size(); ++i) {
255  m_modalityMap[m_qListModalityCheckBox.at(i)->text()] = m_qListModalityCheckBox.at(i)->isChecked();
256  }
257 
259 
260  saveSettings();
261 }
262 
263 //=============================================================================================================
264 
266 {
267 
268 }
DISPLIB::ModalitySelectionView::redrawGUI
void redrawGUI()
Definition: modalityselectionview.cpp:211
DISPLIB::AbstractView
The AbstractView class provides the base calss for all Disp viewers.
Definition: abstractview.h:75
DISPLIB::ModalitySelectionView::loadSettings
void loadSettings()
Definition: modalityselectionview.cpp:149
DISPLIB::ModalitySelectionView::modalitiesChanged
void modalitiesChanged(const QMap< QString, bool > &modalityMap)
modalityselectionview.h
Declaration of the ModalitySelectionView Class.
DISPLIB::ModalitySelectionView::m_sSettingsPath
QString m_sSettingsPath
Definition: modalityselectionview.h:174
DISPLIB::ModalitySelectionView::updateGuiMode
void updateGuiMode(GuiMode mode)
Definition: modalityselectionview.cpp:178
DISPLIB::ModalitySelectionView::m_modalityMap
QMap< QString, bool > m_modalityMap
Definition: modalityselectionview.h:169
DISPLIB::ModalitySelectionView::saveSettings
void saveSettings()
Definition: modalityselectionview.cpp:119
DISPLIB::ModalitySelectionView::~ModalitySelectionView
~ModalitySelectionView()
Definition: modalityselectionview.cpp:105
DISPLIB::ModalitySelectionView::clearView
void clearView()
Definition: modalityselectionview.cpp:265
DISPLIB::ModalitySelectionView::m_lChannelTypeList
QStringList m_lChannelTypeList
Definition: modalityselectionview.h:172
DISPLIB::ModalitySelectionView::setModalityMap
void setModalityMap(const QMap< QString, bool > &modalityMap)
Definition: modalityselectionview.cpp:202
DISPLIB::ModalitySelectionView::updateProcessingMode
void updateProcessingMode(ProcessingMode mode)
Definition: modalityselectionview.cpp:190
DISPLIB::ModalitySelectionView::ModalitySelectionView
ModalitySelectionView(const QList< FIFFLIB::FiffChInfo > &lChannelList, const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
Definition: modalityselectionview.cpp:66
DISPLIB::ModalitySelectionView::m_qListModalityCheckBox
QList< QCheckBox * > m_qListModalityCheckBox
Definition: modalityselectionview.h:170
DISPLIB::ModalitySelectionView::onUpdateModalityCheckbox
void onUpdateModalityCheckbox(qint32 state)
Definition: modalityselectionview.cpp:250
DISPLIB::ModalitySelectionView::getModalityMap
QMap< QString, bool > getModalityMap()
Definition: modalityselectionview.cpp:112