57 using namespace MNELIB;
58 using namespace Eigen;
59 using namespace FIFFLIB;
65 bool MNE::read_events(QString t_sEventName,
66 QString t_fileRawName,
72 if (t_sEventName.isEmpty()) {
73 p = t_fileRawName.indexOf(
".fif");
75 t_sEventName = t_fileRawName.replace(p, 4,
"-eve.fif");
77 printf(
"Raw file name does not end properly\n");
81 t_EventFile.setFileName(t_sEventName);
83 printf(
"Error while read events.\n");
86 printf(
"Events read from %s\n",t_sEventName.toUtf8().constData());
89 if (t_sEventName.contains(
".fif")) {
90 t_EventFile.setFileName(t_sEventName);
92 printf(
"Error while read events.\n");
95 printf(
"Binary event file %s read\n",t_sEventName.toUtf8().constData());
96 }
else if(t_sEventName.contains(
".eve")){
100 printf(
"Text file %s is not supported jet.\n",t_sEventName.toUtf8().constData());
152 if(!t_pStream->open()) {
159 QList<FiffDirNode::SPtr> events = t_pStream->dirtree()->dir_tree_find(FIFFB_MNE_EVENTS);
161 if (events.size() == 0)
163 printf(
"Could not find event data\n");
168 fiff_int_t kind, pos;
170 quint32* serial_eventlist_uint = NULL;
171 qint32* serial_eventlist_int = NULL;
173 for(
k = 0;
k < events[0]->nent(); ++
k)
175 kind = events[0]->dir[
k]->kind;
176 pos = events[0]->dir[
k]->pos;
179 t_pStream->read_tag(t_pTag,pos);
180 if(t_pTag->type == FIFFT_UINT)
182 serial_eventlist_uint = t_pTag->toUnsignedInt();
183 nelem = t_pTag->size()/4;
186 if(t_pTag->type == FIFFT_INT)
188 serial_eventlist_int = t_pTag->toInt();
189 nelem = t_pTag->size()/4;
196 if(serial_eventlist_uint == NULL && serial_eventlist_int == NULL)
198 printf(
"Could not find any events\n");
203 eventlist.resize(nelem/3,3);
204 if(serial_eventlist_uint != NULL)
206 for(
k = 0;
k < nelem/3; ++
k)
208 eventlist(
k,0) = serial_eventlist_uint[
k*3];
209 eventlist(
k,1) = serial_eventlist_uint[
k*3+1];
210 eventlist(
k,2) = serial_eventlist_uint[
k*3+2];
214 if(serial_eventlist_int != NULL)
216 for(
k = 0;
k < nelem/3; ++
k)
218 eventlist(
k,0) = serial_eventlist_int[
k*3];
219 eventlist(
k,1) = serial_eventlist_int[
k*3+1];
220 eventlist(
k,2) = serial_eventlist_int[
k*3+2];
231 fiff_int_t dest_comp,
236 printf(
"No projector specified for these data\n");
243 printf(
"%lld projection items activated\n",raw.
info.
projs.size());
249 printf(
"The projection vectors do not apply to these channels\n");
251 printf(
"Created an SSP operator (subspace dimension = %d)\n",nproj);
258 if (current_comp > 0)
259 printf(
"Current compensation grade : %d\n",current_comp);
262 dest_comp = current_comp;
264 if (current_comp != dest_comp)
266 qDebug() <<
"This part needs to be debugged";
271 printf(
"Appropriate compensator added to change to grade %d.\n",dest_comp);
275 printf(
"Could not make the compensator\n");
284 Eigen::MatrixXi& eventlist)
286 if (!p_IODevice.open(QIODevice::ReadOnly | QIODevice::Text)){
289 QTextStream textStream(&p_IODevice);
291 QList<int> simpleList;
293 while(!textStream.atEnd()){
295 textStream >> iSample;
296 simpleList.append(iSample);
297 textStream.readLine();
298 qDebug() <<
"Added event:" << iSample;
301 eventlist.resize(simpleList.size(), 1);
303 for(
int i = 0; i < simpleList.size(); i++){
304 eventlist(i,0) = simpleList[i];