93 for (
int k = 0; k <
nset; k++)
107 const float tmin =
current->tmin;
113 else if (bmin > tmax)
116 for (b1 = 0; b1 /
sfreq + tmin < bmin; b1++)
118 b1 = qBound(0, b1,
current->np);
122 else if (bmax > tmax)
127 b2 = qBound(0, b2,
current->np);
130 Eigen::MatrixXf &bdata =
current->data;
132 for (
int c = 0; c <
nchan; c++) {
134 for (
int s = b1; s < b2; s++)
138 for (
int s = 0; s <
current->np; s++)
141 qInfo(
"\t%s : using baseline %7.1f ... %7.1f ms\n",
142 current->comment.toUtf8().constData() ?
current->comment.toUtf8().constData() :
"unknown",
143 1000 * (tmin + b1 /
sfreq),
144 1000 * (tmin + b2 /
sfreq));
154 const QStringList& namesp,
168 QPair<float,float>(-1.0f, -1.0f),
false))
170 qCritical(
"Failed to read evoked data from %s\n", name.toUtf8().constData());
177 const int nchan_file = evoked.
info.
nchan;
178 const int nsamp = evoked.
last - evoked.
first + 1;
180 const float dtmin =
static_cast<float>(evoked.
first) /
sfreq;
183 const int nave = evoked.
nave;
185 const QList<FiffChInfo>&
chs = evoked.
info.
chs;
187 const MatrixXf data = evoked.
data.cast<
float>();
211 if (stim14_name.isEmpty() || stim14_name.size() == 0)
215 for (
int i = 0; i < add_to->
nchan; i++)
216 names.append(add_to->
chs[i].ch_name);
221 names =
op->eigen_fields->col_names;
225 names =
fwd->collist;
237 qInfo(
"\tMeasurement file id: %s\n",
id.toString().toUtf8().constData());
243 sel = Eigen::VectorXi::Constant(
nchan, -1);
244 for (c = 0; c < nchan_file; c++) {
245 for (k = 0; k <
nchan; k++) {
246 if (sel[k] == -1 && QString::compare(
chs[c].ch_name,names[k]) == 0) {
251 if (QString::compare(stim14_name,
chs[c].ch_name) == 0) {
255 for (k = 0; k <
nchan; k++)
257 qCritical(
"All channels needed were not in the MEG/EEG data file "
258 "(first missing: %s).",names[k].toUtf8().constData());
263 sel.resize(nchan_file);
265 for (c = 0,
nchan = 0; c < nchan_file; c++) {
270 if (QString::compare(stim14_name,
chs[c].ch_name) == 0) {
282 tmax = dtmin + (np-1)/
sfreq;
283 qInfo(
"\tData time range: %8.1f ... %8.1f ms\n",1000*tmin,1000*tmax);
312 if (!devHeadT.isEmpty()) {
313 new_data->
meg_head_t = std::make_unique<FiffCoordTrans>(devHeadT);
314 qInfo(
"\tUsing MEG <-> head transform from the present data set\n");
316 if (
op !=
nullptr && !
op->mri_head_t.isEmpty()) {
317 new_data->
mri_head_t = std::make_unique<FiffCoordTrans>(
op->mri_head_t);
318 qInfo(
"\tPicked MRI <-> head transform from the inverse operator\n");
323 for (k = 0; k <
nchan; k++) {
325 new_data->
chs[k] =
chs[sel[k]];
332 if (new_data->
proj && new_data->
proj->nitems > 0) {
333 qInfo(
"\tLoaded projection from %s:\n",name.toUtf8().data());
334 QTextStream errStream(stderr);
335 new_data->
proj->report(errStream, QStringLiteral(
"\t\t"));
340 if (new_data->
proj && new_data->
proj->nitems > 0) {
341 qInfo(
"\tLoaded projection from %s:\n",name.toUtf8().data());
342 QTextStream errStream(stderr);
343 new_data->
proj->report(errStream, QStringLiteral(
"\t\t"));
346 if (!new_data->
comp) {
350 if (new_data->
comp->ncomp > 0)
351 qInfo(
"\tRead %d compensation data sets from %s\n",new_data->
comp->ncomp,name.toUtf8().data());
359 new_data->
bad = Eigen::VectorXi::Zero(new_data->
nchan);
361 for (
int b = 0; b < new_data->
nbad; b++) {
362 for (k = 0; k < new_data->
nchan; k++) {
363 if (QString::compare(new_data->
chs[k].ch_name,new_data->
badlist[b],Qt::CaseInsensitive) == 0) {
364 new_data->
bad[k] = 1;
369 qInfo(
"\t%d bad channels read from %s%s",new_data->
nbad,name.toUtf8().data(),new_data->
nbad > 0 ?
":\n" :
"\n");
370 if (new_data->
nbad > 0) {
372 for (k = 0; k < new_data->
nbad; k++)
373 qInfo(
"%s%c",new_data->
badlist[k].toUtf8().constData(),k < new_data->
nbad-1 ?
' ' :
'\n');
381 dataset->
tmin = tmin;
385 dataset->
nave = nave;
386 dataset->
kind = aspect_kind;
387 dataset->
data = Eigen::MatrixXf::Zero(np,
nchan);
393 for (k = 0; k <
nchan; k++) {
397 for (p = 0; p < np; p++)
398 dataset->
data(p, k) = data(sel[k], p + n1);
404 dataset->
stim14 = Eigen::VectorXf(np);
405 for (p = 0; p < np; p++)
406 dataset->
stim14[p] = data(stim14, p + n1) /
chs[stim14].cal;
408 new_data->
sets.append(dataset); dataset =
nullptr;
413 qInfo(
"\t%s dataset %s from %s\n",
414 add_to ?
"Added" :
"Loaded",
415 new_data->
sets[new_data->
nset-1]->comment.toUtf8().constData() ? new_data->
sets[new_data->
nset-1]->comment.toUtf8().constData() :
"unknown",name.toUtf8().data());
417 if (res ==
nullptr && !add_to)
428 const QStringList& namesp,
FiffEvoked class declaration.
Old fiff_type declarations - replace them.
FiffCoordTrans class declaration.
Legacy MNE-C constants and common typedefs.
#define MNE_ENV_TRIGGER_CH
Environment variable overriding the trigger channel name.
#define MNE_DEFAULT_TRIGGER_CH
Default digital trigger channel name.
MNENamedMatrix class declaration.
MNEMeasData class declaration.
MNEInverseOperator class declaration.
MNEMeasDataSet class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
Coordinate transformation description.
static bool read(QIODevice &p_IODevice, FiffEvoked &p_FiffEvoked, QVariant setno=0, QPair< float, float > t_baseline=defaultFloatPair, bool proj=true, fiff_int_t p_aspect_kind=FIFFV_ASPECT_AVERAGE)
Universally unique identifier.
FiffCoordTrans dev_head_t
Time stamp record storing seconds and microseconds since epoch.
static std::unique_ptr< MNECTFCompDataSet > read(const QString &name)
MNE-style inverse operator.
static MNEMeasData * mne_read_meas_data_add(const QString &name, int set, MNEInverseOperator *op, MNENamedMatrix *fwd, const QStringList &namesp, int nnamesp, MNEMeasData *add_to)
Read an evoked-response data set and append it to an existing container.
void adjust_baselines(float bmin, float bmax)
Adjust baseline offset of the current data set.
~MNEMeasData()
Destroys the measurement data and all owned data sets.
MNEMeasData()
Constructs an empty measurement data container.
FIFFLIB::FiffTime meas_date
std::unique_ptr< FIFFLIB::FiffCoordTrans > meg_head_t
QList< MNEMeasDataSet * > sets
std::unique_ptr< MNECTFCompDataSet > comp
QList< FIFFLIB::FiffChInfo > chs
std::unique_ptr< FIFFLIB::FiffCoordTrans > mri_head_t
std::unique_ptr< MNEProjOp > proj
static MNEMeasData * mne_read_meas_data(const QString &name, int set, MNEInverseOperator *op, MNENamedMatrix *fwd, const QStringList &namesp, int nnamesp)
Read an evoked-response data set into a new container.
Single measurement epoch or average within MNEMeasData.
Eigen::VectorXf baselines
A dense matrix with named rows and columns.
static std::unique_ptr< MNEProjOp > read(const QString &name)