72 for (
int k = 0; k <
nset; k++)
86 const float tmin =
current->tmin;
95 for (b1 = 0; b1 /
sfreq + tmin < bmin; b1++)
97 b1 = qBound(0, b1,
current->np);
101 else if (bmax > tmax)
106 b2 = qBound(0, b2,
current->np);
109 Eigen::MatrixXf &bdata =
current->data;
111 for (
int c = 0; c <
nchan; c++) {
113 for (
int s = b1; s < b2; s++)
117 for (
int s = 0; s <
current->np; s++)
120 qInfo(
"\t%s : using baseline %7.1f ... %7.1f ms\n",
121 current->comment.toUtf8().constData() ?
current->comment.toUtf8().constData() :
"unknown",
122 1000 * (tmin + b1 /
sfreq),
123 1000 * (tmin + b2 /
sfreq));
133 const QStringList& namesp,
147 QPair<float,float>(-1.0f, -1.0f),
false))
149 qCritical(
"Failed to read evoked data from %s\n", name.toUtf8().constData());
156 const int nchan_file = evoked.
info.
nchan;
157 const int nsamp = evoked.
last - evoked.
first + 1;
159 const float dtmin =
static_cast<float>(evoked.
first) /
sfreq;
162 const int nave = evoked.
nave;
164 const QList<FiffChInfo>&
chs = evoked.
info.
chs;
166 const MatrixXf data = evoked.
data.cast<
float>();
190 if (stim14_name.isEmpty() || stim14_name.size() == 0)
194 for (
int i = 0; i < add_to->
nchan; i++)
195 names.append(add_to->
chs[i].ch_name);
200 names =
op->eigen_fields->col_names;
204 names =
fwd->collist;
216 qInfo(
"\tMeasurement file id: %s\n",
id.toString().toUtf8().constData());
222 sel = Eigen::VectorXi::Constant(
nchan, -1);
223 for (c = 0; c < nchan_file; c++) {
224 for (k = 0; k <
nchan; k++) {
225 if (sel[k] == -1 && QString::compare(
chs[c].ch_name,names[k]) == 0) {
230 if (QString::compare(stim14_name,
chs[c].ch_name) == 0) {
234 for (k = 0; k <
nchan; k++)
236 qCritical(
"All channels needed were not in the MEG/EEG data file "
237 "(first missing: %s).",names[k].toUtf8().constData());
242 sel.resize(nchan_file);
244 for (c = 0,
nchan = 0; c < nchan_file; c++) {
249 if (QString::compare(stim14_name,
chs[c].ch_name) == 0) {
261 tmax = dtmin + (np-1)/
sfreq;
262 qInfo(
"\tData time range: %8.1f ... %8.1f ms\n",1000*tmin,1000*tmax);
291 if (!devHeadT.isEmpty()) {
292 new_data->
meg_head_t = std::make_unique<FiffCoordTrans>(devHeadT);
293 qInfo(
"\tUsing MEG <-> head transform from the present data set\n");
295 if (
op !=
nullptr && !
op->mri_head_t.isEmpty()) {
296 new_data->
mri_head_t = std::make_unique<FiffCoordTrans>(
op->mri_head_t);
297 qInfo(
"\tPicked MRI <-> head transform from the inverse operator\n");
302 for (k = 0; k <
nchan; k++) {
304 new_data->
chs[k] =
chs[sel[k]];
311 if (new_data->
proj && new_data->
proj->nitems > 0) {
312 qInfo(
"\tLoaded projection from %s:\n",name.toUtf8().data());
313 QTextStream errStream(stderr);
314 new_data->
proj->report(errStream, QStringLiteral(
"\t\t"));
319 if (new_data->
proj && new_data->
proj->nitems > 0) {
320 qInfo(
"\tLoaded projection from %s:\n",name.toUtf8().data());
321 QTextStream errStream(stderr);
322 new_data->
proj->report(errStream, QStringLiteral(
"\t\t"));
325 if (!new_data->
comp) {
329 if (new_data->
comp->ncomp > 0)
330 qInfo(
"\tRead %d compensation data sets from %s\n",new_data->
comp->ncomp,name.toUtf8().data());
338 new_data->
bad = Eigen::VectorXi::Zero(new_data->
nchan);
340 for (
int b = 0; b < new_data->
nbad; b++) {
341 for (k = 0; k < new_data->
nchan; k++) {
342 if (QString::compare(new_data->
chs[k].ch_name,new_data->
badlist[b],Qt::CaseInsensitive) == 0) {
343 new_data->
bad[k] = 1;
348 qInfo(
"\t%d bad channels read from %s%s",new_data->
nbad,name.toUtf8().data(),new_data->
nbad > 0 ?
":\n" :
"\n");
349 if (new_data->
nbad > 0) {
351 for (k = 0; k < new_data->
nbad; k++)
352 qInfo(
"%s%c",new_data->
badlist[k].toUtf8().constData(),k < new_data->
nbad-1 ?
' ' :
'\n');
360 dataset->
tmin = tmin;
364 dataset->
nave = nave;
365 dataset->
kind = aspect_kind;
366 dataset->
data = Eigen::MatrixXf::Zero(np,
nchan);
372 for (k = 0; k <
nchan; k++) {
376 for (p = 0; p < np; p++)
377 dataset->
data(p, k) = data(sel[k], p + n1);
383 dataset->
stim14 = Eigen::VectorXf(np);
384 for (p = 0; p < np; p++)
385 dataset->
stim14[p] = data(stim14, p + n1) /
chs[stim14].cal;
387 new_data->
sets.append(dataset); dataset =
nullptr;
392 qInfo(
"\t%s dataset %s from %s\n",
393 add_to ?
"Added" :
"Loaded",
394 new_data->
sets[new_data->
nset-1]->comment.toUtf8().constData() ? new_data->
sets[new_data->
nset-1]->comment.toUtf8().constData() :
"unknown",name.toUtf8().data());
396 if (res ==
nullptr && !add_to)
407 const QStringList& namesp,
One condition / averaging slice within a legacy MNELIB::MNEMeasData.
Pre-computed inverse operator (whitened SVD of the forward model) for MNE/dSPM/sLORETA.
Row/column-labelled dense matrix used wherever FIFF stores per-channel data.
Legacy MNE-C constants and shared typedefs used across MNELIB structures.
#define MNE_ENV_TRIGGER_CH
Environment variable overriding the trigger channel name.
#define MNE_DEFAULT_TRIGGER_CH
Default digital trigger channel name.
Legacy MNE-C measurement-data container assembling raw/evoked sets and their projection state.
Single averaged evoked response: time axis, samples, baseline, channel info and processing history.
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
Primitive scalar typedefs and forward-compatible aliases backing the FIFF type system.
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O, in-memory data structures and high-level readers/writers.
Per-channel FIFF descriptor: identifiers, kind, calibration, coil type, channel-frame coil position a...
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
Single averaged evoked response: time axis, data, baseline, channel info and averaging metadata.
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)
128-bit FIFF identifier: hardware machine ID plus creation time, stamped on every file and block.
FiffCoordTrans dev_head_t
FIFF time stamp: Unix seconds plus a microsecond fraction matching the on-disk fiffTimeRec record.
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)