MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
triggerdetectionview.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
40
41#include "ui_triggerdetectionview.h"
42
43#include <fiff/fiff_info.h>
44
45//=============================================================================================================
46// QT INCLUDES
47//=============================================================================================================
48
49#include <QColorDialog>
50#include <QPalette>
51#include <QSettings>
52
53//=============================================================================================================
54// EIGEN INCLUDES
55//=============================================================================================================
56
57//=============================================================================================================
58// USED NAMESPACES
59//=============================================================================================================
60
61using namespace DISPLIB;
62using namespace FIFFLIB;
63
64//=============================================================================================================
65// DEFINE MEMBER METHODS
66//=============================================================================================================
67
68TriggerDetectionView::TriggerDetectionView(const QString& sSettingsPath,
69 QWidget *parent,
70 Qt::WindowFlags f)
71: AbstractView(parent, f)
72, m_pUi(new Ui::TriggerDetectionViewWidget)
73{
74 m_sSettingsPath = sSettingsPath;
75 m_pUi->setupUi(this);
76
77 this->setWindowTitle("Trigger Detection Settings");
78 this->setMinimumWidth(330);
79 this->setMaximumWidth(330);
80
81 updateProcessingMode(RealTime);
82
84}
85
86//=============================================================================================================
87
94
95//=============================================================================================================
96
98{
99 if(pFiffInfo) {
100 m_pFiffInfo = pFiffInfo;
101 //Trigger detection
102 connect(m_pUi->m_checkBox_activateTriggerDetection, static_cast<void (QCheckBox::*)(int)>(&QCheckBox::stateChanged),
104
105 m_pUi->m_comboBox_triggerChannels->clear();
106
107 for(int i = 0; i<m_pFiffInfo->chs.size(); i++) {
108 if(m_pFiffInfo->chs[i].kind == FIFFV_STIM_CH) {
109 m_pUi->m_comboBox_triggerChannels->addItem(m_pFiffInfo->chs[i].ch_name);
110 }
111 }
112
113 connect(m_pUi->m_comboBox_triggerChannels, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged),
115
116 connect(m_pUi->m_comboBox_triggerColorType, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged),
118
119 connect(m_pUi->m_pushButton_triggerColor, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
121
122 m_pUi->m_pushButton_triggerColor->setAutoFillBackground(true);
123 m_pUi->m_pushButton_triggerColor->setFlat(true);
124 QPalette* palette1 = new QPalette();
125 palette1->setColor(QPalette::Button,QColor(177,0,0));
126 m_pUi->m_pushButton_triggerColor->setPalette(*palette1);
127 m_pUi->m_pushButton_triggerColor->update();
128
129 connect(m_pUi->m_doubleSpinBox_detectionThresholdFirst, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
131
132 connect(m_pUi->m_spinBox_detectionThresholdSecond, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
134
135 connect(m_pUi->m_pushButton_resetNumberTriggers, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
137
138 connect(m_pUi->m_pushButton_DetectTriggers, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
139 this, &TriggerDetectionView::onDetectTriggers, Qt::UniqueConnection);
140
141 loadSettings();
142 }
143}
144
145//=============================================================================================================
146
147void TriggerDetectionView::setNumberDetectedTriggersAndTypes(int numberDetections, const QMap<int,QList<QPair<int,double> > >& mapDetectedTriggers)
148{
149 //if(m_bTriggerDetection) {
150 m_pUi->m_label_numberDetectedTriggers->setText(QString("%1").arg(numberDetections));
151 //}
152
153 //Set trigger types
154 QMapIterator<int,QList<QPair<int,double> > > i(mapDetectedTriggers);
155 while (i.hasNext()) {
156 i.next();
157
158 for(int j = 0; j < i.value().size(); ++j) {
159 if(m_pUi->m_comboBox_triggerColorType->findText(QString::number(i.value().at(j).second)) == -1) {
160 m_pUi->m_comboBox_triggerColorType->addItem(QString::number(i.value().at(j).second));
161 }
162 }
163 }
164}
165
166//=============================================================================================================
167
169{
170 if(m_sSettingsPath.isEmpty()) {
171 return;
172 }
173
174 QSettings settings("MNECPP");
175
176 settings.setValue(m_sSettingsPath + QString("/TriggerDetectionView/Activated"), m_pUi->m_checkBox_activateTriggerDetection->isChecked());
177 settings.setValue(m_sSettingsPath + QString("/TriggerDetectionView/ChannelIndex"), m_pUi->m_comboBox_triggerChannels->currentIndex());
178 settings.setValue(m_sSettingsPath + QString("/TriggerDetectionView/FirstThresholdValue"), m_pUi->m_doubleSpinBox_detectionThresholdFirst->value());
179 settings.setValue(m_sSettingsPath + QString("/TriggerDetectionView/SecondThresholdValue"), m_pUi->m_spinBox_detectionThresholdSecond->value());
180
181 settings.beginGroup(m_sSettingsPath + QString("/TriggerDetectionView/Colors"));
182 QMap<double, QColor>::const_iterator i = m_qMapTriggerColor.constBegin();
183 while (i != m_qMapTriggerColor.constEnd()) {
184 settings.setValue(QString::number(i.key()), i.value());
185 ++i;
186 }
187 settings.endGroup();
188}
189
190//=============================================================================================================
191
193{
194 if(m_sSettingsPath.isEmpty()) {
195 return;
196 }
197
198 QSettings settings("MNECPP");
199
200 m_pUi->m_checkBox_activateTriggerDetection->setChecked(settings.value(m_sSettingsPath + QString("/TriggerDetectionView/Activated"), false).toBool());
201 m_pUi->m_comboBox_triggerChannels->setCurrentIndex(settings.value(m_sSettingsPath + QString("/TriggerDetectionView/ChannelIndex"), 0).toInt());
202 m_pUi->m_doubleSpinBox_detectionThresholdFirst->setValue(settings.value(m_sSettingsPath + QString("/TriggerDetectionView/FirstThresholdValue"), 0.1).toDouble());
203 m_pUi->m_spinBox_detectionThresholdSecond->setValue(settings.value(m_sSettingsPath + QString("/TriggerDetectionView/SecondThresholdValue"), -1).toInt());
204
205 settings.beginGroup(m_sSettingsPath + QString("/TriggerDetectionView/Colors"));
206 QStringList keys = settings.childKeys();
207 foreach (QString key, keys) {
208 double dKey = key.toDouble();
209 m_qMapTriggerColor[dKey] = settings.value(key).value<QColor>();
210 }
211 settings.endGroup();
212
214}
215
216//=============================================================================================================
217
219{
220 switch(mode) {
221 case GuiMode::Clinical:
222 break;
223 default: // default is research mode
224 break;
225 }
226}
227
228//=============================================================================================================
229
231{
232 switch(mode) {
233 case ProcessingMode::Offline:
234 m_pUi->label->hide();
235 m_pUi->label_9->hide();
236 m_pUi->m_pushButton_resetNumberTriggers->hide();
237 m_pUi->m_pushButton_triggerColor->hide();
238 m_pUi->m_checkBox_activateTriggerDetection->hide();
239 m_pUi->m_comboBox_triggerColorType->hide();
240 m_pUi->m_label_numberDetectedTriggers->hide();
241 m_pUi->m_pushButton_DetectTriggers->show();
242 break;
243 default: // default is realtime mode
244 m_pUi->label->show();
245 m_pUi->label_9->show();
246 m_pUi->m_pushButton_resetNumberTriggers->show();
247 m_pUi->m_pushButton_triggerColor->show();
248 m_pUi->m_checkBox_activateTriggerDetection->show();
249 m_pUi->m_comboBox_triggerColorType->show();
250 m_pUi->m_label_numberDetectedTriggers->show();
251 m_pUi->m_pushButton_DetectTriggers->hide();
252 break;
253 }
254}
255
256//=============================================================================================================
257
259{
261 m_pUi->m_checkBox_activateTriggerDetection->isChecked(),
262 m_pUi->m_comboBox_triggerChannels->currentText(),
263 m_pUi->m_doubleSpinBox_detectionThresholdFirst->value()*pow(10, m_pUi->m_spinBox_detectionThresholdSecond->value()));
264
265 saveSettings();
266}
267
268//=============================================================================================================
269
271{
272 Q_UNUSED(state);
273
274 QColor color = QColorDialog::getColor(m_qMapTriggerColor[m_pUi->m_comboBox_triggerColorType->currentText().toDouble()], this, "Set trigger color");
275
276 //Change color of pushbutton
277 QPalette* palette1 = new QPalette();
278 palette1->setColor(QPalette::Button,color);
279 m_pUi->m_pushButton_triggerColor->setPalette(*palette1);
280 m_pUi->m_pushButton_triggerColor->update();
281
282 m_qMapTriggerColor[m_pUi->m_comboBox_triggerColorType->currentText().toDouble()] = color;
283
285}
286
287//=============================================================================================================
288
290{
291 //Change color of pushbutton
292 QPalette* palette1 = new QPalette();
293 palette1->setColor(QPalette::Button,m_qMapTriggerColor[value.toDouble()]);
294 m_pUi->m_pushButton_triggerColor->setPalette(*palette1);
295 m_pUi->m_pushButton_triggerColor->update();
296}
297
298//=============================================================================================================
299
301{
302 m_pUi->m_label_numberDetectedTriggers->setText(QString("0"));
303 m_pUi->m_comboBox_triggerColorType->clear();
304
305 emit resetTriggerCounter();
306
307 //emit updateConnectedView();
308}
309
310//=============================================================================================================
311
313{
314 if(m_pUi->m_comboBox_triggerChannels->currentText() == ""){
315 return;
316 }
317 emit detectTriggers(m_pUi->m_comboBox_triggerChannels->currentText(),
318 m_pUi->m_doubleSpinBox_detectionThresholdFirst->value()*pow(10, m_pUi->m_spinBox_detectionThresholdSecond->value()));
319}
320
321//=============================================================================================================
322
324{
325 return m_pUi->m_comboBox_triggerChannels->currentText();
326}
327
328//=============================================================================================================
329
Declaration of the TriggerDetectionView Class.
FiffInfo class declaration.
The AbstractView class provides the base calss for all Disp viewers.
TriggerDetectionView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
QMap< double, QColor > m_qMapTriggerColor
void setNumberDetectedTriggersAndTypes(int totalNumberDetections, const QMap< int, QList< QPair< int, double > > > &mapDetectedTriggers)
QSharedPointer< FIFFLIB::FiffInfo > m_pFiffInfo
void onRealTimeTriggerColorTypeChanged(const QString &value)
void init(const QSharedPointer< FIFFLIB::FiffInfo > pFiffInfo)
void triggerInfoChanged(const QMap< double, QColor > &value, bool bActive, const QString &sTriggerCh, double dThreshold)
void updateProcessingMode(ProcessingMode mode)
void detectTriggers(const QString &sChannelName, double iThreshold)
QSharedPointer< FiffInfo > SPtr
Definition fiff_info.h:87