99 for (
int k = 0; k <
nset; k++)
113 const float tmin =
current->tmin;
119 else if (bmin > tmax)
122 for (b1 = 0; b1 /
sfreq + tmin < bmin; b1++)
124 b1 = qBound(0, b1,
current->np);
128 else if (bmax > tmax)
133 b2 = qBound(0, b2,
current->np);
136 Eigen::MatrixXf &bdata =
current->data;
138 for (
int c = 0; c <
nchan; c++) {
140 for (
int s = b1; s < b2; s++)
144 for (
int s = 0; s <
current->np; s++)
147 printf(
"\t%s : using baseline %7.1f ... %7.1f ms\n",
148 current->comment.toUtf8().constData() ?
current->comment.toUtf8().constData() :
"unknown",
149 1000 * (tmin + b1 /
sfreq),
150 1000 * (tmin + b2 /
sfreq));
160 const QStringList& namesp,
174 QPair<float,float>(-1.0f, -1.0f),
false))
176 printf(
"Failed to read evoked data from %s\n", name.toUtf8().constData());
183 const int nchan_file = evoked.
info.
nchan;
184 const int nsamp = evoked.
last - evoked.
first + 1;
186 const float dtmin =
static_cast<float>(evoked.
first) /
sfreq;
189 const int nave = evoked.
nave;
191 const QList<FiffChInfo>&
chs = evoked.
info.
chs;
193 const MatrixXf data = evoked.
data.cast<
float>();
205 std::vector<int> sel;
217 if (stim14_name.isEmpty() || stim14_name.size() == 0)
221 for (
int i = 0; i < add_to->
nchan; i++)
222 names.append(add_to->
chs[i].ch_name);
227 names =
op->eigen_fields->col_names;
231 names =
fwd->collist;
243 printf(
"\tMeasurement file id: %s\n",
id.toString().toUtf8().constData());
249 sel.assign(
nchan, -1);
250 for (c = 0; c < nchan_file; c++) {
251 for (k = 0; k <
nchan; k++) {
252 if (sel[k] == -1 && QString::compare(
chs[c].ch_name,names[k]) == 0) {
257 if (QString::compare(stim14_name,
chs[c].ch_name) == 0) {
261 for (k = 0; k <
nchan; k++)
263 printf(
"All channels needed were not in the MEG/EEG data file "
264 "(first missing: %s).",names[k].toUtf8().constData());
269 sel.resize(nchan_file);
270 for (c = 0,
nchan = 0; c < nchan_file; c++) {
275 if (QString::compare(stim14_name,
chs[c].ch_name) == 0) {
287 tmax = dtmin + (np-1)/
sfreq;
288 printf(
"\tData time range: %8.1f ... %8.1f ms\n",1000*tmin,1000*tmax);
317 if (!devHeadT.isEmpty()) {
318 new_data->
meg_head_t = std::make_unique<FiffCoordTrans>(devHeadT);
319 printf(
"\tUsing MEG <-> head transform from the present data set\n");
321 if (
op !=
nullptr && !
op->mri_head_t.isEmpty()) {
322 new_data->
mri_head_t = std::make_unique<FiffCoordTrans>(
op->mri_head_t);
323 printf(
"\tPicked MRI <-> head transform from the inverse operator\n");
328 for (k = 0; k <
nchan; k++) {
330 new_data->
chs[k] =
chs[sel[k]];
337 if (new_data->
proj && new_data->
proj->nitems > 0) {
338 printf(
"\tLoaded projection from %s:\n",name.toUtf8().data());
339 QTextStream errStream(stderr);
340 new_data->
proj->report(errStream,
"\t\t");
345 if (new_data->
proj && new_data->
proj->nitems > 0) {
346 printf(
"\tLoaded projection from %s:\n",name.toUtf8().data());
347 QTextStream errStream(stderr);
348 new_data->
proj->report(errStream,
"\t\t");
353 if (new_data->
comp->ncomp > 0)
354 printf(
"\tRead %d compensation data sets from %s\n",new_data->
comp->ncomp,name.toUtf8().data());
364 for (
int b = 0; b < new_data->
nbad; b++) {
365 for (k = 0; k < new_data->
nchan; k++) {
366 if (QString::compare(new_data->
chs[k].ch_name,new_data->
badlist[b],Qt::CaseInsensitive) == 0) {
372 printf(
"\t%d bad channels read from %s%s",new_data->
nbad,name.toUtf8().data(),new_data->
nbad > 0 ?
":\n" :
"\n");
373 if (new_data->
nbad > 0) {
375 for (k = 0; k < new_data->
nbad; k++)
376 printf(
"%s%c",new_data->
badlist[k].toUtf8().constData(),k < new_data->
nbad-1 ?
' ' :
'\n');
384 dataset->
tmin = tmin;
388 dataset->
nave = nave;
389 dataset->
kind = aspect_kind;
390 dataset->
data = Eigen::MatrixXf::Zero(np,
nchan);
396 for (k = 0; k <
nchan; k++) {
400 for (p = 0; p < np; p++)
401 dataset->
data(p, k) = data(sel[k], p + n1);
407 dataset->
stim14 = Eigen::VectorXf(np);
408 for (p = 0; p < np; p++)
409 dataset->
stim14[p] = data(stim14, p + n1) /
chs[stim14].cal;
411 new_data->
sets.append(dataset); dataset =
nullptr;
416 printf(
"\t%s dataset %s from %s\n",
417 add_to ?
"Added" :
"Loaded",
418 new_data->
sets[new_data->
nset-1]->comment.toUtf8().constData() ? new_data->
sets[new_data->
nset-1]->comment.toUtf8().constData() :
"unknown",name.toUtf8().data());
421 if (res ==
nullptr && !add_to)
433 const QStringList& namesp,
FiffEvoked class declaration.
Old fiff_type declarations - replace them.
FiffCoordTrans class declaration.
MNEInverseOperator 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.
MNEMeasDataSet class declaration.
MNEMeasData class declaration.
MNENamedMatrix 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 MNEProjOp * read(const QString &name)