173 QPair<float,float> t_baseline,
177 p_FiffEvoked.
clear();
183 QString t_sFileName = t_pStream->streamName();
185 qInfo(
"Reading %s ...\n",t_sFileName.toUtf8().constData());
187 if(!t_pStream->open())
194 if(!t_pStream->read_meas_info(t_pStream->dirtree(),
info, meas))
196 info.filename = t_sFileName;
201 if (processed.size() == 0)
203 qWarning(
"Could not find processed data");
207 QList<FiffDirNode::SPtr> evoked_node = meas->dir_tree_find(
FIFFB_EVOKED);
208 if (evoked_node.size() == 0)
210 qWarning(
"Could not find evoked data");
217 if (evoked_node.size() > 1)
219 QStringList comments;
220 QList<fiff_int_t> aspect_kinds;
222 if(!t_pStream->get_evoked_entries(evoked_node, comments, aspect_kinds, t))
223 t = QString(
"None found, must use integer");
224 qWarning(
"%lld datasets present, setno parameter must be set. Candidate setno names:\n%s", evoked_node.size(), t.toUtf8().constData());
233 bool t_bIsInteger =
true;
234 setno.toInt(&t_bIsInteger);
239 qWarning(
"kindStat must be \"FIFFV_ASPECT_AVERAGE\" or \"FIFFV_ASPECT_STD_ERR\"");
243 QStringList comments;
244 QList<fiff_int_t> aspect_kinds;
246 t_pStream->get_evoked_entries(evoked_node, comments, aspect_kinds, t);
249 for(qint32 i = 0; i < comments.size(); ++i)
251 if(comments[i].compare(setno.toString()) == 0 && p_aspect_kind == aspect_kinds[i])
260 qWarning() <<
"setno " << setno <<
" (" << p_aspect_kind <<
") not found, out of found datasets:\n " << t;
266 if (setno.toInt() >= evoked_node.size() || setno.toInt() < 0)
268 qWarning(
"Data set selector out of range");
277 QList<FiffDirNode::SPtr> aspects = my_evoked->dir_tree_find(
FIFFB_ASPECT);
279 if(aspects.size() > 1)
280 qInfo(
"\tMultiple (%lld) aspects found. Taking first one.\n", aspects.size());
289 QList<FiffChInfo> chs;
294 for (k = 0; k < my_evoked->nent(); ++k)
296 kind = my_evoked->dir[k]->kind;
297 pos = my_evoked->dir[k]->pos;
301 t_pStream->read_tag(t_pTag,pos);
305 t_pStream->read_tag(t_pTag,pos);
306 first = *t_pTag->toInt();
309 t_pStream->read_tag(t_pTag,pos);
310 last = *t_pTag->toInt();
313 t_pStream->read_tag(t_pTag,pos);
314 nchan = *t_pTag->toInt();
317 t_pStream->read_tag(t_pTag,pos);
318 sfreq = *t_pTag->toFloat();
321 t_pStream->read_tag(t_pTag, pos);
322 chs.append( t_pTag->toChInfo() );
327 comment = QString(
"No comment");
336 qWarning(
"Local channel information was not found when it was expected.");
339 if (chs.size() != nchan)
341 qWarning(
"Number of channels and number of channel definitions are different.");
346 qInfo(
"\tFound channel information in evoked data. nchan = %d\n",nchan);
351 qInfo(
"\tFound the data of interest:\n");
352 qInfo(
"\t\tt = %10.2f ... %10.2f ms (%s)\n", 1000*
static_cast<float>(
first)/
info.sfreq, 1000*
static_cast<float>(
last)/
info.sfreq,
comment.toUtf8().constData());
353 if (
info.comps.size() > 0)
354 qInfo(
"\t\t%lld CTF compensation matrices available\n",
info.comps.size());
361 QList<FiffTag> epoch;
362 for (k = 0; k < my_aspect->nent(); ++k)
364 kind = my_aspect->dir[k]->kind;
365 pos = my_aspect->dir[k]->pos;
370 t_pStream->read_tag(t_pTag, pos);
374 t_pStream->read_tag(t_pTag, pos);
378 t_pStream->read_tag(t_pTag, pos);
379 nave = *t_pTag->toInt();
382 t_pStream->read_tag(t_pTag, pos);
383 epoch.append(
FiffTag(*t_pTag));
391 qint32 nepoch = epoch.size();
398 all_data = epoch[0].toFloatMatrix().cast<
double>();
399 all_data.transposeInPlace();
403 if (all_data.cols() == 1 &&
info.nchan == 1)
404 all_data.transposeInPlace();
411 all_data = epoch[0].toFloatMatrix().cast<
double>();
412 all_data.transposeInPlace();
414 for (k = 1; k < nepoch; ++k)
416 oldsize = all_data.rows();
417 MatrixXd tmp = epoch[k].toFloatMatrix().cast<
double>();
418 tmp.transposeInPlace();
419 all_data.conservativeResize(oldsize+tmp.rows(), all_data.cols());
420 all_data.block(oldsize, 0, tmp.rows(), tmp.cols()) = tmp;
423 if (all_data.cols() != nsamp)
425 qWarning(
"Incorrect number of samples (%d instead of %d)", (
int) all_data.cols(), nsamp);
432 qInfo(
"\n\tPreprocessing...\n");
433 qInfo(
"\t%d channels remain after picking\n",
info.nchan);
435 using T = Eigen::Triplet<double>;
436 std::vector<T> tripletList;
437 tripletList.reserve(
info.nchan);
438 for(k = 0; k <
info.nchan; ++k)
439 tripletList.push_back(T(k, k,
info.chs[k].cal));
440 SparseMatrix<double> cals(
info.nchan,
info.nchan);
441 cals.setFromTriplets(tripletList.begin(), tripletList.end());
443 all_data = cals * all_data;
446 for (k = 0; k <
times.size(); ++k)
454 qInfo(
"\tNo projector specified for these data.\n");
455 p_FiffEvoked.
proj = MatrixXd();
461 qint32 nproj =
info.make_projector(projection);
464 qWarning(
"\tThe projection vectors do not apply to these channels\n");
465 p_FiffEvoked.
proj = MatrixXd();
469 qInfo(
"\tCreated an SSP operator (subspace dimension = %d)\n", nproj);
470 p_FiffEvoked.
proj = projection;
477 if(p_FiffEvoked.
proj.rows() > 0)
479 all_data = p_FiffEvoked.
proj * all_data;
480 qInfo(
"\tSSP projectors applied to the evoked data\n");
491 p_FiffEvoked.
data = all_data;
496 if (t_baseline.first != t_baseline.second) {
500 qInfo(
"\tNo baseline correction applied\n");