82: QDataStream(p_pIODevice)
84 this->setFloatingPointPrecision(QDataStream::SinglePrecision);
85 this->setByteOrder(QDataStream::BigEndian);
86 this->setVersion(QDataStream::Qt_5_0);
92 QIODevice::OpenMode mode)
95 this->setFloatingPointPrecision(QDataStream::SinglePrecision);
96 this->setByteOrder(QDataStream::BigEndian);
97 this->setVersion(QDataStream::Qt_5_0);
104 QFile* t_pFile = qobject_cast<QFile*>(this->device());
107 p_sFileName = t_pFile->fileName();
109 p_sFileName = QString(
"TCPSocket");
162 *this << static_cast<qint32>(
FIFF_NOP);
164 *this << static_cast<qint32>(datasize);
183 aspect_kinds.clear();
184 QList<FiffDirNode::SPtr>::ConstIterator ev;
189 for (ev = evoked_node.begin(); ev != evoked_node.end(); ++ev) {
190 for (k = 0; k < (*ev)->nent(); ++k) {
191 kind = (*ev)->dir[k]->kind;
192 pos = (*ev)->dir[k]->pos;
195 comments.append(t_pTag->toString());
199 for (k = 0; k < my_aspect->nent(); ++k) {
200 kind = my_aspect->dir[k]->kind;
201 pos = my_aspect->dir[k]->pos;
204 aspect_kinds.append(*t_pTag->toInt());
209 if (comments.size() != aspect_kinds.size() || comments.size() == 0) {
210 qWarning(
"Dataset names in FIF file could not be found.");
215 for (k = 0; k < aspect_kinds.size(); ++k) {
216 t += QString(
"%1 - \"%2\" (").arg(k).arg(comments[k]);
218 t += QString(
"FIFFV_ASPECT_AVERAGE)\n");
220 t += QString(
"FIFFV_ASPECT_STD_ERR)\n");
222 t += QString(
"unknown)\n");
238 if (!this->device()->
open(mode)) {
239 qCritical(
"Cannot open %s\n", t_sFileName.toUtf8().constData());
243 if (!check_beginning(t_pTag))
250 qCritical(
"FIFF file should start with FIFF_FILE_ID!");
251 this->device()->close();
254 m_id = t_pTag->toFiffID();
258 qWarning(
"Fiff::open: file does have a directory pointer");
259 this->device()->close();
266 qInfo(
"Creating tag directory for %s...", t_sFileName.toUtf8().constData());
268 qint32 dirpos = *t_pTag->toInt();
274 m_dir = this->make_dir(&ok);
276 qCritical(
"Could not create tag directory!");
280 if (!this->
read_tag(t_pTag, dirpos)) {
281 qCritical(
"Could not read the tag directory (file probably damaged)!");
284 m_dir = t_pTag->toDirEntry();
290 if (m_dir[m_dir.size() - 2]->kind ==
FIFF_DIR) {
292 m_dir[m_dir.size() - 1]->kind = -1;
293 m_dir[m_dir.size() - 1]->type = -1;
294 m_dir[m_dir.size() - 1]->size = -1;
295 m_dir[m_dir.size() - 1]->pos = -1;
301 if ((this->m_dirtree = this->
make_subtree(m_dir)) ==
nullptr)
304 this->m_dirtree->parent.clear();
309 this->device()->seek(SEEK_SET);
317 if (this->device()->isOpen())
318 this->device()->close();
331 QList<FiffDirEntry::SPtr>
dir;
334 node->dir_tree = dentry;
340 if (!this->
read_tag(t_pTag, dentry[current]->pos))
343 node->type = *t_pTag->toInt();
345 node->id = this->
id();
350 for (; current < dentry.size(); ++current) {
355 QList<FiffDirEntry::SPtr> sub_dentry = dentry.mid(current);
358 child->parent = node;
359 node->children.append(child);
365 }
else if (dentry[current]->kind == -1)
367 else if (level == 0) {
374 if (!this->
read_tag(t_pTag, dentry[current]->pos))
376 node->id = t_pTag->toFiffID();
427 for (insert = -1, b = 0; insert_blocks[b] >= 0; b++) {
428 for (k = 0; k <
nent(); k++) {
432 if (*(t_pTag->toInt()) == insert_blocks[b]) {
442 qCritical(
"Suitable place for environment insertion not found.");
450 if (where < 0 || where >=
nent() - 1) {
451 qCritical(
"illegal insertion point in fiff_insert_after!");
456 QList<FiffDirEntry::SPtr> old_dir =
dir();
457 QList<FiffDirEntry::SPtr> this_ent = old_dir.mid(where);
459 if (!
read_tag(t_pTagNext, this_ent[0]->pos))
464 qint64 next_tmp = device()->pos();
468 device()->seek(device()->size());
472 QList<FiffDirEntry::SPtr> new_dir = old_dir.mid(0, where + 1);
474 qint64 old_end = device()->pos();
483 new_this->size = 1 * 4;
485 new_dir.append(new_this);
490 new_this->size = 5 * 4;
492 new_dir.append(new_this);
497 new_this->size = workingDir.size();
499 new_dir.append(new_this);
504 new_this->size = command.size();
506 new_dir.append(new_this);
511 new_this->size = 1 * 4;
513 new_dir.append(new_this);
518 new_dir.append(old_dir.mid(where + 1));
522 t_pTagNext->next =
static_cast<qint32
>(old_end);
539 QList<FiffDirNode::SPtr> covs = p_Node->dir_tree_find(
FIFFB_MNE_COV);
540 if (covs.size() == 0) {
541 qWarning(
"No covariance matrices found");
549 bool success =
false;
552 bool diagmat =
false;
559 for (p = 0; p < covs.size(); ++p) {
561 if (success && *tag->toInt() == cov_kind) {
567 qWarning(
"Covariance matrix dimension not found.\n");
574 nfree = *tag->toInt();
578 if (names.size() != dim) {
579 qWarning(
"Number of names does not match covariance matrix dimension\n");
585 qWarning(
"No covariance matrix data found\n");
592 cov_diag = Map<const VectorXd>(tag->toDouble(), dim);
594 cov_diag = Map<const VectorXf>(tag->toFloat(), dim).cast<
double>();
596 qCritical(
"Illegal data type for covariance matrix\n");
601 qInfo(
"\t%d x %d diagonal covariance (kind = %d) found.\n", dim, dim, cov_kind);
605 nn = dim * (dim + 1) / 2;
607 vals = Map<const VectorXd>(tag->toDouble(), nn);
609 vals = Map<const VectorXf>(tag->toFloat(), nn).cast<
double>();
611 qDebug() << tag->getInfo();
619 cov = MatrixXd::Zero(dim, dim);
623 for (qint32 j = 0; j < dim; ++j) {
624 for (qint32 k = 0; k <= j; ++k) {
629 for (qint32 j = 0; j < dim; ++j)
630 for (qint32 k = j + 1; k < dim; ++k)
631 cov(j, k) = cov(k, j);
634 qInfo(
"\t%d x %d full covariance (kind = %d) found.\n", dim, dim, cov_kind);
638 qDebug() <<
"ToDo: FiffStream::read_cov - this needs to be debugged.\n";
640 qInfo(
"\t%d x %d sparse covariance (kind = %d) found.\n", dim, dim, cov_kind);
678 eig = VectorXd(Map<const VectorXd>(tag1->toDouble(), dim));
679 eigvec = tag2->toFloatMatrix().cast<
double>();
680 eigvec.transposeInPlace();
685 QList<FiffProj> projs = this->
read_proj(current);
695 p_covData.
kind = cov_kind;
696 p_covData.
diag = diagmat;
698 p_covData.
names = names;
700 if (cov_diag.size() > 0)
701 p_covData.
data = cov_diag;
702 else if (cov.size() > 0)
703 p_covData.
data = cov;
704 else if (cov_sparse.size() > 0)
705 p_covData.
data = cov_sparse;
707 p_covData.
projs = projs;
708 p_covData.
bads = bads;
709 p_covData.
nfree = nfree;
711 p_covData.
eigvec = eigvec;
718 qInfo(
"Did not find the desired covariance matrix\n");
726 QList<FiffCtfComp> compdata;
732 for (k = 0; k < t_qListComps.size(); ++k) {
739 for (p = 0; p < node->nent(); ++p) {
740 kind = node->dir[p]->kind;
741 pos = node->dir[p]->pos;
748 qWarning(
"Compensation type not found\n");
755 one.
ctfkind = *t_pTag->toInt();
762 else if (one.
ctfkind == 1194476114)
764 else if (one.
ctfkind == 1194541650)
766 else if (one.
ctfkind == 1194479433)
768 else if (one.
ctfkind == 1194544969)
773 for (p = 0; p < node->nent(); ++p) {
774 kind = node->dir[p]->kind;
775 pos = node->dir[p]->pos;
785 calibrated =
static_cast<bool>(*t_pTag->toInt());
791 compdata.append(one);
794 if (compdata.size() > 0)
795 qInfo(
"\tRead %lld compensation matrices\n",
static_cast<long long>(compdata.size()));
810 QList<FiffDirNode::SPtr> t_qListDigData = p_Node->dir_tree_find(
FIFFB_ISOTRAK);
813 if (t_qListDigData.isEmpty()) {
816 if (t_qListDigData.isEmpty()) {
817 qWarning(
"No Isotrak data found in %s", this->
streamName().toLatin1().data());
827 for (
int k = 0; k < t_qListDigData.first()->
nent(); ++k) {
828 kind = t_qListDigData.first()->dir[k]->kind;
829 pos = t_qListDigData.first()->dir[k]->pos;
834 p_digData.
points.append(t_pTag->toDigPoint());
843 npoint = p_digData.
points.size();
846 qWarning(
"No digitizer data in %s", this->
streamName().toLatin1().data());
850 for (
auto& dig : p_digData.
points) {
856 p_digData.
npoint = npoint;
858 for (
int k = 0; k < p_digData.
npoint; k++) {
859 p_digData.
active.append(1);
870 p_InfoForward.
clear();
877 if (parent_meg.size() == 0) {
878 qWarning(
"No parent MEG information found in operator\n");
884 QList<FiffChInfo> chs;
889 for (qint32 k = 0; k < parent_meg[0]->nent(); ++k) {
890 kind = parent_meg[0]->dir[k]->kind;
891 pos = parent_meg[0]->dir[k]->pos;
894 chs.append(t_pTag->toChInfo());
902 p_InfoForward.
chs = chs;
903 for (qint32 c = 0; c < p_InfoForward.
chs.size(); ++c)
904 p_InfoForward.
ch_names << p_InfoForward.
chs[c].ch_name;
906 p_InfoForward.
nchan = chs.size();
912 cand = t_pTag->toCoordTrans();
918 qWarning(
"MEG device/head coordinate transformation not found");
920 qWarning(
"MEG/head coordinate transformation not found.\n");
940 QList<FiffDirNode::SPtr> meas = p_Node->dir_tree_find(
FIFFB_MEAS);
942 if (meas.size() == 0) {
943 qWarning(
"Could not find measurement data\n");
947 QList<FiffDirNode::SPtr> meas_info = meas[0]->dir_tree_find(
FIFFB_MEAS_INFO);
948 if (meas_info.count() == 0) {
949 qWarning(
"Could not find measurement info\n");
960 float linefreq = -1.0f;
961 QList<FiffChInfo> chs;
962 float lowpass = -1.0f;
963 float highpass = -1.0f;
966 QString proj_name =
"";
967 QString xplotter_layout =
"";
969 QString utc_offset =
"";
972 QString experimenter =
"";
973 QString description =
"";
980 QList<FiffCoordTrans> all_coord_trans;
989 for (qint32 k = 0; k < meas_info[0]->nent(); ++k) {
990 kind = meas_info[0]->dir[k]->kind;
991 pos = meas_info[0]->dir[k]->pos;
995 nchan = *t_pTag->toInt();
999 sfreq = *t_pTag->toFloat();
1003 linefreq = *t_pTag->toFloat();
1007 chs.append(t_pTag->toChInfo());
1011 lowpass = *t_pTag->toFloat();
1015 highpass = *t_pTag->toFloat();
1019 meas_date[0] = t_pTag->toInt()[0];
1020 meas_date[1] = t_pTag->toInt()[1];
1025 cand = t_pTag->toCoordTrans();
1026 all_coord_trans.append(cand);
1034 proj_id = *t_pTag->toInt();
1038 proj_name = t_pTag->toString();
1042 xplotter_layout = t_pTag->toString();
1046 experimenter = t_pTag->toString();
1050 description = t_pTag->toString();
1056 gantry_angle =
static_cast<fiff_int_t>(*t_pTag->toFloat());
1057 }
else if (t_pTag->getType() ==
FIFFT_INT) {
1058 gantry_angle = *t_pTag->toInt();
1063 utc_offset = t_pTag->toString();
1071 qWarning(
"Number of channels in not defined\n");
1075 qWarning(
"Sampling frequency is not defined\n");
1079 qWarning(
"Line frequency is not defined\n");
1081 if (chs.size() == 0) {
1082 qWarning(
"Channel information not defined\n");
1085 if (chs.size() != nchan) {
1086 qWarning(
"Incorrect number of channel definitions found\n");
1091 QList<FiffDirNode::SPtr> hpi_result = meas_info[0]->dir_tree_find(
FIFFB_HPI_RESULT);
1092 if (hpi_result.size() == 1) {
1093 for (qint32 k = 0; k < hpi_result[0]->nent(); ++k) {
1094 kind = hpi_result[0]->dir[k]->kind;
1095 pos = hpi_result[0]->dir[k]->pos;
1098 cand = t_pTag->toCoordTrans();
1110 QList<FiffDirNode::SPtr> isotrak = meas_info[0]->dir_tree_find(
FIFFB_ISOTRAK);
1112 QList<FiffDigPoint> dig;
1117 if (isotrak.size() == 1) {
1118 for (k = 0; k < isotrak[0]->nent(); ++k) {
1119 kind = isotrak[0]->dir[k]->kind;
1120 pos = isotrak[0]->dir[k]->pos;
1123 dig.append(t_pTag->toDigPoint());
1127 coord_frame = *t_pTag->toInt();
1130 dig_trans = t_pTag->toCoordTrans();
1135 for (k = 0; k < dig.size(); ++k)
1136 dig[k].coord_frame = coord_frame;
1139 if (dig_trans.
from != coord_frame && dig_trans.
to != coord_frame)
1145 QList<FiffDirNode::SPtr> acqpars = meas_info[0]->dir_tree_find(
FIFFB_DACQ_PARS);
1148 if (acqpars.size() == 1) {
1149 for (k = 0; k < acqpars[0]->nent(); ++k) {
1150 kind = acqpars[0]->dir[k]->kind;
1151 pos = acqpars[0]->dir[k]->pos;
1154 acq_pars = t_pTag->toString();
1157 acq_stim = t_pTag->toString();
1164 QList<FiffProj> projs = this->
read_proj(meas_info[0]);
1168 QList<FiffCtfComp> comps = this->
read_ctf_comp(meas_info[0], chs);
1177 if (p_Node->id.version != -1)
1185 if (meas_info[0]->parent_id.version == -1) {
1186 if (meas_info[0]->
id.version == -1) {
1187 if (meas[0]->
id.version == -1) {
1188 if (meas[0]->parent_id.version == -1)
1191 info.
meas_id = meas[0]->parent_id;
1195 info.
meas_id = meas_info[0]->id;
1197 info.
meas_id = meas_info[0]->parent_id;
1199 if (meas_date[0] == -1) {
1211 if (highpass != -1.0f)
1216 if (lowpass != -1.0f)
1226 for (qint32 c = 0; c < info.
nchan; ++c)
1268 QList<FiffDirNode::SPtr> hpi_meas = meas_info[0]->dir_tree_find(
FIFFB_HPI_MEAS);
1269 if (!hpi_meas.isEmpty()) {
1270 QList<FiffDirNode::SPtr> hpi_coils = hpi_meas[0]->dir_tree_find(
FIFFB_HPI_COIL);
1272 for (qint32 c = 0; c < hpi_coils.size(); ++c) {
1273 for (qint32 e = 0; e < hpi_coils[c]->nent(); ++e) {
1278 this->
read_tag(t_pTag, hpi_coils[c]->
dir[e]->pos);
1285 p_NodeInfo = meas[0];
1300 bool found_it =
false;
1302 for (
int k = 0; k < node->nchild(); ++k) {
1304 if (node->children[k]->has_tag(matkind)) {
1305 node = node->children[k];
1312 qWarning(
"Fiff::read_named_matrix: Desired named matrix (kind = %d) not available\n", matkind);
1316 if (!node->has_tag(matkind)) {
1317 qWarning(
"Desired named matrix (kind = %d) not available", matkind);
1326 if (!node->find_tag(
this, matkind, t_pTag)) {
1327 qWarning(
"Matrix data missing.\n");
1331 mat.
data = t_pTag->toFloatMatrix().cast<
double>();
1332 mat.
data.transposeInPlace();
1339 if (*t_pTag->toInt() != mat.
nrow) {
1340 qWarning(
"Number of rows in matrix data and FIFF_MNE_NROW tag do not match");
1344 if (*t_pTag->toInt() != mat.
ncol) {
1345 qWarning(
"Number of columns in matrix data and FIFF_MNE_NCOL tag do not match");
1351 row_names = t_pTag->toString();
1355 col_names = t_pTag->toString();
1360 if (!row_names.isEmpty())
1363 if (!col_names.isEmpty())
1367 qWarning(
"FiffStream::read_named_matrix - Number of rows in matrix data and row names do not match\n");
1371 qWarning(
"FiffStream::read_named_matrix - Number of columns in matrix data and column names do not match\n");
1381 QList<FiffProj> projdata;
1385 QList<FiffDirNode::SPtr> t_qListNodes = p_Node->dir_tree_find(
FIFFB_PROJ);
1386 if (t_qListNodes.size() == 0)
1390 t_qListNodes[0]->find_tag(
this,
FIFF_NCHAN, t_pTag);
1393 global_nchan = *t_pTag->toInt();
1396 QList<FiffDirNode::SPtr> t_qListItems = t_qListNodes[0]->dir_tree_find(
FIFFB_PROJ_ITEM);
1397 for (qint32 i = 0; i < t_qListItems.size(); ++i) {
1402 t_pFiffDirTreeItem->find_tag(
this,
FIFF_NCHAN, t_pTag);
1404 nchan = *t_pTag->toInt();
1406 nchan = global_nchan;
1411 desc = t_pTag->toString();
1413 t_pFiffDirTreeItem->find_tag(
this,
FIFF_NAME, t_pTag);
1415 desc = t_pTag->toString();
1417 qWarning(
"Projection item description missing\n");
1435 kind = *t_pTag->toInt();
1437 qWarning(
"Projection item kind missing");
1443 nvec = *t_pTag->toInt();
1445 qWarning(
"Number of projection vectors not specified\n");
1453 qWarning(
"Projection item channel list missing\n");
1459 data = t_pTag->toFloatMatrix().cast<
double>();
1460 data.transposeInPlace();
1462 qWarning(
"Projection item data missing\n");
1468 active = *t_pTag->toInt();
1472 if (data.cols() != names.size()) {
1473 qWarning(
"Number of channel names does not match the size of data matrix\n");
1480 QStringList defaultList;
1481 FiffNamedMatrix t_fiffNamedMatrix(nvec, nchan, defaultList, names, data);
1483 FiffProj one(kind, active, desc, t_fiffNamedMatrix);
1485 projdata.append(one);
1488 if (projdata.size() > 0) {
1489 qInfo(
"\tRead a total of %lld projection items:\n",
static_cast<long long>(projdata.size()));
1490 for (qint32 k = 0; k < projdata.size(); ++k) {
1491 qInfo(
"\t\t%s (%d x %d) %s\n", projdata[k].desc.toUtf8().constData(), projdata[k].data->nrow, projdata[k].data->ncol, projdata[k].active ?
"active" :
"idle");
1503 this->device()->seek(pos);
1512 if (p_pTag->size() > 0) {
1513 this->readRawData(p_pTag->data(), p_pTag->size());
1518 this->device()->seek(p_pTag->next);
1529 p_pTag = std::make_unique<FiffTag>();
1539 *
this >> p_pTag->kind;
1540 *
this >> p_pTag->type;
1543 p_pTag->resize(size);
1544 *
this >> p_pTag->next;
1549 QTcpSocket* t_qTcpSocket = qobject_cast<QTcpSocket*>(this->device());
1551 this->skipRawData(p_pTag->size());
1553 if (p_pTag->next > 0) {
1554 if (!this->device()->seek(p_pTag->next)) {
1558 }
else if (p_pTag->size() > 0 && p_pTag->next ==
FIFFV_NEXT_SEQ) {
1559 if (!this->device()->seek(this->device()->pos() + p_pTag->size())) {
1573 while (this->device()->bytesAvailable() < 16)
1574 this->device()->waitForReadyRead(10);
1580 while (this->device()->bytesAvailable() < p_pTag->size())
1581 this->device()->waitForReadyRead(10);
1595 this->device()->seek(pos);
1598 p_pTag = std::make_unique<FiffTag>();
1603 *
this >> p_pTag->kind;
1604 *
this >> p_pTag->type;
1607 p_pTag->resize(size);
1608 *
this >> p_pTag->next;
1616 if (this->byteOrder() == QDataStream::LittleEndian) {
1624 if (p_pTag->size() > 0) {
1625 this->readRawData(p_pTag->data(), p_pTag->size());
1632 this->device()->seek(p_pTag->next);
1641 bool allow_maxshield,
1642 bool is_littleEndian)
1648 QString t_sFileName = t_pStream->streamName();
1650 if (is_littleEndian) {
1652 t_pStream->setByteOrder(QDataStream::LittleEndian);
1655 qInfo(
"Opening raw data %s...\n", t_sFileName.toUtf8().constData());
1657 if (!t_pStream->open()) {
1666 if (!t_pStream->read_meas_info(t_pStream->dirtree(), info, meas))
1672 QList<FiffDirNode::SPtr> raw = meas->dir_tree_find(
FIFFB_RAW_DATA);
1673 if (raw.size() == 0) {
1675 if (allow_maxshield) {
1680 qInfo(
"Maxshield data found\n");
1682 if (raw.size() == 0) {
1683 qWarning(
"No raw data in %s\n", t_sFileName.toUtf8().constData());
1687 if (raw.size() == 0) {
1688 qWarning(
"No raw data in %s\n", t_sFileName.toUtf8().constData());
1699 data.
file = t_pStream;
1706 QList<FiffDirEntry::SPtr>
dir = raw[0]->dir;
1716 if (
dir.isEmpty()) {
1717 qWarning(
"No directory entries in raw data block of %s\n", t_sFileName.toUtf8().constData());
1726 qWarning(
"Measurement info of %s reports %d channels; cannot read raw data\n", t_sFileName.toUtf8().constData(), nchan);
1734 t_pStream->read_tag(t_pTag,
dir[first]->pos);
1735 first_samp = *t_pTag->toInt();
1745 t_pStream->read_tag(t_pTag,
dir[first]->pos);
1746 first_skip = *t_pTag->toInt();
1753 QList<FiffRawDir> rawdir;
1757 for (qint32 k = first; k <
nent; ++k) {
1760 t_pStream->read_tag(t_pTag, ent->pos);
1761 nskip = *t_pTag->toInt();
1766 switch (ent->type) {
1768 nsamp = ent->size / (2 * nchan);
1771 nsamp = ent->size / (2 * nchan);
1774 nsamp = ent->size / (4 * nchan);
1777 nsamp = ent->size / (4 * nchan);
1780 nsamp = ent->size / (8 * nchan);
1783 qWarning(
"Cannot handle data buffers of type %d\n", ent->type);
1789 if (first_skip > 0) {
1790 first_samp += nsamp * first_skip;
1801 t_RawDir.
first = first_samp;
1802 t_RawDir.
last = first_samp + nskip * nsamp - 1;
1803 t_RawDir.
nsamp = nskip * nsamp;
1804 rawdir.append(t_RawDir);
1805 first_samp = first_samp + nskip * nsamp;
1813 t_RawDir.
first = first_samp;
1814 t_RawDir.
last = first_samp + nsamp - 1;
1815 t_RawDir.
nsamp = nsamp;
1816 rawdir.append(t_RawDir);
1817 first_samp += nsamp;
1826 for (qint32 k = 0; k < data.
info.
nchan; ++k)
1827 cals[k] =
static_cast<double>(data.
info.
chs[k].range) * data.
info.
chs[k].cal;
1834 qInfo(
"\tRange : %d ... %d = %9.3f ... %9.3f secs",
1848 return p_sNameList.replace(
" ",
"").split(
":");
1863 QString t_sFileName = p_pStream->streamName();
1865 if (!p_IODevice.isOpen()) {
1866 if (!p_pStream->device()->open(QIODevice::WriteOnly)) {
1867 qWarning(
"Cannot write to %s\n", t_sFileName.toUtf8().constData());
1869 return p_pEmptyStream;
1891 QString t_sFileName = t_pStream->streamName();
1898 QFile* t_pFile = qobject_cast<QFile*>(&p_IODevice);
1899 if (t_pFile !=
nullptr && !t_pFile->exists()) {
1900 qCritical(
"Cannot open %s for update: no such file", t_sFileName.toUtf8().constData());
1907 if (!t_pStream->open(QIODevice::ReadWrite)) {
1908 qCritical(
"Cannot open %s\n", t_sFileName.toUtf8().constData());
1913 long dirpos, pointerpos;
1915 QFile* file = qobject_cast<QFile*>(t_pStream->device());
1917 if (file !=
nullptr) {
1921 pointerpos = t_pStream->dir()[t_pStream->nent() - 2]->pos;
1922 if (!t_pStream->read_tag(t_pTag, pointerpos)) {
1923 qCritical(
"Could not read last tag in the directory list!");
1929 t_pStream->write_tag(t_pTag, pointerpos);
1934 pointerpos = t_pStream->dir()[1]->pos;
1935 if (!t_pStream->read_tag(t_pTag, pointerpos)) {
1936 qCritical(
"Could not read directory pointer!");
1943 dirpos = *t_pTag->toInt();
1948 t_pStream->write_dir_pointer(-1, pointerpos);
1952 file->resize(dirpos);
1957 t_pStream->device()->seek(file->size());
1976 if (sel.cols() == 0) {
1977 sel.resize(1, info.
chs.size());
1978 for (qint32 k = 0; k < info.
chs.size(); ++k)
1982 QList<FiffChInfo> chs;
1984 for (qint32 k = 0; k < sel.cols(); ++k)
1985 chs << info.
chs.at(sel(0, k));
2011 QList<fiff_int_t> blocks;
2013 bool have_hpi_result =
false;
2014 bool have_isotrak =
false;
2015 if (blocks.size() > 0 && !info.
filename.isEmpty()) {
2019 if (!t_pStream2->open()) {
2020 qDebug() <<
"Failed to open file. Returning early";
2024 for (qint32 k = 0; k < blocks.size(); ++k) {
2025 QList<FiffDirNode::SPtr> nodes = t_pStream2->dirtree()->dir_tree_find(blocks[k]);
2028 have_hpi_result =
true;
2031 have_isotrak =
true;
2056 if (!have_hpi_result) {
2058 t_pStream->write_coord_trans(info.
dev_head_t);
2061 t_pStream->write_coord_trans(info.
ctf_head_t);
2066 if (info.
dig.size() > 0 && !have_isotrak) {
2068 for (qint32 k = 0; k < info.
dig.size(); ++k)
2069 t_pStream->write_dig_point(info.
dig[k]);
2078 t_pStream->write_proj(info.
projs);
2082 t_pStream->write_ctf_comp(info.
comps);
2086 if (info.
bads.size() > 0) {
2111 cals = RowVectorXd(nchan);
2112 for (qint32 k = 0; k < nchan; ++k) {
2116 chs[k].scanNo = k + 1;
2120 cals[k] = chs[k].cal;
2121 t_pStream->write_ch_info(chs[k]);
2142 this->device()->seek(pos);
2144 QFile* file = qobject_cast<QFile*>(this->device());
2146 this->device()->seek(file->size());
2148 pos = this->device()->pos();
2152 *this << static_cast<qint32>(p_pTag->kind);
2153 *this << static_cast<qint32>(p_pTag->type);
2154 *this << static_cast<qint32>(datasize);
2155 *this << static_cast<qint32>(p_pTag->next);
2162 auto fileTag = std::make_unique<FiffTag>(*p_pTag);
2164 this->writeRawData(fileTag->data(), datasize);
2199 *this << static_cast<qint32>(datasize);
2205 *this << static_cast<qint32>(ch.
scanNo);
2206 *this << static_cast<qint32>(ch.
logNo);
2207 *this << static_cast<qint32>(ch.
kind);
2220 *this << static_cast<qint32>(ch.
unit);
2221 *this << static_cast<qint32>(ch.
unit_mul);
2229 ch_name = ch.
ch_name.mid(0, 15);
2233 len = ch_name.size();
2235 this->writeRawData(ch_name.toUtf8().constData(), len);
2238 const char* chNull =
"";
2239 for (qint32 i = 0; i < 16 - len; ++i)
2240 this->writeRawData(chNull, 1);
2255 *this << static_cast<qint32>(chpos.
coil_type);
2259 for (i = 0; i < 3; ++i)
2260 *
this << chpos.
r0[i];
2262 for (i = 0; i < 3; ++i)
2263 *
this << chpos.
ex[i];
2265 for (i = 0; i < 3; ++i)
2266 *
this << chpos.
ey[i];
2268 for (i = 0; i < 3; ++i)
2269 *
this << chpos.
ez[i];
2292 *this << static_cast<qint32>(datasize);
2298 *this << static_cast<qint32>(trans.
from);
2299 *this << static_cast<qint32>(trans.
to);
2305 for (r = 0; r < 3; ++r)
2306 for (c = 0; c < 3; ++c)
2307 *
this <<
static_cast<float>(trans.
trans(r, c));
2308 for (r = 0; r < 3; ++r)
2309 *
this <<
static_cast<float>(trans.
trans(r, 3));
2314 for (r = 0; r < 3; ++r)
2315 for (c = 0; c < 3; ++c)
2316 *
this <<
static_cast<float>(trans.
invtrans(r, c));
2317 for (r = 0; r < 3; ++r)
2318 *
this <<
static_cast<float>(trans.
invtrans(r, 3));
2336 if (p_FiffCov.
nfree > 0)
2341 if (p_FiffCov.
names.size() > 0)
2354 qint32 dim = p_FiffCov.
dim;
2355 qint32 n = dim * (dim + 1) / 2;
2360 VectorXd vals = VectorXd::Zero(n);
2362 for (qint32 i = 0; i < dim; ++i)
2363 for (qint32 j = 0; j <= i; ++j)
2364 vals(count++) = p_FiffCov.
data(i, j);
2372 if (p_FiffCov.
eig.size() > 0 && p_FiffCov.
eigvec.size() > 0) {
2383 if (p_FiffCov.
bads.size() > 0) {
2402 if (comps.size() <= 0)
2408 for (qint32 k = 0; k < comps.size(); ++k) {
2421 if (!comps[k].save_calibrated) {
2423 if (comp.
rowcals.size() == comp.
data->data.rows())
2424 comp.
data->data = comp.
rowcals.reshaped().cwiseInverse().asDiagonal() * comp.
data->data;
2425 if (comp.
colcals.size() == comp.
data->data.cols())
2426 comp.
data->data = comp.
data->data * comp.
colcals.reshaped().cwiseInverse().asDiagonal();
2454 *this << static_cast<qint32>(datasize);
2460 *this << static_cast<qint32>(dig.
kind);
2461 *this << static_cast<qint32>(dig.
ident);
2462 for (qint32 i = 0; i < 3; ++i)
2476 this->device()->seek(pos);
2478 QFile* file = qobject_cast<QFile*>(this->device());
2480 this->device()->seek(file->size());
2482 pos = this->device()->pos();
2487 *this << static_cast<qint32>(
FIFFT_INT);
2488 *this << static_cast<qint32>(datasize);
2489 *this << static_cast<qint32>(next);
2514 this->device()->seek(pos);
2516 QFile* file = qobject_cast<QFile*>(this->device());
2518 this->device()->seek(file->size());
2521 pos = this->device()->pos();
2526 *this << static_cast<qint32>(
FIFF_DIR);
2528 *this << static_cast<qint32>(datasize);
2534 for (qint32 i = 0; i <
nent; ++i) {
2535 *this << static_cast<qint32>(
dir[i]->kind);
2536 *this << static_cast<qint32>(
dir[i]->type);
2537 *this << static_cast<qint32>(
dir[i]->size);
2538 *this << static_cast<qint32>(
dir[i]->pos);
2550 qint32 datasize = nel * 8;
2552 *this << static_cast<qint32>(kind);
2563 for (qint32 i = 0; i < nel; ++i) {
2565 memcpy(&bits, &data[i],
sizeof(
double));
2578 qint32 datasize = nel * 4;
2580 *this << static_cast<qint32>(kind);
2585 for (qint32 i = 0; i < nel; ++i)
2597 qint32 numel = mat.rows() * mat.cols();
2601 *this << static_cast<qint32>(kind);
2603 *this << static_cast<qint32>(datasize);
2608 for (i = 0; i < mat.rows(); ++i)
2609 for (j = 0; j < mat.cols(); ++j)
2613 dims[0] = mat.cols();
2614 dims[1] = mat.rows();
2617 for (i = 0; i < 3; ++i)
2637 qint32 nnzm = mat.nonZeros();
2638 qint32 ncol = mat.cols();
2639 fiff_int_t datasize = 4 * nnzm + 4 * nnzm + 4 * (ncol + 1) + 4 * 4;
2643 using T = Eigen::Triplet<float>;
2645 s.reserve(mat.nonZeros());
2646 for (
int k = 0; k < mat.outerSize(); ++k)
2647 for (SparseMatrix<float>::InnerIterator it(mat, k); it; ++it)
2648 s.push_back(T(it.row(), it.col(), it.value()));
2653 std::vector<qint32> cols, starts;
2656 for (i = 0; i < s.size(); ++i) {
2657 if (
static_cast<signed>(s[i].col()) != v_old) {
2659 cols.push_back(s[i].col());
2660 starts.push_back(i);
2664 *this << static_cast<qint32>(kind);
2666 *this << static_cast<qint32>(datasize);
2672 for (i = 0; i < s.size(); ++i)
2673 *
this << s[i].value();
2678 for (i = 0; i < s.size(); ++i)
2679 *
this << s[i].row();
2684 RowVectorXi ptrs = RowVectorXi::Ones(ncol + 1);
2687 for (k = 0; k < cols.size(); ++k)
2688 ptrs[cols[k]] = starts[k];
2693 for (k = ncol; k >= 1; --k)
2694 if (ptrs[k - 1] < 0)
2695 ptrs[k - 1] = ptrs[k];
2697 for (i = 0; i < static_cast<quint32>(ptrs.size()); ++i)
2703 dims[0] = mat.nonZeros();
2704 dims[1] = mat.rows();
2705 dims[2] = mat.cols();
2708 for (i = 0; i < 4; ++i)
2728 qint32 nnzm = mat.nonZeros();
2729 qint32 nrow = mat.rows();
2730 fiff_int_t datasize = 4 * nnzm + 4 * nnzm + 4 * (nrow + 1) + 4 * 4;
2734 using T = Eigen::Triplet<float>;
2736 s.reserve(mat.nonZeros());
2737 for (
int k = 0; k < mat.outerSize(); ++k)
2738 for (SparseMatrix<float>::InnerIterator it(mat, k); it; ++it)
2739 s.push_back(T(it.row(), it.col(), it.value()));
2744 std::vector<qint32> rows, starts;
2747 for (i = 0; i < s.size(); ++i) {
2748 if (
static_cast<signed>(s[i].row()) != v_old) {
2750 rows.push_back(s[i].row());
2751 starts.push_back(i);
2758 *this << static_cast<qint32>(kind);
2760 *this << static_cast<qint32>(datasize);
2766 for (i = 0; i < s.size(); ++i)
2767 *
this << s[i].value();
2772 for (i = 0; i < s.size(); ++i)
2773 *
this << s[i].col();
2778 RowVectorXi ptrs = RowVectorXi::Ones(nrow + 1);
2781 for (k = 0; k < rows.size(); ++k)
2782 ptrs[rows[k]] = starts[k];
2788 for (k = nrow; k >= 1; --k)
2789 if (ptrs[k - 1] < 0)
2790 ptrs[k - 1] = ptrs[k];
2793 for (i = 0; i < static_cast<quint32>(ptrs.size()); ++i)
2800 dims[0] = mat.nonZeros();
2801 dims[1] = mat.rows();
2802 dims[2] = mat.cols();
2805 for (i = 0; i < 4; ++i)
2830 *this << static_cast<qint32>(kind);
2832 *this << static_cast<qint32>(datasize);
2839 data[1] = t_id.
machid[0];
2840 data[2] = t_id.
machid[1];
2844 for (qint32 i = 0; i < 5; ++i)
2873 QList<FiffChInfo> chs;
2874 for (k = 0; k < p_FiffInfoBase.
nchan; ++k)
2875 chs << p_FiffInfoBase.
chs[k];
2877 for (k = 0; k < p_FiffInfoBase.
nchan; ++k) {
2881 chs[k].scanNo = k + 1;
2888 bool have_hpi_result =
false;
2893 if (!have_hpi_result) {
2903 if (p_FiffInfoBase.
bads.size() > 0) {
2922 *this << static_cast<qint32>(kind);
2923 *this << static_cast<qint32>(
FIFFT_INT);
2924 *this << static_cast<qint32>(datasize);
2925 *this << static_cast<qint32>(next);
2927 for (qint32 i = 0; i < nel; ++i)
2942 qint32 numel = mat.rows() * mat.cols();
2946 *this << static_cast<qint32>(kind);
2948 *this << static_cast<qint32>(datasize);
2953 for (i = 0; i < mat.rows(); ++i)
2954 for (j = 0; j < mat.cols(); ++j)
2958 dims[0] = mat.cols();
2959 dims[1] = mat.rows();
2962 for (i = 0; i < 3; ++i)
2972 QString all = data.join(
":");
3001 if (projs.size() <= 0)
3006 for (qint32 k = 0; k < projs.size(); ++k) {
3011 float fValue = 0.0f;
3017 qint32 bValue =
static_cast<qint32
>(projs[k].active);
3034 if (p_FiffEvokedSet.
evoked.isEmpty())
3050 float sfreq = p_FiffEvokedSet.
info.
sfreq;
3053 for (
int k = 0; k < p_FiffEvokedSet.
info.
nchan; ++k) {
3062 if (!p_FiffEvokedSet.
info.
projs.isEmpty())
3065 if (!p_FiffEvokedSet.
info.
bads.isEmpty())
3070 for (
int j = 0; j < p_FiffEvokedSet.
evoked.size(); ++j) {
3078 int first = evoked.
first;
3081 int last = evoked.
last;
3089 int nave = evoked.
nave;
3093 Eigen::VectorXd decal(evoked.
data.rows());
3094 for (
int k = 0; k < decal.size(); ++k) {
3095 const double cal = k < p_FiffEvokedSet.
info.
chs.size() ? p_FiffEvokedSet.
info.
chs[k].cal : 1.0;
3096 decal[k] = cal != 0.0 ? 1.0 / cal : 1.0;
3098 Eigen::MatrixXf floatData = (decal.asDiagonal() * evoked.
data).cast<
float>();
3114 const RowVectorXd& cals)
3116 if (buf.rows() != cals.cols()) {
3117 qWarning(
"buffer and calibration sizes do not match\n");
3121 using T = Eigen::Triplet<double>;
3122 std::vector<T> tripletList;
3123 tripletList.reserve(cals.cols());
3124 for (qint32 i = 0; i < cals.cols(); ++i)
3125 tripletList.push_back(T(i, i, 1.0 / cals[i]));
3127 SparseMatrix<double> inv_calsMat(cals.cols(), cals.cols());
3128 inv_calsMat.setFromTriplets(tripletList.begin(), tripletList.end());
3130 MatrixXf tmp = (inv_calsMat * buf).cast<float>();
3138 const SparseMatrix<double>& mult)
3140 if (buf.rows() != mult.cols()) {
3141 qWarning(
"buffer and mult sizes do not match\n");
3145 SparseMatrix<double> inv_mult(mult.rows(), mult.cols());
3146 for (
int k = 0; k < inv_mult.outerSize(); ++k)
3147 for (SparseMatrix<double>::InnerIterator it(mult, k); it; ++it)
3148 inv_mult.coeffRef(it.row(), it.col()) = 1 / it.value();
3150 MatrixXf tmp = (inv_mult * buf).cast<float>();
3159 MatrixXf tmp = buf.cast<
float>();
3167 const QString& data)
3171 const QByteArray bytes = data.toUtf8();
3173 *this << static_cast<qint32>(kind);
3175 *this << static_cast<qint32>(datasize);
3178 this->writeRawData(bytes.constData(), datasize);
3187 const QByteArray bytes = data.toUtf8();
3191 *this << 4 + static_cast<qint32>(datasize);
3195 this->writeRawData(bytes.constData(), datasize);
3200QList<FiffDirEntry::SPtr> FiffStream::make_dir(
bool* ok)
3203 QList<FiffDirEntry::SPtr>
dir;
3211 if (!this->device()->seek(SEEK_SET))
3220 if (this->status() != QDataStream::Ok) {
3221 this->resetStatus();
3233 t_pFiffDirEntry->kind = t_pTag->kind;
3234 t_pFiffDirEntry->type = t_pTag->type;
3235 t_pFiffDirEntry->size = t_pTag->size();
3236 t_pFiffDirEntry->pos = pos;
3238 dir.append(t_pFiffDirEntry);
3239 if (t_pTag->next < 0)
3246 t_pFiffDirEntry->kind = -1;
3247 t_pFiffDirEntry->type = -1;
3248 t_pFiffDirEntry->size = -1;
3249 t_pFiffDirEntry->pos = -1;
3250 dir.append(t_pFiffDirEntry);
3262 QFile srcFile(fromPath);
3264 if (!srcStream.
open()) {
3265 qWarning(
"FiffStream::copyProcessingHistory - Cannot parse source FIFF file %s",
3266 fromPath.toUtf8().constData());
3272 if (histNodes.isEmpty()) {
3273 qWarning(
"FiffStream::copyProcessingHistory - No processing history block found in %s",
3274 fromPath.toUtf8().constData());
3286 std::vector<Item> items;
3288 items.push_back({node->type, 0,
nullptr});
3289 for (
int i = 0; i < node->nent(); ++i) {
3290 const int kind = node->dir[i]->kind;
3294 if (srcStream.
read_tag(tag, node->dir[i]->pos))
3295 items.push_back({0, 0, std::move(tag)});
3297 for (
int c = 0; c < node->nchild(); ++c)
3298 collect(node->children[c]);
3299 items.push_back({0, node->type,
nullptr});
3301 collect(histNodes[0]);
3305 QFile dstFile(toPath);
3308 qWarning(
"FiffStream::copyProcessingHistory - Cannot open destination file %s for update",
3309 toPath.toUtf8().constData());
3314 const fiff_long_t lastPos = dstStream->dir()[dstStream->nent() - 2]->pos;
3316 if (!dstStream->read_tag(lastTag, lastPos)) {
3321 dstStream->write_tag(lastTag, lastPos);
3322 dstStream->device()->seek(dstStream->device()->size());
3324 for (
const Item& item : items) {
3325 if (item.blockStart)
3326 dstStream->start_block(item.blockStart);
3327 else if (item.blockEnd)
3328 dstStream->end_block(item.blockEnd);
3330 dstStream->write_tag(item.tag);
3333 dstStream->end_file();
3346 qWarning(
"Fiff::open: file does not start with a file id tag\n");
3351 qWarning(
"Fiff::open: file does not start with a file id tag\n");
3354 if (p_pTag->size() != 20) {
3355 qWarning(
"Fiff::open: file does not start with a file id tag\n");
FIFF channel descriptor record (FIFF_CH_INFO): per-channel logical/scanner numbers,...
constexpr auto FIFFB_MNE_PARENT_MEAS_FILE
constexpr auto FIFFV_COORD_HEAD
constexpr auto FIFF_MNE_FILE_NAME
constexpr auto FIFF_MNE_ROW_NAMES
constexpr auto FIFFB_MNE_CTF_COMP
constexpr auto FIFF_MNE_CTF_COMP_KIND
constexpr auto FIFFV_MNE_COORD_CTF_HEAD
constexpr auto FIFFV_NEXT_NONE
constexpr auto FIFF_MNE_ENV_COMMAND_LINE
constexpr auto FIFF_MNE_COORD_FRAME
constexpr auto FIFF_MNE_NCOL
constexpr auto FIFF_MNE_COV_EIGENVALUES
constexpr auto FIFFB_MNE_NAMED_MATRIX
constexpr auto FIFFV_NEXT_SEQ
constexpr auto FIFFV_COORD_DEVICE
constexpr auto FIFF_MNE_NROW
constexpr auto FIFF_MNE_CH_NAME_LIST
constexpr auto FIFFB_MNE_COV
constexpr auto FIFF_MNE_COV_EIGENVECTORS
constexpr auto FIFF_MNE_COV_DIAG
constexpr auto FIFF_MNE_COV_DIM
constexpr auto FIFFV_COORD_UNKNOWN
constexpr auto FIFF_MNE_PROJ_ITEM_ACTIVE
constexpr auto FIFF_MNE_COV_NFREE
constexpr auto FIFF_MNE_ENV_WORKING_DIR
constexpr auto FIFF_MNE_COV
constexpr auto FIFFV_COORD_MRI
constexpr auto FIFF_MNE_CTF_COMP_CALIBRATED
constexpr auto FIFF_MNE_COV_KIND
constexpr auto FIFF_MNE_CTF_COMP_DATA
constexpr auto FIFF_MNE_COL_NAMES
constexpr auto FIFFB_MNE_ENV
constexpr auto FIFFB_MNE_BAD_CHANNELS
constexpr auto FIFF_MNE_RT_COMMAND
constexpr auto FIFFB_MNE_CTF_COMP_DATA
FIFF tag: the 16-byte tag header (kind, type, size, next) plus its decoded payload.
Set of averaged evoked responses sharing a FiffInfo, plus the ave-style category / rejection descript...
FIFF binary tag-stream layer: wraps a QIODevice to read and write FIFF tags, directories,...
Full FIFF measurement metadata: everything from FIFFB_MEAS / FIFFB_MEAS_INFO needed to interpret a re...
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
constexpr auto FIFF_DATA_SKIP
constexpr auto FIFF_PROJ_ITEM_NVEC
constexpr auto FIFF_BLOCK_END
constexpr auto FIFFB_PROCESSED_DATA
constexpr auto FIFFB_DACQ_PARS
constexpr auto FIFFB_ROOT
constexpr auto FIFF_PROJ_NAME
constexpr auto FIFF_PROJ_ITEM_KIND
constexpr auto FIFFV_NATIVE_ENDIAN
constexpr auto FIFFV_BIG_ENDIAN
constexpr auto FIFFB_SUBJECT
constexpr auto FIFFT_CH_INFO_STRUCT
constexpr auto FIFF_PROJ_ITEM_CH_NAME_LIST
constexpr auto FIFFT_DIG_POINT_STRUCT
constexpr auto FIFFB_CONTINUOUS_DATA
constexpr auto FIFFB_SMSH_RAW_DATA
constexpr auto FIFF_DACQ_STIM
constexpr auto FIFF_EPOCH
#define FIFFT_MATRIX_FLOAT
constexpr auto FIFF_GANTRY_ANGLE
constexpr auto FIFF_FILE_ID
constexpr auto FIFF_COMMENT
#define FIFFT_RCS_MATRIX_FLOAT
constexpr auto FIFF_EXPERIMENTER
constexpr auto FIFF_BLOCK_START
constexpr auto FIFF_UTC_OFFSET
constexpr auto FIFF_DATA_BUFFER
constexpr auto FIFFT_ID_STRUCT
constexpr auto FIFF_LINE_FREQ
constexpr auto FIFFT_COORD_TRANS_STRUCT
constexpr auto FIFFB_ASPECT
#define FIFFT_CCS_MATRIX_FLOAT
constexpr auto FIFF_HIGHPASS
constexpr auto FIFFB_RAW_DATA
constexpr auto FIFFT_DOUBLE
constexpr auto FIFF_LAST_SAMPLE
constexpr auto FIFF_DATA_PACK
constexpr auto FIFF_DACQ_PARS
constexpr auto FIFF_HPI_COIL_FREQ
constexpr auto FIFFV_LITTLE_ENDIAN
constexpr auto FIFFT_STRING
constexpr auto FIFF_SFREQ
constexpr auto FIFF_DIR_POINTER
constexpr auto FIFFB_MRI_SET
constexpr auto FIFFT_VOID
constexpr auto FIFFT_DAU_PACK16
constexpr auto FIFFB_ISOTRAK
constexpr auto FIFFV_PROJ_ITEM_FIELD
constexpr auto FIFF_NCHAN
constexpr auto FIFF_COORD_TRANS
constexpr auto FIFFB_HPI_SUBSYSTEM
constexpr auto FIFF_FIRST_SAMPLE
constexpr auto FIFF_LOWPASS
constexpr auto FIFF_PARENT_BLOCK_ID
constexpr auto FIFF_PROJ_ID
constexpr auto FIFF_XPLOTTER_LAYOUT
constexpr auto FIFFV_ASPECT_AVERAGE
constexpr auto FIFFB_EVOKED
constexpr auto FIFFT_SHORT
constexpr auto FIFF_ASPECT_KIND
constexpr auto FIFFT_FLOAT
constexpr auto FIFFB_HPI_COIL
constexpr auto FIFF_PROJ_ITEM_TIME
constexpr auto FIFFT_DIR_ENTRY_STRUCT
constexpr auto FIFFV_ASPECT_STD_ERR
constexpr auto FIFF_DIG_POINT
constexpr auto FIFF_PROJ_ITEM_VECTORS
constexpr auto FIFFB_MEAS_INFO
constexpr auto FIFFB_MEAS
constexpr auto FIFFB_HPI_MEAS
constexpr auto FIFFB_PROCESSING_HISTORY
constexpr auto FIFFB_HPI_RESULT
constexpr auto FIFFB_EVENTS
constexpr auto FIFF_BLOCK_ID
constexpr auto FIFF_CH_INFO
constexpr auto FIFF_FREE_LIST
constexpr auto FIFF_MEAS_DATE
return FiffCoordTrans(from_frame, to_frame, R, moveVec)
Coil-frame position record embedded inside FIFF_CH_INFO: coil location and 3x3 EX/EY/EZ orientation t...
Recursive node of the parsed FIFF block tree (FIFFB_* hierarchy with directory entries and children).
Single digitization point (FIFF_DIG_POINT) with kind (cardinal/HPI/EEG/extra), identifier and 3D coor...
FIFF continuous raw recording: FiffInfo plus a directory of FIFF_DATA_BUFFER tags for random-access s...
High-level digitization data: dig points plus the device→head transform and fitting metadata that tog...
128-bit FIFF identifier record (machine ID + creation time) used to stamp files, blocks and parent re...
CTF / 4D Neuroimaging software gradient-compensation matrix block (FIFFB_MNE_CTF_COMP_DATA).
Noise / data covariance matrix as stored under FIFFB_MNE_COV, with channel names, kind,...
Minimal measurement-info subset (channel list, sampling rate, basic transforms) shared by FIFF reader...
Header-only Eigen matrix text I/O — round-trips dense matrices to whitespace-separated ASCII for cros...
General numerical helpers: GCD, log2, histogram binning, baseline rescaling, sparsity tests.
Static linear-algebra helpers: SVD-based conditioning, block-diagonal assembly, sorted index pairs.
FIFF file I/O, in-memory data structures and high-level readers/writers.
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Per-channel FIFF descriptor: identifiers, kind, calibration, coil type, channel-frame coil position a...
Channel coil-frame placement: origin r0 (m) and orthonormal axes ex / ey / ez in FIFFV_COORD_DEVICE.
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > invtrans
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > trans
FIFF noise / data covariance: matrix, channel names, kind, applied projectors, bads,...
One CTF software-gradient compensation matrix: grade kind, calibration flag and the gradiometer × ref...
bool calibrate(const QList< FiffChInfo > &chs)
FiffNamedMatrix::SDPtr data
One digitizer point: kind (cardinal/HPI/EEG/extra), ident, 3D position in FIFFV_COORD_HEAD.
Registration-ready digitization data: dig points, device→head transform and HPI fit metadata.
QList< FIFFLIB::FiffDigPoint > points
Directory entry: tag kind + on-disk type + byte size + absolute file offset (16-byte record).
QSharedPointer< FiffDirEntry > SPtr
Recursive FIFF block-tree node: block kind, block ID, directly contained directory entries and child ...
QSharedPointer< FiffDirNode > SPtr
static bool copy_tree(QSharedPointer< FiffStream > &p_pStreamIn, const FiffId &in_id, const QList< QSharedPointer< FiffDirNode > > &p_Nodes, QSharedPointer< FiffStream > &p_pStreamOut)
Single averaged evoked response: time axis, data, baseline, channel info and averaging metadata.
Set of FiffEvoked instances sharing one FiffInfo, plus channel-picking and compensation helpers.
QList< FiffEvoked > evoked
128-bit FIFF identifier: hardware machine ID plus creation time, stamped on every file and block.
static FiffId new_file_id()
Full FIFF measurement info: per-channel descriptors, sampling and filter setup, projectors,...
QList< float > hpi_coil_freqs
QList< FiffCtfComp > comps
QList< FiffDigPoint > dig
Stripped FIFF measurement info: channel list, sampling rate, device→head transform and bad-channel li...
QList< FiffCoordTrans > all_coord_trans
FiffCoordTrans ctf_head_t
FiffCoordTrans dev_head_t
FIFF named matrix: dense / sparse Eigen matrix plus row-name and column-name string lists.
QSharedDataPointer< FiffNamedMatrix > SDPtr
Single SSP projection item: kind, active flag, desired flag and the named projection vector matrix.
Continuous FIFF raw recording: FiffInfo plus a random-access directory of FIFF_DATA_BUFFER tags.
QList< FiffRawDir > rawdir
Per-buffer raw-data directory entry: data kind, first sample, sample count, on-disk tag position.
bool write_raw_buffer(const Eigen::MatrixXd &buf, const Eigen::RowVectorXd &cals)
fiff_long_t write_cov(const FiffCov &p_FiffCov)
bool read_cov(const FiffDirNode::SPtr &p_Node, fiff_int_t cov_kind, FiffCov &p_covData)
fiff_long_t write_dir_entries(const QList< FiffDirEntry::SPtr > &dir, fiff_long_t pos=-1)
fiff_long_t start_block(fiff_int_t kind)
fiff_long_t write_float_matrix(fiff_int_t kind, const Eigen::MatrixXf &mat)
fiff_long_t write_proj(const QList< FiffProj > &projs)
fiff_long_t write_int_matrix(fiff_int_t kind, const Eigen::MatrixXi &mat)
QSharedPointer< FiffStream > SPtr
bool read_rt_tag(std::unique_ptr< FiffTag > &p_pTag)
bool read_tag_data(std::unique_ptr< FiffTag > &p_pTag, fiff_long_t pos=-1)
bool read_meas_info_base(const FiffDirNode::SPtr &p_Node, FiffInfoBase &p_InfoForward)
fiff_long_t write_tag(const std::unique_ptr< FiffTag > &p_pTag, fiff_long_t pos=-1)
static bool copyProcessingHistory(const QString &fromPath, const QString &toPath)
void write_bad_channels(const QStringList &bads)
fiff_long_t write_dig_point(const FiffDigPoint &dig)
fiff_long_t write_int(fiff_int_t kind, const fiff_int_t *data, fiff_int_t nel=1, fiff_int_t next=FIFFV_NEXT_SEQ)
static bool setup_read_raw(QIODevice &p_IODevice, FiffRawData &data, bool allow_maxshield=true, bool is_littleEndian=false)
QList< FiffCtfComp > read_ctf_comp(const FiffDirNode::SPtr &p_Node, const QList< FiffChInfo > &p_Chs)
fiff_long_t write_float(fiff_int_t kind, const float *data, fiff_int_t nel=1)
fiff_long_t write_id(fiff_int_t kind, const FiffId &id=FiffId::getDefault())
fiff_long_t write_float_sparse_rcs(fiff_int_t kind, const Eigen::SparseMatrix< float > &mat)
fiff_long_t write_ch_pos(const FiffChPos &chpos)
void write_rt_command(fiff_int_t command, const QString &data)
fiff_long_t write_coord_trans(const FiffCoordTrans &trans)
bool get_evoked_entries(const QList< FiffDirNode::SPtr > &evoked_node, QStringList &comments, QList< fiff_int_t > &aspect_kinds, QString &t)
fiff_long_t write_name_list(fiff_int_t kind, const QStringList &data)
bool read_meas_info(const FiffDirNode::SPtr &p_Node, FiffInfo &p_Info, FiffDirNode::SPtr &p_NodeInfo)
bool open(QIODevice::OpenModeFlag mode=QIODevice::ReadOnly)
fiff_long_t read_tag_info(std::unique_ptr< FiffTag > &p_pTag, bool p_bDoSkip=true)
fiff_long_t write_named_matrix(fiff_int_t kind, const FiffNamedMatrix &mat)
FiffStream(QIODevice *p_pIODevice)
static QStringList split_name_list(QString p_sNameList)
fiff_long_t write_string(fiff_int_t kind, const QString &data)
QStringList read_bad_channels(const FiffDirNode::SPtr &p_Node)
fiff_long_t write_evoked_set(const FiffEvokedSet &p_FiffEvokedSet)
const FiffDirNode::SPtr & dirtree() const
bool read_digitizer_data(const FiffDirNode::SPtr &p_Node, FiffDigitizerData &p_digData)
static FiffStream::SPtr start_writing_raw(QIODevice &p_IODevice, const FiffInfo &info, Eigen::RowVectorXd &cals, Eigen::MatrixXi sel=defaultMatrixXi, bool bResetRange=true)
fiff_long_t write_dir_pointer(fiff_int_t dirpos, fiff_long_t pos=-1, fiff_int_t next=FIFFV_NEXT_SEQ)
static FiffStream::SPtr start_file(QIODevice &p_IODevice)
fiff_long_t write_info_base(const FiffInfoBase &p_FiffInfoBase)
fiff_long_t end_block(fiff_int_t kind, fiff_int_t next=FIFFV_NEXT_SEQ)
fiff_long_t write_float_sparse_ccs(fiff_int_t kind, const Eigen::SparseMatrix< float > &mat)
fiff_long_t write_ch_info(const FiffChInfo &ch)
fiff_long_t write_ctf_comp(const QList< FiffCtfComp > &comps)
bool read_tag(std::unique_ptr< FiffTag > &p_pTag, fiff_long_t pos=-1)
fiff_long_t write_double(fiff_int_t kind, const double *data, fiff_int_t nel=1)
bool attach_env(const QString &workingDir, const QString &command)
QList< FiffProj > read_proj(const FiffDirNode::SPtr &p_Node)
static FiffStream::SPtr open_update(QIODevice &p_IODevice)
FiffDirNode::SPtr make_subtree(QList< FiffDirEntry::SPtr > &dentry)
bool read_named_matrix(const FiffDirNode::SPtr &p_Node, fiff_int_t matkind, FiffNamedMatrix &mat)
void finish_writing_raw()
QList< FiffDirEntry::SPtr > & dir()
std::unique_ptr< FiffTag > UPtr
static void convert_tag_data(const FiffTag::UPtr &tag, int from_endian, int to_endian)
static std::vector< Eigen::Triplet< T > > sortrows(const std::vector< Eigen::Triplet< T > > &A, qint32 column=0)
static bool issparse(Eigen::VectorXd &v)