62 #include <QtCore/QCoreApplication>
88 int main(
int argc,
char *argv[])
90 QCoreApplication a(argc, argv);
92 QFile t_fileRaw(
"./MNE-sample-data/MEG/sample/sample_audvis_raw.fif");
95 QString t_sEventName =
"./MNE-sample-data/MEG/sample/sample_audvis_raw-eve.fif";
99 bool keep_comp =
false;
100 fiff_int_t dest_comp = 0;
101 bool pick_all =
true;
116 picks.resize(raw.info.nchan);
118 for(k = 0; k < raw.info.nchan; ++k)
125 include <<
"STI 014";
126 bool want_meg =
true;
127 bool want_eeg =
false;
128 bool want_stim =
false;
131 picks = raw.info.pick_types(want_meg, want_eeg, want_stim, include, raw.info.bads);
134 QStringList ch_names;
135 for(k = 0; k < picks.cols(); ++k)
136 ch_names << raw.info.ch_names[picks(0,k)];
141 if (raw.info.projs.size() == 0)
142 printf(
"No projector specified for these data\n");
148 for (k = 0; k < raw.info.projs.size(); ++k)
149 raw.info.projs[k].active =
true;
151 printf(
"%d projection items activated\n",raw.info.projs.size());
156 fiff_int_t nproj = raw.info.make_projector(raw.proj);
160 printf(
"The projection vectors do not apply to these channels\n");
164 printf(
"Created an SSP operator (subspace dimension = %d)\n",nproj);
172 qint32 current_comp = raw.info.get_current_comp();
173 if (current_comp > 0)
174 printf(
"Current compensation grade : %d\n",current_comp);
177 dest_comp = current_comp;
179 if (current_comp != dest_comp)
181 qDebug() <<
"This part needs to be debugged";
182 if(MNE::make_compensator(raw.info, current_comp, dest_comp, raw.comp))
185 raw.info.set_current_comp(dest_comp);
186 printf(
"Appropriate compensator added to change to grade %d.\n",dest_comp);
190 printf(
"Could not make the compensator\n");
199 if (t_sEventName.size() == 0)
201 p = t_fileRaw.fileName().indexOf(
".fif");
204 t_sEventName = t_fileRaw.fileName().replace(p, 4,
"-eve.fif");
208 printf(
"Raw file name does not end properly\n");
213 t_EventFile.setFileName(t_sEventName);
214 MNE::read_events(t_EventFile, events);
215 printf(
"Events read from %s\n",t_sEventName.toUtf8().constData());
222 p = t_fileRaw.fileName().indexOf(
".fif");
225 t_EventFile.setFileName(t_sEventName);
226 if(!MNE::read_events(t_EventFile, events))
228 printf(
"Error while read events.\n");
231 printf(
"Binary event file %s read\n",t_sEventName.toUtf8().constData());
238 printf(
"Text file %s is not supported jet.\n",t_sEventName.toUtf8().constData());
280 MatrixXi selected = MatrixXi::Zero(1, events.rows());
281 for (p = 0; p < events.rows(); ++p)
283 if (events(p,1) == 0 && events(p,2) == event)
285 selected(0,count) = p;
289 selected.conservativeResize(1, count);
291 printf(
"%d matching events found\n",count);
294 printf(
"No desired events found.\n");
299 fiff_int_t event_samp, from, to;
308 for (p = 0; p < count; ++p)
313 event_samp = events(selected(p),0);
314 from = event_samp + tmin*raw.info.sfreq;
315 to = event_samp + floor(tmax*raw.info.sfreq + 0.5);
319 if(raw.read_raw_segment(epoch->
epoch, timesDummy, from, to, picks))
323 times.resize(1, to-from+1);
324 for (qint32 i = 0; i < times.cols(); ++i)
325 times(0, i) = ((float)(from-event_samp+i)) / raw.info.sfreq;
328 epoch->
event = event;
329 epoch->
tmin = ((float)(from)-(float)(raw.first_samp))/raw.info.sfreq;
330 epoch->
tmax = ((
float)(to)-(
float)(raw.first_samp))/raw.info.sfreq;
336 printf(
"Can't read the event data segments");
342 data.
average(raw.info,raw.first_samp,raw.last_samp);
MNEEpochDataList class declaration.
FIFF raw measurement data.
FiffEvoked average(FiffInfo &p_info, fiff_int_t first, fiff_int_t last, VectorXi sel=defaultVectorXi, bool proj=false)
QSharedPointer< MNEEpochData > SPtr
FIFF class declaration, which provides static wrapper functions to stay consistent with mne matlab to...