43 #include "mainwindow.h"
59 MainWindow::MainWindow(QWidget *parent)
61 , m_qFileRaw(
"./MNE-sample-data/MEG/sample/sample_audvis_raw.fif")
62 , m_qEventFile(
"./MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif")
63 , m_qEvokedFile(
"./MNE-sample-data/MEG/sample/sample_audvis-ave.fif")
66 , ui(new
Ui::MainWindowWidget)
80 setLogLevel(_LogLvMax);
86 MainWindow::~MainWindow()
93 void MainWindow::setupWindowWidgets()
100 addDockWidget(Qt::LeftDockWidgetArea, m_pEventWindow);
101 m_pEventWindow->hide();
105 addDockWidget(Qt::BottomDockWidgetArea, m_pInformationWindow);
106 m_pInformationWindow->hide();
110 m_pAboutWindow->hide();
114 addDockWidget(Qt::BottomDockWidgetArea, m_pChInfoWindow);
115 m_pChInfoWindow->hide();
119 addDockWidget(Qt::BottomDockWidgetArea, m_pSelectionManagerWindow);
120 m_pSelectionManagerWindow->hide();
124 addDockWidget(Qt::BottomDockWidgetArea, m_pAverageWindow);
125 m_pAverageWindow->hide();
129 addDockWidget(Qt::LeftDockWidgetArea, m_pScaleWindow);
130 m_pScaleWindow->hide();
134 addDockWidget(Qt::BottomDockWidgetArea, m_pFilterWindow);
135 m_pFilterWindow->hide();
139 addDockWidget(Qt::LeftDockWidgetArea, m_pProjectionWindow);
140 m_pProjectionWindow->hide();
143 m_pDataWindow->
init();
144 m_pEventWindow->
init();
145 m_pScaleWindow->
init();
203 m_pSelectionManagerWindow->newFiffFileLoaded();
204 m_pFilterWindow->newFileLoaded();
212 void MainWindow::createToolBar()
215 QToolBar *toolBar =
new QToolBar(
this);
216 toolBar->setOrientation(Qt::Vertical);
217 toolBar->setMovable(
true);
220 m_pRemoveDCAction =
new QAction(QIcon(
":/Resources/Images/removeDC.png"),tr(
"Remove DC component"),
this);
221 m_pRemoveDCAction->setStatusTip(tr(
"Remove the DC component by subtracting the channel mean"));
222 connect(m_pRemoveDCAction,&QAction::triggered, [=](){
224 m_pRemoveDCAction->setIcon(QIcon(
":/Resources/Images/removeDC.png"));
225 m_pRemoveDCAction->setToolTip(
"Remove DC component");
226 m_pDataWindow->setStatusTip(tr(
"Remove the DC component by subtracting the channel mean"));
230 m_pRemoveDCAction->setIcon(QIcon(
":/Resources/Images/addDC.png"));
231 m_pRemoveDCAction->setToolTip(
"Add DC component");
232 m_pRemoveDCAction->setStatusTip(tr(
"Add the DC component"));
238 toolBar->addAction(m_pRemoveDCAction);
241 m_pHideBadAction =
new QAction(QIcon(
":/Resources/Images/hideBad.png"),tr(
"Hide all bad channels"),
this);
242 m_pHideBadAction->setStatusTip(tr(
"Hide all bad channels"));
243 connect(m_pHideBadAction,&QAction::triggered, [=](){
244 if(m_pHideBadAction->toolTip() ==
"Show all bad channels") {
245 m_pHideBadAction->setIcon(QIcon(
":/Resources/Images/hideBad.png"));
246 m_pHideBadAction->setToolTip(
"Hide all bad channels");
247 m_pDataWindow->setStatusTip(tr(
"Hide all bad channels"));
251 m_pHideBadAction->setIcon(QIcon(
":/Resources/Images/showBad.png"));
252 m_pHideBadAction->setToolTip(
"Show all bad channels");
253 m_pHideBadAction->setStatusTip(tr(
"Show all bad channels"));
257 toolBar->addAction(m_pHideBadAction);
259 toolBar->addSeparator();
262 QAction* showEventManager =
new QAction(QIcon(
":/Resources/Images/showEventManager.png"),tr(
"Toggle event manager"),
this);
263 showEventManager->setStatusTip(tr(
"Toggle the event manager"));
264 connect(showEventManager, &QAction::triggered,
this, [=](){
265 showWindow(m_pEventWindow);
267 toolBar->addAction(showEventManager);
270 QAction* showFilterWindow =
new QAction(QIcon(
":/Resources/Images/showFilterWindow.png"),tr(
"Toggle filter window"),
this);
271 showFilterWindow->setStatusTip(tr(
"Toggle filter window"));
272 connect(showFilterWindow, &QAction::triggered,
this, [=](){
273 showWindow(m_pFilterWindow);
275 toolBar->addAction(showFilterWindow);
278 QAction* showSelectionManager =
new QAction(QIcon(
":/Resources/Images/showSelectionManager.png"),tr(
"Toggle selection manager"),
this);
279 showSelectionManager->setStatusTip(tr(
"Toggle the selection manager"));
280 connect(showSelectionManager, &QAction::triggered,
this, [=](){
281 showWindow(m_pSelectionManagerWindow);
283 toolBar->addAction(showSelectionManager);
286 QAction* showScalingWindow =
new QAction(QIcon(
":/Resources/Images/showScalingWindow.png"),tr(
"Toggle scaling window"),
this);
287 showScalingWindow->setStatusTip(tr(
"Toggle the scaling window"));
288 connect(showScalingWindow, &QAction::triggered,
this, [=](){
289 showWindow(m_pScaleWindow);
291 toolBar->addAction(showScalingWindow);
294 QAction* showAverageManager =
new QAction(QIcon(
":/Resources/Images/showAverageManager.png"),tr(
"Toggle average manager"),
this);
295 showAverageManager->setStatusTip(tr(
"Toggle the average manager"));
296 connect(showAverageManager, &QAction::triggered,
this, [=](){
297 showWindow(m_pAverageWindow);
299 toolBar->addAction(showAverageManager);
302 QAction* showProjectionManager =
new QAction(QIcon(
":/Resources/Images/showProjectionWindow.png"),tr(
"Toggle projection manager"),
this);
303 showProjectionManager->setStatusTip(tr(
"Toggle the projection manager"));
304 connect(showProjectionManager, &QAction::triggered,
this, [=](){
305 showWindow(m_pProjectionWindow);
307 toolBar->addAction(showProjectionManager);
309 toolBar->addSeparator();
312 QAction* showChInfo =
new QAction(QIcon(
":/Resources/Images/showChInformationWindow.png"),tr(
"Channel info"),
this);
313 showChInfo->setStatusTip(tr(
"Toggle channel info window"));
314 connect(showChInfo, &QAction::triggered,
this, [=](){
315 showWindow(m_pChInfoWindow);
317 toolBar->addAction(showChInfo);
327 this->addToolBar(Qt::RightToolBarArea,toolBar);
333 void MainWindow::connectMenus()
336 connect(ui->m_openAction, SIGNAL(triggered()),
this, SLOT(openFile()));
337 connect(ui->m_writeAction, SIGNAL(triggered()),
this, SLOT(writeFile()));
338 connect(ui->m_loadEvents, SIGNAL(triggered()),
this, SLOT(loadEvents()));
339 connect(ui->m_saveEvents, SIGNAL(triggered()),
this, SLOT(saveEvents()));
340 connect(ui->m_loadEvokedAction, SIGNAL(triggered()),
this, SLOT(loadEvoked()));
341 connect(ui->m_quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
344 connect(ui->m_filterAction, &QAction::triggered,
this, [=](){
345 showWindow(m_pFilterWindow);
349 connect(ui->m_eventAction, &QAction::triggered,
this, [=](){
350 showWindow(m_pEventWindow);
352 connect(ui->m_informationAction, &QAction::triggered,
this, [=](){
353 showWindow(m_pInformationWindow);
355 connect(ui->m_channelSelectionManagerAction, &QAction::triggered,
this, [=](){
356 showWindow(m_pSelectionManagerWindow);
358 connect(ui->m_averageWindowAction, &QAction::triggered,
this, [=](){
359 showWindow(m_pAverageWindow);
361 connect(ui->m_scalingAction, &QAction::triggered,
this, [=](){
362 showWindow(m_pScaleWindow);
364 connect(ui->m_ChInformationAction, &QAction::triggered,
this, [=](){
365 showWindow(m_pChInfoWindow);
367 connect(ui->m_projectionManagerAction, &QAction::triggered,
this, [=](){
368 showWindow(m_pProjectionWindow);
372 connect(ui->m_aboutAction, &QAction::triggered,
this, [=](){
373 showWindow(m_pAboutWindow);
380 void MainWindow::setupMainWindow()
383 resize(m_qSettings.value(
"MainWindow/size", QSize(MAINWINDOW_WINDOW_SIZE_W, MAINWINDOW_WINDOW_SIZE_H)).toSize());
384 move(m_qSettings.value(
"MainWindow/position", QPoint(MAINWINDOW_WINDOW_POSITION_X, MAINWINDOW_WINDOW_POSITION_Y)).toPoint());
387 setCentralWidget(m_pDataWindow);
393 void MainWindow::setWindowStatus()
398 title = QString(
"Visualize and Process");
399 setWindowTitle(title);
404 int idx = m_qFileRaw.fileName().lastIndexOf(
"/");
405 QString filename = m_qFileRaw.fileName().remove(0,idx+1);
409 title = QString(
"No data file");
413 int idx = m_qEventFile.fileName().lastIndexOf(
"/");
414 QString filename = m_qEventFile.fileName().remove(0,idx+1);
416 title.append(QString(
" - Event file: %1").arg(filename));
419 title.append(
" - No event file");
423 int idx = m_qEvokedFile.fileName().lastIndexOf(
"/");
424 QString filename = m_qEvokedFile.fileName().remove(0,idx+1);
426 title.append(QString(
" - Evoked file: %1").arg(filename));
429 title.append(
" - No evoked file");
432 QObjectList cildrenList = statusBar()->children();
434 for(
int i = 0; i< cildrenList.size(); i++)
435 statusBar()->removeWidget((QWidget*)cildrenList.at(i));
437 QLabel* label =
new QLabel(title);
438 statusBar()->addWidget(label);
446 m_pInformationWindow->
writeToLog(logMsg, lgknd, lglvl);
452 void MainWindow::setLogLevel(LogLevel lvl)
460 void MainWindow::openFile()
462 QString filename = QFileDialog::getOpenFileName(
this,
463 QString(
"Open fiff data file"),
464 QString(
"./MNE-sample-data/MEG/sample/"),
465 tr(
"fif data files (*.fif)"));
467 if(filename.isEmpty())
469 qDebug(
"User aborted opening of fiff data file");
473 if(m_qFileRaw.isOpen())
476 m_qFileRaw.setFileName(filename);
517 qDebug() <<
"Fiff data file" << filename <<
"loaded.";
519 qDebug(
"ERROR loading fiff data file %s",filename.toLatin1().data());
546 void MainWindow::writeFile()
548 QString filename = QFileDialog::getSaveFileName(
this,
549 QString(
"Write fiff data file"),
550 QString(
"./MNE-sample-data/MEG/sample/"),
551 tr(
"fif data files (*.fif)"));
553 if(filename.isEmpty()) {
554 qDebug(
"User aborted saving to fiff data file");
558 if(filename == m_qFileRaw.fileName()) {
560 msgBox.setText(
"You are trying to write to the file you are currently loading the data from. Please choose another file to write to.");
566 QFile qFileOutput (filename);
567 if(qFileOutput.isOpen())
570 QFutureWatcher<bool> writeFileFutureWatcher;
571 QProgressDialog progressDialog(
"Writing to fif file...", QString(), 0, 0,
this, Qt::Dialog);
574 connect(&writeFileFutureWatcher, &QFutureWatcher<bool>::finished,
575 &progressDialog, &QProgressDialog::reset);
577 connect(&progressDialog, &QProgressDialog::canceled,
578 &writeFileFutureWatcher, &QFutureWatcher<bool>::cancel);
580 connect(m_pDataWindow->
getDataModel(), &RawModel::writeProgressRangeChanged,
581 &progressDialog, &QProgressDialog::setRange);
583 connect(m_pDataWindow->
getDataModel(), &RawModel::writeProgressChanged,
584 &progressDialog, &QProgressDialog::setValue);
587 writeFileFutureWatcher.setFuture(QtConcurrent::run(m_pDataWindow->
getDataModel(),
591 progressDialog.exec();
593 writeFileFutureWatcher.waitForFinished();
595 if(!writeFileFutureWatcher.future().result())
596 qDebug() <<
"MainWindow: ERROR writing fiff data file" << qFileOutput.fileName() <<
"!";
598 qDebug() <<
"MainWindow: Successfully written to" << qFileOutput.fileName() <<
"!";
604 void MainWindow::loadEvents()
606 QString filename = QFileDialog::getOpenFileName(
this,
607 QString(
"Open fiff event data file"),
608 QString(
"./MNE-sample-data/MEG/sample/"),
609 tr(
"fif event data files (*-eve.fif);;fif data files (*.fif)"));
611 if(filename.isEmpty())
613 qDebug(
"User aborted loading fiff event file");
617 if(m_qEventFile.isOpen())
618 m_qEventFile.close();
620 m_qEventFile.setFileName(filename);
623 qDebug() <<
"Fiff event data file" << filename <<
"loaded.";
625 qDebug(
"ERROR loading fiff event data file %s",filename.toLatin1().data());
631 if(!m_pEventWindow->isVisible())
632 m_pEventWindow->show();
638 void MainWindow::saveEvents()
640 QString filename = QFileDialog::getSaveFileName(
this,
641 QString(
"Save fiff event data file"),
642 QString(
"./MNE-sample-data/MEG/sample/"),
643 tr(
"fif event data files (*-eve.fif);;fif data files (*.fif)"));
644 if(filename.isEmpty())
646 qDebug(
"User aborted saving to fiff event data file");
650 if(m_qEventFile.isOpen())
651 m_qEventFile.close();
652 m_qEventFile.setFileName(filename);
655 qDebug() <<
"Fiff event data file" << filename <<
"saved.";
658 qDebug(
"ERROR saving fiff event data file %s",filename.toLatin1().data());
664 void MainWindow::loadEvoked()
666 QString filename = QFileDialog::getOpenFileName(
this,QString(
"Open evoked fiff data file"),QString(
"./MNE-sample-data/MEG/sample/"),tr(
"fif evoked data files (*-ave.fif);;fif data files (*.fif)"));
668 if(filename.isEmpty())
670 qDebug(
"User aborted loading fiff evoked file");
674 if(m_qEvokedFile.isOpen())
675 m_qEvokedFile.close();
677 m_qEvokedFile.setFileName(filename);
680 qDebug() <<
"Fiff evoked data file" << filename <<
"loaded.";
682 qDebug(
"ERROR loading evoked data file %s",filename.toLatin1().data());
688 if(!m_pAverageWindow->isVisible())
689 m_pAverageWindow->show();
695 void MainWindow::showWindow(QWidget *window)
698 if(!window->isVisible())
AverageModel * getAverageModel()
The EventWindow class provides the event dock window.
ProjectionModel * getDataModel()
ChInfoModel * getDataModel()
bool loadEvokedData(QFile &qFile)
void fiffInfoChanged(const FiffInfo &fiffInfo)
void fileLoaded(const FiffInfo &)
EventModel * getEventModel()
void scaleData(const QMap< QString, double > &scaleMap)
FIFF measurement file information.
void channelSelectionManagerChanged(const QList< QGraphicsItem * > &selectedChannelItems)
The ChInfoWindow class provides a dock window for informations about every loaded channel...
The AboutWindow class provides the about window.
RawModel * getDataModel()
The SelectionManagerWindow class provides a channel selection window.
void setFirstLastSample(int firstSample, int lastSample)
void layoutChanged(const QMap< QString, QPointF > &layoutMap)
void assignedOperatorsChanged(const QMap< int, QSharedPointer< MNEOperator > > &assignedOperators)
void selectionChanged(const QList< QGraphicsItem * > &selectedChannelItems)
The ProjectionWindow class provides a dock window for managing SSP operator projcetions.
void scaleChannels(double)
void scaleAllChannels(double scaleValue)
QTableView * getDataTableView()
void showSelectedChannelsOnly(QStringList selectedChannels)
The DataWindow class provides the data dock window.
void writeToLog(const QString &logMsg, LogKind lgknd, LogLevel lglvl)
bool writeFiffData(QIODevice *p_IODevice)
The FilterWindow class provides the filter window.
void scalingChannelValueChanged(QMap< QString, double >)
RawDelegate * getDataDelegate()
const QStringList & getMappedChannelsList()
void assignedOperatorsChanged(const QMap< int, QSharedPointer< MNEOperator > > &)
void scaleAveragedData(const QMap< QString, double > &scaleMap)
qint32 firstSample() const
void scalingViewValueChanged(int)
bool saveEventData(QFile &qFile)
The AverageWindow class provides a dock window for plotting averages.
void hideBadChannels(bool hideChannels)
void loadedLayoutMap(const QMap< QString, QPointF > &layoutMap)
bool loadEventData(QFile &qFile)
void addProjections(const QList< FiffProj > &dataProjs)
void hideSpinBoxes(FiffInfo currentFiffInfo)
void setFiffInfo(FiffInfo &fiffInfo)
The ScaleWindow class provides the scale window.
bool loadFiffData(QFile *qFile)
void showSelectedChannelsOnly(QStringList selectedChannels)
void changeRowHeight(int height)
void channelsMappedToLayout(const QStringList &mappedLayoutChNames)
qint32 lastSample() const
void setCurrentlyMappedFiffChannels(const QStringList &mappedLayoutChNames)
void updateDataTableViews()