49 #include <QGridLayout>
51 #include <QDoubleSpinBox>
63 using namespace DISPLIB;
64 using namespace FIFFLIB;
70 ArtifactSettingsView::ArtifactSettingsView(
const QString& sSettingsPath,
71 const QList<FiffChInfo>& fiffChInfoList,
74 , m_fiffChInfoList(fiffChInfoList)
76 m_sSettingsPath = sSettingsPath;
77 qRegisterMetaType<QMap<QString,double> >(
"QMap<QString,double>");
79 this->setWindowTitle(
"Artifact Rejection Settings");
80 this->setMinimumWidth(330);
81 this->setMaximumWidth(330);
97 void ArtifactSettingsView::setChInfo(
const QList<FIFFLIB::FiffChInfo>& fiffChInfoList)
99 m_fiffChInfoList = fiffChInfoList;
102 onChangeArtifactThreshold();
107 QMap<QString,double> ArtifactSettingsView::getThresholdMap()
109 return m_mapThresholds;
114 void ArtifactSettingsView::setThresholdMap(
const QMap<QString,double>& mapThresholds)
116 m_mapThresholds = mapThresholds;
119 onChangeArtifactThreshold();
124 bool ArtifactSettingsView::getDoArtifactThresholdRejection()
126 if (m_pArtifactRejectionCheckBox) {
127 return m_pArtifactRejectionCheckBox->isChecked();
142 QSettings settings(
"MNECPP");
144 settings.setValue(
m_sSettingsPath + QString(
"/ArtifactSettingsView/doArtifactThresholdReduction"), m_bDoArtifactThresholdReduction);
146 settings.beginGroup(
m_sSettingsPath + QString(
"/ArtifactSettingsView/artifactThresholdsFirst"));
147 QMap<QString, double>::const_iterator itrFirst = m_mapThresholdsFirst.constBegin();
148 while (itrFirst != m_mapThresholdsFirst.constEnd()) {
149 settings.setValue(itrFirst.key(), itrFirst.value());
154 settings.beginGroup(
m_sSettingsPath + QString(
"/ArtifactSettingsView/artifactThresholdsSecond"));
155 QMap<QString, int>::const_iterator itrSecond = m_mapThresholdsSecond.constBegin();
156 while (itrSecond != m_mapThresholdsSecond.constEnd()) {
157 settings.setValue(itrSecond.key(), itrSecond.value());
172 QSettings settings(
"MNECPP");
174 m_bDoArtifactThresholdReduction = settings.value(
m_sSettingsPath + QString(
"/ArtifactSettingsView/doArtifactThresholdReduction"),
false).toBool();
176 if(m_bDoArtifactThresholdReduction) {
177 m_mapThresholds[
"Active"] = 1.0;
179 m_mapThresholds[
"Active"] = 0.0;
182 m_mapThresholdsFirst[
"grad"] = 1.0;
183 m_mapThresholdsFirst[
"mag"] = 1.0;
184 m_mapThresholdsFirst[
"eeg"] = 1.0;
185 m_mapThresholdsFirst[
"ecg"] = 1.0;
186 m_mapThresholdsFirst[
"emg"] = 1.0;
187 m_mapThresholdsFirst[
"eog"] = 1.0;
189 m_mapThresholdsSecond[
"grad"] = -1;
190 m_mapThresholdsSecond[
"mag"] = -1;
191 m_mapThresholdsSecond[
"eeg"] = -1;
192 m_mapThresholdsSecond[
"ecg"] = -1;
193 m_mapThresholdsSecond[
"emg"] = -1;
194 m_mapThresholdsSecond[
"eog"] = -1;
196 settings.beginGroup(
m_sSettingsPath + QString(
"/ArtifactSettingsView/artifactThresholdsFirst"));
197 QStringList keys = settings.childKeys();
198 foreach (QString key, keys) {
199 m_mapThresholdsFirst.insert(key, settings.value(key, 1.0).toDouble());
203 settings.beginGroup(
m_sSettingsPath + QString(
"/ArtifactSettingsView/artifactThresholdsSecond"));
204 keys = settings.childKeys();
205 foreach (QString key, keys) {
206 m_mapThresholdsSecond.insert(key, settings.value(key, -1).toInt());
216 case GuiMode::Clinical:
228 case ProcessingMode::Offline:
239 if(QLayout* layout = this->layout()) {
243 QGridLayout* pGroupBoxArtifactRejection =
new QGridLayout();
244 this->setLayout(pGroupBoxArtifactRejection);
247 if(!m_fiffChInfoList.isEmpty()) {
248 QStringList channelTypes;
251 for(
int i = 0; i < m_fiffChInfoList.size(); ++i) {
252 kind = m_fiffChInfoList.at(i).kind;
253 unit = m_fiffChInfoList.at(i).unit;
255 if(kind == FIFFV_MEG_CH && unit == FIFF_UNIT_T_M && !channelTypes.contains(
"grad")) {
256 channelTypes <<
"grad";
258 if(kind == FIFFV_MEG_CH && unit == FIFF_UNIT_T && !channelTypes.contains(
"mag")) {
259 channelTypes <<
"mag";
261 if(kind == FIFFV_EEG_CH && !channelTypes.contains(
"eeg", Qt::CaseInsensitive)) {
262 channelTypes <<
"eeg";
264 if(kind == FIFFV_EOG_CH && !channelTypes.contains(
"eog", Qt::CaseInsensitive)) {
265 channelTypes <<
"eog";
267 if(kind == FIFFV_EMG_CH && !channelTypes.contains(
"emg", Qt::CaseInsensitive)) {
268 channelTypes <<
"emg";
270 if(kind == FIFFV_ECG_CH && !channelTypes.contains(
"ecg", Qt::CaseInsensitive)) {
271 channelTypes <<
"ecg";
275 if(!channelTypes.isEmpty()) {
276 m_pArtifactRejectionCheckBox =
new QCheckBox(
"Activate artifact rejection");
277 pGroupBoxArtifactRejection->addWidget(m_pArtifactRejectionCheckBox,0,0,1,2);
278 m_pArtifactRejectionCheckBox->setChecked(m_bDoArtifactThresholdReduction);
279 connect(m_pArtifactRejectionCheckBox.data(), &QCheckBox::clicked,
280 this, &ArtifactSettingsView::onChangeArtifactThreshold);
282 for(
int i = 0; i < channelTypes.size(); ++i) {
283 QLabel* pLabel =
new QLabel(channelTypes.at(i));
284 pGroupBoxArtifactRejection->addWidget(pLabel,i+1,0);
286 QDoubleSpinBox* pDoubleSpinBox =
new QDoubleSpinBox();
287 pDoubleSpinBox->setPrefix(
"+/-");
288 pDoubleSpinBox->setMinimum(0.0);
289 pDoubleSpinBox->setMaximum(100000.0);
290 pDoubleSpinBox->setValue(m_mapThresholdsFirst[channelTypes.at(i)]);
291 pGroupBoxArtifactRejection->addWidget(pDoubleSpinBox,i+1,1);
292 connect(pDoubleSpinBox,
static_cast<void (QDoubleSpinBox::*)(
double)
>(&QDoubleSpinBox::valueChanged),
293 this, &ArtifactSettingsView::onChangeArtifactThreshold);
294 m_mapChThresholdsDoubleSpinBoxes[channelTypes.at(i)] = pDoubleSpinBox;
296 QSpinBox* pSpinBox =
new QSpinBox();
297 pSpinBox->setPrefix(
"e");
298 pSpinBox->setMaximum(0);
299 pSpinBox->setMinimum(-10000);
300 pSpinBox->setValue(m_mapThresholdsSecond[channelTypes.at(i)]);
301 pGroupBoxArtifactRejection->addWidget(pSpinBox,i+1,2);
302 connect(pSpinBox,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
303 this, &ArtifactSettingsView::onChangeArtifactThreshold);
304 m_mapChThresholdsSpinBoxes[channelTypes.at(i)] = pSpinBox;
312 void ArtifactSettingsView::onChangeArtifactThreshold()
314 m_mapThresholds.clear();
315 m_mapThresholdsFirst.clear();
316 m_mapThresholdsSecond.clear();
318 if(m_pArtifactRejectionCheckBox) {
319 if(m_pArtifactRejectionCheckBox->isChecked()) {
320 m_mapThresholds[
"Active"] = 1.0;
321 m_bDoArtifactThresholdReduction =
true;
323 m_mapThresholds[
"Active"] = 0.0;
324 m_bDoArtifactThresholdReduction =
false;
328 QMapIterator<QString, QDoubleSpinBox*> i(m_mapChThresholdsDoubleSpinBoxes);
330 while (i.hasNext()) {
333 m_mapThresholdsFirst[i.key()] = i.value()->value();
334 m_mapThresholdsSecond[i.key()] = m_mapChThresholdsSpinBoxes[i.key()]->value();
336 if(i.key().contains(
"grad", Qt::CaseInsensitive)) {
337 m_mapThresholds[
"grad"] = i.value()->value() * pow(10, m_mapChThresholdsSpinBoxes[i.key()]->value());
339 if(i.key().contains(
"mag", Qt::CaseInsensitive)) {
340 m_mapThresholds[
"mag"] = i.value()->value() * pow(10, m_mapChThresholdsSpinBoxes[i.key()]->value());
342 if(i.key().contains(
"eeg", Qt::CaseInsensitive)) {
343 m_mapThresholds[
"eeg"] = i.value()->value() * pow(10, m_mapChThresholdsSpinBoxes[i.key()]->value());
345 if(i.key().contains(
"ecg", Qt::CaseInsensitive)) {
346 m_mapThresholds[
"ecg"] = i.value()->value() * pow(10, m_mapChThresholdsSpinBoxes[i.key()]->value());
348 if(i.key().contains(
"eog", Qt::CaseInsensitive)) {
349 m_mapThresholds[
"eog"] = i.value()->value() * pow(10, m_mapChThresholdsSpinBoxes[i.key()]->value());
351 if(i.key().contains(
"emg", Qt::CaseInsensitive)) {
352 m_mapThresholds[
"emg"] = i.value()->value() * pow(10, m_mapChThresholdsSpinBoxes[i.key()]->value());
357 emit changeArtifactThreshold(m_mapThresholds);