MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
fwdsettingsview.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "fwdsettingsview.h"
40#include "QtWidgets/qspinbox.h"
41#include "ui_fwdsettingsview.h"
42
43#include <fs/annotationset.h>
44
45//=============================================================================================================
46// QT INCLUDES
47//=============================================================================================================
48
49#include <QFileInfo>
50#include <QFileDialog>
51#include <QMessageBox>
52#include <QSettings>
53
54//=============================================================================================================
55// EIGEN INCLUDES
56//=============================================================================================================
57
58//=============================================================================================================
59// USED NAMESPACES
60//=============================================================================================================
61
62using namespace DISPLIB;
63using namespace FSLIB;
64
65//=============================================================================================================
66// DEFINE GLOBAL METHODS
67//=============================================================================================================
68
69//=============================================================================================================
70// DEFINE MEMBER METHODS
71//=============================================================================================================
72
73FwdSettingsView::FwdSettingsView(const QString& sSettingsPath,
74 QWidget *parent,
75 Qt::WindowFlags f)
76: AbstractView(parent, f)
77, m_bAnnotaionsLoaded(false)
78, m_pUi(new Ui::FwdSettingsViewWidget)
79{
80 m_sSettingsPath = sSettingsPath;
81 m_pUi->setupUi(this);
82
83 // init
84 m_pUi->m_checkBox_bDoRecomputation->setChecked(false);
85 m_pUi->m_checkBox_bDoClustering->setChecked(true);
86 m_pUi->m_lineEdit_iNChan->setText(QString::number(0));
87 m_pUi->m_lineEdit_iNSourceSpace->setText(QString::number(0));
88 m_pUi->m_lineEdit_iNDipole->setText(QString::number(0));
89 m_pUi->m_lineEdit_sSourceOri->setText("fixed");
90 m_pUi->m_lineEdit_sCoordFrame->setText("Head Space");
91 m_pUi->m_lineEdit_iNDipoleClustered->setText("Not Clustered");
92 m_pUi->m_spinBox_iNDipoleClustered->setValue(200);
93 m_pUi->m_spinBox_iNDipoleClustered->setKeyboardTracking(false);
94
95 // load init annotation set
96 QString t_sAtlasDir = QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects/sample/label";
97 m_pUi->m_qLineEdit_AtlasDirName->setText(t_sAtlasDir);
98
99 AnnotationSet::SPtr t_pAnnotationSet = AnnotationSet::SPtr(new AnnotationSet(t_sAtlasDir+"/lh.aparc.a2009s.annot", t_sAtlasDir+"/rh.aparc.a2009s.annot"));
100
101 if(!t_pAnnotationSet->isEmpty() && t_pAnnotationSet->size() == 2)
102 {
103 emit atlasDirChanged(t_sAtlasDir,t_pAnnotationSet);
104 m_pUi->m_qLabel_atlasStat->setText("loaded");
105 m_bAnnotaionsLoaded = true;
106 }
107 else
108 {
109 m_pUi->m_qLabel_atlasStat->setText("not loaded");
110 }
111
112 // connect
113 connect(m_pUi->m_checkBox_bDoRecomputation, &QCheckBox::clicked,
115 connect(m_pUi->m_qPushButton_AtlasDirDialog, &QPushButton::released,
117 connect(m_pUi->m_checkBox_bDoClustering, &QCheckBox::clicked,
119 connect(m_pUi->m_qPushButton_ComputeForward, &QPushButton::clicked,
121 connect(m_pUi->m_spinBox_iNDipoleClustered, QOverload<int>::of(&QSpinBox::valueChanged),
123
124 // load settings
125 loadSettings();
126}
127
128//=============================================================================================================
129
130FwdSettingsView::~FwdSettingsView()
131{
132 saveSettings();
133
134 delete m_pUi;
135}
136
137//=============================================================================================================
138
140{
141 if(m_sSettingsPath.isEmpty()) {
142 return;
143 }
144
145 QSettings settings("MNECPP");
146 QVariant data;
147}
148
149//=============================================================================================================
150
152{
153 if(m_sSettingsPath.isEmpty()) {
154 return;
155 }
156
157 QSettings settings("MNECPP");
158 QVariant defaultData;
159}
160
161//=============================================================================================================
162
164{
165 switch(mode) {
166 case GuiMode::Clinical:
167 break;
168 default: // default is research mode
169 break;
170 }
171}
172
173//=============================================================================================================
174
176{
177 switch(mode) {
178 case ProcessingMode::Offline:
179 break;
180 default: // default is realtime mode
181 break;
182 }
183}
184
185//=============================================================================================================
186
188{
189 return m_pUi->m_checkBox_bDoRecomputation->isChecked();
190}
191
192//=============================================================================================================
193
195{
196 if(iStatus == 0) {
197 m_pUi->m_label_recomputationFeedback->setText("Initializing");
198 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
199 } else if(iStatus == 1) {
200 m_pUi->m_label_recomputationFeedback->setText("Computing");
201 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
202 } else if (iStatus == 2) {
203 m_pUi->m_label_recomputationFeedback->setText("Recomputing");
204 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
205 } else if (iStatus == 3) {
206 m_pUi->m_label_recomputationFeedback->setText("Clustering");
207 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
208 } else if (iStatus == 4) {
209 m_pUi->m_label_recomputationFeedback->setText("Not Computed");
210 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
211 } else if (iStatus == 5) {
212 m_pUi->m_label_recomputationFeedback->setText("Not Clustered");
213 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : yellow;}");
214 } else {
215 m_pUi->m_label_recomputationFeedback->setText("Finished");
216 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : green;}");
217 }
218}
219
220//=============================================================================================================
221
222void FwdSettingsView::setSolutionInformation(FIFFLIB::fiff_int_t iSourceOri,
223 FIFFLIB::fiff_int_t iCoordFrame,
224 int iNSource,
225 int iNChan,
226 int iNSpaces)
227{
228 // set source orientation
229 if(iSourceOri == 0) {
230 m_pUi->m_lineEdit_sSourceOri->setText("fixed");
231 } else {
232 m_pUi->m_lineEdit_sSourceOri->setText("free");
233 }
234
235 // set coordinate frame
236 if(iCoordFrame == FIFFV_COORD_HEAD) {
237 m_pUi->m_lineEdit_sCoordFrame->setText("Head Space");
238 } else if (iCoordFrame == FIFFV_COORD_MRI){
239 m_pUi->m_lineEdit_sCoordFrame->setText("MRI Space");
240 } else {
241 m_pUi->m_lineEdit_sCoordFrame->setText("Unknown");
242 }
243
244 // set number of sources
245 m_pUi->m_lineEdit_iNDipole->setText(QString::number(iNSource));
246
247 // set number of clustered sources
248 m_pUi->m_lineEdit_iNDipoleClustered->setText("Not clustered");
249
250 // set number of channels
251 m_pUi->m_lineEdit_iNChan->setText(QString::number(iNChan));
252
253 // set number of source spaces
254 m_pUi->m_lineEdit_iNSourceSpace->setText(QString::number(iNSpaces));
255}
256
257//=============================================================================================================
258
260{
261 return m_pUi->m_checkBox_bDoClustering->isChecked();
262}
263
264//=============================================================================================================
265
267{
268 return m_pUi->m_spinBox_iNDipoleClustered->value();
269}
270
271//=============================================================================================================
272
274{
276 QMessageBox msgBox;
277 msgBox.setText("Please load an annotation set before clustering.");
278 msgBox.exec();
279 m_pUi->m_checkBox_bDoClustering->setChecked(false);
280 return;
281 } else {
282 emit clusteringStatusChanged(bChecked);
283 }
284}
285
286//=============================================================================================================
287
289{
290 // set number of clustered sources
291 m_pUi->m_lineEdit_iNDipoleClustered->setText(QString::number(iNSources));
292}
293
294//=============================================================================================================
295
297{
298 QString t_sAtlasDir = QFileDialog::getExistingDirectory(this, tr("Open Atlas Directory"),
299 QCoreApplication::applicationDirPath(),
300 QFileDialog::ShowDirsOnly
301 | QFileDialog::DontResolveSymlinks);
302
303 m_pUi->m_qLineEdit_AtlasDirName->setText(t_sAtlasDir);
304
305 AnnotationSet::SPtr t_pAnnotationSet = AnnotationSet::SPtr(new AnnotationSet(t_sAtlasDir+"/lh.aparc.a2009s.annot", t_sAtlasDir+"/rh.aparc.a2009s.annot"));
306
307 if(!t_pAnnotationSet->isEmpty() && t_pAnnotationSet->size() == 2)
308 {
309 emit atlasDirChanged(t_sAtlasDir,t_pAnnotationSet);
310 m_pUi->m_qLabel_atlasStat->setText("loaded");
311 m_bAnnotaionsLoaded = true;
312 }
313 else
314 {
315 m_pUi->m_qLabel_atlasStat->setText("not loaded");
316 }
317}
318
319//=============================================================================================================
320
322{
323
324}
FwdSettingsView class declaration.
AnnotationSet class declaration.
The AbstractView class provides the base calss for all Disp viewers.
void setSolutionInformation(FIFFLIB::fiff_int_t iSourceOri, FIFFLIB::fiff_int_t iCoordFrame, int iNSource, int iNChan, int iNSpaces)
void setClusteredInformation(int iNSource)
Ui::FwdSettingsViewWidget * m_pUi
void atlasDirChanged(const QString &sDirPath, const FSLIB::AnnotationSet::SPtr pAnnotationSet)
void clusterNumberChanged(int iNCluster)
void setRecomputationStatus(int iStatus)
void updateProcessingMode(ProcessingMode mode)
void clusteringStatusChanged(bool bChecked)
void recompStatusChanged(bool bChecked)
void onClusteringStatusChanged(bool bChecked)
void updateGuiMode(GuiMode mode)
FwdSettingsView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
Annotation set.
QSharedPointer< AnnotationSet > SPtr