MNE-CPP  beta 1.0
eegosportssetupprojectwidget.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
43 #include "ui_eegosportssetupprojectwidget.h"
44 #include "../eegosports.h"
45 
46 //*************************************************************************************************************
47 //=============================================================================================================
48 // USED NAMESPACES
49 //=============================================================================================================
50 
51 using namespace EEGoSportsPlugin;
52 
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // DEFINE MEMBER METHODS
57 //=============================================================================================================
58 
60 : QWidget(parent)
62 , m_pEEGoSports(pEEGoSports)
63 {
64  ui->setupUi(this);
65 
66  // Connect write to file options
67  connect(ui->m_qPushButton_NewProject, &QPushButton::released, this, &EEGoSportsSetupProjectWidget::addProject);
68  connect(ui->m_qPushButton_NewSubject, &QPushButton::released, this, &EEGoSportsSetupProjectWidget::addSubject);
69  connect(ui->m_qPushButton_FiffRecordFile, &QPushButton::released, this, &EEGoSportsSetupProjectWidget::changeOutputFile);
70 
71  // Connect drop down menus
72  connect(ui->m_qComboBox_SubjectSelection, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
73  this, &EEGoSportsSetupProjectWidget::generateFilePath);
74  connect(ui->m_qComboBox_ProjectSelection, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
75  this, &EEGoSportsSetupProjectWidget::generateFilePath);
76 
77  // Connect EEG hat
78  connect(ui->m_qPushButton_EEGCap, &QPushButton::released, this, &EEGoSportsSetupProjectWidget::changeCap);
79 
80  // Connect QLineEdit's
81  connect(ui->m_qLineEdit_EEGCap, static_cast<void (QLineEdit::*)(const QString &)>(&QLineEdit::textEdited),
82  this, &EEGoSportsSetupProjectWidget::changeQLineEdits);
83  connect(ui->m_qLineEdit_FiffRecordFile, static_cast<void (QLineEdit::*)(const QString &)>(&QLineEdit::textEdited),
84  this, &EEGoSportsSetupProjectWidget::changeQLineEdits);
85 }
86 
87 
88 //*************************************************************************************************************
89 
91 {
92  delete ui;
93 }
94 
95 //*************************************************************************************************************
96 
98 {
99  // Init output file path
100  ui->m_qLineEdit_FiffRecordFile->setText(m_pEEGoSports->m_sOutputFilePath);
101 
102  // Init location of layout file
103  ui->m_qLineEdit_EEGCap->setText(m_pEEGoSports->m_sElcFilePath);
104 
105  // Init project and subject menus
106  ui->m_qComboBox_ProjectSelection->addItem("Sequence_01");
107  ui->m_qComboBox_SubjectSelection->addItem("Subject_01");
108  ui->m_qComboBox_ProjectSelection->addItem("Sequence_02");
109  ui->m_qComboBox_SubjectSelection->addItem("Subject_02");
110 
111  // Init file name
112  generateFilePath();
113 }
114 
115 
116 //*************************************************************************************************************
117 
118 void EEGoSportsSetupProjectWidget::addProject()
119 {
120  QString path = QFileDialog::getExistingDirectory(this, tr("Open Project Directory"),
121  m_pEEGoSports->m_qStringResourcePath,
122  QFileDialog::ShowDirsOnly
123  | QFileDialog::DontResolveSymlinks);
124 
125  // Split string to get created or existing target dir with the name of the project
126  QStringList list = path.split("/");
127 
128  // Add to combo box
129  ui->m_qComboBox_ProjectSelection->addItem(list.at(list.size()-1));
130  ui->m_qComboBox_ProjectSelection->setCurrentIndex(ui->m_qComboBox_ProjectSelection->count()-1);
131 }
132 
133 
134 //*************************************************************************************************************
135 
136 void EEGoSportsSetupProjectWidget::addSubject()
137 {
138  QString path = QFileDialog::getExistingDirectory(this, tr("Open Subject Directory"),
139  m_pEEGoSports->m_qStringResourcePath,
140  QFileDialog::ShowDirsOnly
141  | QFileDialog::DontResolveSymlinks);
142 
143  // Split string to get created or existing target dir with the name of the project
144  QStringList list = path.split("/");
145 
146  // Add to combo box
147  ui->m_qComboBox_SubjectSelection->addItem(list.at(list.size()-1));
148  ui->m_qComboBox_SubjectSelection->setCurrentIndex(ui->m_qComboBox_SubjectSelection->count()-1);
149 }
150 
151 
152 //*************************************************************************************************************
153 
154 void EEGoSportsSetupProjectWidget::changeOutputFile()
155 {
156  QString path = QFileDialog::getSaveFileName(
157  this,
158  "Save to fif file",
159  "mne_x_plugins/resources/eegosports/EEG_data_001_raw.fif",
160  tr("Fif files (*.fif)"));
161 
162  if(path==NULL)
163  path = ui->m_qLineEdit_FiffRecordFile->text();
164 
165  ui->m_qLineEdit_FiffRecordFile->setText(path);
166  m_pEEGoSports->m_sOutputFilePath = ui->m_qLineEdit_FiffRecordFile->text();
167 }
168 
169 
170 //*************************************************************************************************************
171 
172 void EEGoSportsSetupProjectWidget::changeCap()
173 {
174  QString path = QFileDialog::getOpenFileName(this,
175  "Change EEG cap layout",
176  "mne_x_plugins/resources/tmsi/loc_files",
177  tr("Electrode location files (*.elc)"));
178 
179  if(path==NULL)
180  path = ui->m_qLineEdit_EEGCap->text();
181 
182  ui->m_qLineEdit_EEGCap->setText(path);
183  m_pEEGoSports->m_sElcFilePath = ui->m_qLineEdit_EEGCap->text();
184 }
185 
186 
187 //*************************************************************************************************************
188 
189 void EEGoSportsSetupProjectWidget::generateFilePath(int index)
190 {
191  Q_UNUSED(index);
192 
193  // Generate file name with timestamp
194  QDate date;
195  QString fileName = QString ("%1_%2_%3_EEG_001_raw.fif").arg(date.currentDate().year()).arg(date.currentDate().month()).arg(date.currentDate().day());
196 
197  // Append new file name, subject and project
198  QString resourcePath = m_pEEGoSports->m_qStringResourcePath;
199  resourcePath.append(ui->m_qComboBox_ProjectSelection->currentText());
200  resourcePath.append("/");
201  resourcePath.append(ui->m_qComboBox_SubjectSelection->currentText());
202  resourcePath.append("/");
203  resourcePath.append(fileName);
204 
205  ui->m_qLineEdit_FiffRecordFile->setText(resourcePath);
206  m_pEEGoSports->m_sOutputFilePath = resourcePath;
207 }
208 
209 
210 //*************************************************************************************************************
211 
212 void EEGoSportsSetupProjectWidget::changeQLineEdits()
213 {
214  m_pEEGoSports->m_sElcFilePath = ui->m_qLineEdit_EEGCap->text();
215  m_pEEGoSports->m_sOutputFilePath = ui->m_qLineEdit_FiffRecordFile->text();
216 }
Definition: aboutwindow.h:52
The EEGoSportsSetupProjectWidget class provides the EEGoSportsSetupProjectWidget configuration window...
EEGoSportsSetupProjectWidget(EEGoSports *pEEGoSports, QWidget *parent=0)
Contains the declaration of the EEGoSportsSetupProjectWidget class.
The EEGoSports class provides a EEG connector. In order for this plugin to work properly the driver d...
Definition: eegosports.h:120