v2.0.0
Loading...
Searching...
No Matches
fwdsettingsview.cpp
Go to the documentation of this file.
1//=============================================================================================================
16
17//=============================================================================================================
18// INCLUDES
19//=============================================================================================================
20
21#include "fwdsettingsview.h"
22#include "QtWidgets/qspinbox.h"
23#include "ui_fwdsettingsview.h"
24
25#include <fs/fs_annotationset.h>
26
27//=============================================================================================================
28// QT INCLUDES
29//=============================================================================================================
30
31#include <QFileInfo>
32#include <QFileDialog>
33#include <QMessageBox>
34#include <QSettings>
35
36//=============================================================================================================
37// EIGEN INCLUDES
38//=============================================================================================================
39
40//=============================================================================================================
41// USED NAMESPACES
42//=============================================================================================================
43
44using namespace DISPLIB;
45using namespace FSLIB;
46
47//=============================================================================================================
48// DEFINE GLOBAL METHODS
49//=============================================================================================================
50
51//=============================================================================================================
52// DEFINE MEMBER METHODS
53//=============================================================================================================
54
55FwdSettingsView::FwdSettingsView(const QString& sSettingsPath,
56 QWidget* parent,
57 Qt::WindowFlags f)
58: AbstractView(parent, f)
60, m_pUi(new Ui::FwdSettingsViewWidget)
61{
62 m_sSettingsPath = sSettingsPath;
63 m_pUi->setupUi(this);
64
65 // init
66 m_pUi->m_checkBox_bDoRecomputation->setChecked(false);
67 m_pUi->m_checkBox_bDoClustering->setChecked(true);
68 m_pUi->m_lineEdit_iNChan->setText(QString::number(0));
69 m_pUi->m_lineEdit_iNSourceSpace->setText(QString::number(0));
70 m_pUi->m_lineEdit_iNDipole->setText(QString::number(0));
71 m_pUi->m_lineEdit_sSourceOri->setText("fixed");
72 m_pUi->m_lineEdit_sCoordFrame->setText("Head Space");
73 m_pUi->m_lineEdit_iNDipoleClustered->setText("Not Clustered");
74 m_pUi->m_spinBox_iNDipoleClustered->setValue(200);
75 m_pUi->m_spinBox_iNDipoleClustered->setKeyboardTracking(false);
76
77 // load init annotation set
78 QString t_sAtlasDir = QCoreApplication::applicationDirPath() + "/../resources/data/MNE-sample-data/subjects/sample/label";
79 m_pUi->m_qLineEdit_AtlasDirName->setText(t_sAtlasDir);
80
81 FsAnnotationSet::SPtr t_pAnnotationSet = FsAnnotationSet::SPtr(new FsAnnotationSet(t_sAtlasDir + "/lh.aparc.a2009s.annot", t_sAtlasDir + "/rh.aparc.a2009s.annot"));
82
83 // No atlasDirChanged() here: nothing can be connected to it during construction
84 if (!t_pAnnotationSet->isEmpty() && t_pAnnotationSet->size() == 2) {
85 m_pUi->m_qLabel_atlasStat->setText("loaded");
87 } else {
88 m_pUi->m_qLabel_atlasStat->setText("not loaded");
89 }
90
91 // connect
92 connect(m_pUi->m_checkBox_bDoRecomputation, &QCheckBox::clicked,
94 connect(m_pUi->m_qPushButton_AtlasDirDialog, &QPushButton::released,
96 connect(m_pUi->m_checkBox_bDoClustering, &QCheckBox::clicked,
98 connect(m_pUi->m_qPushButton_ComputeForward, &QPushButton::clicked,
100 connect(m_pUi->m_spinBox_iNDipoleClustered, QOverload<int>::of(&QSpinBox::valueChanged),
102
103 // load settings
104 loadSettings();
105}
106
107//=============================================================================================================
108
110{
111 saveSettings();
112
113 delete m_pUi;
114}
115
116//=============================================================================================================
117
119{
120 if (m_sSettingsPath.isEmpty()) {
121 return;
122 }
123
124 QSettings settings("MNECPP");
125}
126
127//=============================================================================================================
128
130{
131 if (m_sSettingsPath.isEmpty()) {
132 return;
133 }
134
135 QSettings settings("MNECPP");
136 QVariant defaultData;
137}
138
139//=============================================================================================================
140
142{
143 switch (mode) {
145 break;
146 default: // default is research mode
147 break;
148 }
149}
150
151//=============================================================================================================
152
154{
155 switch (mode) {
157 break;
158 default: // default is realtime mode
159 break;
160 }
161}
162
163//=============================================================================================================
164
166{
167 return m_pUi->m_checkBox_bDoRecomputation->isChecked();
168}
169
170//=============================================================================================================
171
173{
174 if (iStatus == 0) {
175 m_pUi->m_label_recomputationFeedback->setText("Initializing");
176 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
177 } else if (iStatus == 1) {
178 m_pUi->m_label_recomputationFeedback->setText("Computing");
179 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
180 } else if (iStatus == 2) {
181 m_pUi->m_label_recomputationFeedback->setText("Recomputing");
182 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
183 } else if (iStatus == 3) {
184 m_pUi->m_label_recomputationFeedback->setText("Clustering");
185 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
186 } else if (iStatus == 4) {
187 m_pUi->m_label_recomputationFeedback->setText("Not Computed");
188 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : red;}");
189 } else if (iStatus == 5) {
190 m_pUi->m_label_recomputationFeedback->setText("Not Clustered");
191 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : yellow;}");
192 } else {
193 m_pUi->m_label_recomputationFeedback->setText("Finished");
194 m_pUi->m_label_recomputationFeedback->setStyleSheet("QLabel { background-color : green;}");
195 }
196}
197
198//=============================================================================================================
199
201 FIFFLIB::fiff_int_t iCoordFrame,
202 int iNSource,
203 int iNChan,
204 int iNSpaces)
205{
206 // set source orientation
207 if (iSourceOri == 0) {
208 m_pUi->m_lineEdit_sSourceOri->setText("fixed");
209 } else {
210 m_pUi->m_lineEdit_sSourceOri->setText("free");
211 }
212
213 // set coordinate frame
214 if (iCoordFrame == FIFFV_COORD_HEAD) {
215 m_pUi->m_lineEdit_sCoordFrame->setText("Head Space");
216 } else if (iCoordFrame == FIFFV_COORD_MRI) {
217 m_pUi->m_lineEdit_sCoordFrame->setText("MRI Space");
218 } else {
219 m_pUi->m_lineEdit_sCoordFrame->setText("Unknown");
220 }
221
222 // set number of sources
223 m_pUi->m_lineEdit_iNDipole->setText(QString::number(iNSource));
224
225 // set number of clustered sources
226 m_pUi->m_lineEdit_iNDipoleClustered->setText("Not clustered");
227
228 // set number of channels
229 m_pUi->m_lineEdit_iNChan->setText(QString::number(iNChan));
230
231 // set number of source spaces
232 m_pUi->m_lineEdit_iNSourceSpace->setText(QString::number(iNSpaces));
233}
234
235//=============================================================================================================
236
238{
239 return m_pUi->m_checkBox_bDoClustering->isChecked();
240}
241
242//=============================================================================================================
243
245{
246 return m_pUi->m_spinBox_iNDipoleClustered->value();
247}
248
249//=============================================================================================================
250
252{
253 if (!m_bAnnotaionsLoaded) {
254 QMessageBox msgBox;
255 msgBox.setText("Please load an annotation set before clustering.");
256 msgBox.exec();
257 m_pUi->m_checkBox_bDoClustering->setChecked(false);
258 return;
259 } else {
260 emit clusteringStatusChanged(bChecked);
261 }
262}
263
264//=============================================================================================================
265
267{
268 // set number of clustered sources
269 m_pUi->m_lineEdit_iNDipoleClustered->setText(QString::number(iNSources));
270}
271
272//=============================================================================================================
273
275{
276 QString t_sAtlasDir = QFileDialog::getExistingDirectory(this, tr("Open Atlas Directory"),
277 QCoreApplication::applicationDirPath(),
278 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
279
280 m_pUi->m_qLineEdit_AtlasDirName->setText(t_sAtlasDir);
281
282 FsAnnotationSet::SPtr t_pAnnotationSet = FsAnnotationSet::SPtr(new FsAnnotationSet(t_sAtlasDir + "/lh.aparc.a2009s.annot", t_sAtlasDir + "/rh.aparc.a2009s.annot"));
283
284 if (!t_pAnnotationSet->isEmpty() && t_pAnnotationSet->size() == 2) {
285 emit atlasDirChanged(t_sAtlasDir, t_pAnnotationSet);
286 m_pUi->m_qLabel_atlasStat->setText("loaded");
287 m_bAnnotaionsLoaded = true;
288 } else {
289 m_pUi->m_qLabel_atlasStat->setText("not loaded");
290 }
291}
292
293//=============================================================================================================
294
#define FIFFV_COORD_HEAD
#define FIFFV_COORD_MRI
Forward-solution computation controls (BEM / source space / EEG sphere model selectors).
Bi-hemispheric pair of FreeSurfer annotations (lh + rh) for one parcellation atlas.
FreeSurfer surface, annotation and parcellation I/O for mne-cpp.
qint32 fiff_int_t
Definition fiff_types.h:86
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
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 clusterNumberChanged(int iNCluster)
void setRecomputationStatus(int iStatus)
void atlasDirChanged(const QString &sDirPath, const FSLIB::FsAnnotationSet::SPtr pAnnotationSet)
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)
Container holding the lh and/or rh FsAnnotation for one parcellation atlas.
QSharedPointer< FsAnnotationSet > SPtr