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");
160 fiff_int_t datasize = 0;
164 *
this << (qint32)datasize;
183 aspect_kinds.clear();
184 QList<FiffDirNode::SPtr>::ConstIterator ev;
189 for(ev = evoked_node.begin(); ev != evoked_node.end(); ++ev)
191 for(k = 0; k < (*ev)->nent(); ++k)
193 kind = (*ev)->dir[k]->kind;
194 pos = (*ev)->dir[k]->pos;
198 comments.append(t_pTag->toString());
202 for(k = 0; k < my_aspect->nent(); ++k)
204 kind = my_aspect->dir[k]->kind;
205 pos = my_aspect->dir[k]->pos;
209 aspect_kinds.append(*t_pTag->toInt());
214 if(comments.size() != aspect_kinds.size() || comments.size() == 0)
216 qWarning(
"Dataset names in FIF file could not be found.");
221 for(k = 0; k < aspect_kinds.size(); ++k)
223 t += QString(
"%1 - \"%2\" (").arg(k).arg(comments[k]);
225 t += QString(
"FIFFV_ASPECT_AVERAGE)\n");
227 t += QString(
"FIFFV_ASPECT_STD_ERR)\n");
229 t += QString(
"unknown)\n");
245 if (!this->device()->
open(mode))
247 qCritical(
"Cannot open %s\n", t_sFileName.toUtf8().constData());
251 if(!check_beginning(t_pTag))
258 qCritical(
"FIFF file should start with FIFF_FILE_ID!");
259 this->device()->close();
262 m_id = t_pTag->toFiffID();
266 qWarning(
"Fiff::open: file does have a directory pointer");
267 this->device()->close();
274 qInfo(
"Creating tag directory for %s...", t_sFileName.toUtf8().constData());
276 qint32 dirpos = *t_pTag->toInt();
282 m_dir = this->make_dir(&ok);
284 qCritical (
"Could not create tag directory!");
289 if(!this->
read_tag(t_pTag, dirpos)) {
290 qCritical(
"Could not read the tag directory (file probably damaged)!");
293 m_dir = t_pTag->toDirEntry();
299 if (m_dir[m_dir.size()-2]->kind ==
FIFF_DIR) {
301 m_dir[m_dir.size()-1]->kind = -1;
302 m_dir[m_dir.size()-1]->type = -1;
303 m_dir[m_dir.size()-1]->size = -1;
304 m_dir[m_dir.size()-1]->pos = -1;
310 if((this->m_dirtree = this->
make_subtree(m_dir)) ==
nullptr)
313 this->m_dirtree->parent.clear();
318 this->device()->seek(SEEK_SET);
326 if(this->device()->isOpen())
327 this->device()->close();
340 QList<FiffDirEntry::SPtr>
dir;
343 node->dir_tree = dentry;
349 if (!this->
read_tag(t_pTag,dentry[current]->pos))
352 node->type = *t_pTag->toInt();
355 node->id = this->
id();
360 for (; current < dentry.size(); ++current) {
365 QList<FiffDirEntry::SPtr> sub_dentry = dentry.mid(current);
368 child->parent = node;
369 node->children.append(child);
377 else if (dentry[current]->kind == -1)
379 else if (level == 0) {
386 if (!this->
read_tag(t_pTag,dentry[current]->pos))
388 node->id = t_pTag->toFiffID();
439 for (insert = -1, b = 0; insert_blocks[b] >= 0; b++) {
440 for (k = 0; k <
nent(); k++) {
444 if (*(t_pTag->toInt()) == insert_blocks[b]) {
454 qCritical(
"Suitable place for environment insertion not found.");
462 if (where < 0 || where >=
nent()-1) {
463 qCritical(
"illegal insertion point in fiff_insert_after!");
468 QList<FiffDirEntry::SPtr> old_dir =
dir();
469 QList<FiffDirEntry::SPtr> this_ent = old_dir.mid(where);
471 if (!
read_tag(t_pTagNext, this_ent[0]->pos))
476 qint64 next_tmp = device()->pos();
480 device()->seek(device()->size());
484 QList<FiffDirEntry::SPtr> new_dir = old_dir.mid(0, where+1);
486 qint64 old_end = device()->pos();
495 new_this->size = 1 * 4;
497 new_dir.append(new_this);
502 new_this->size = 5 * 4;
504 new_dir.append(new_this);
509 new_this->size = workingDir.size();
511 new_dir.append(new_this);
516 new_this->size = command.size();
518 new_dir.append(new_this);
523 new_this->size = 1 * 4;
525 new_dir.append(new_this);
530 new_dir.append(old_dir.mid(where+1));
534 t_pTagNext->next = (qint32)old_end;
551 QList<FiffDirNode::SPtr> covs = p_Node->dir_tree_find(
FIFFB_MNE_COV);
552 if (covs.size() == 0)
554 qWarning(
"No covariance matrices found");
562 bool success =
false;
563 fiff_int_t dim, nfree, nn;
565 bool diagmat =
false;
572 for(p = 0; p < covs.size(); ++p)
575 if (success && *tag->toInt() == cov_kind)
583 qWarning(
"Covariance matrix dimension not found.\n");
590 nfree = *tag->toInt();
595 if (names.size() != dim)
597 qWarning(
"Number of names does not match covariance matrix dimension\n");
605 qWarning(
"No covariance matrix data found\n");
615 cov_diag = Map<const VectorXd>(tag->toDouble(),dim);
619 cov_diag = Map<const VectorXf>(tag->toFloat(),dim).cast<
double>();
622 qCritical(
"Illegal data type for covariance matrix\n");
627 qInfo(
"\t%d x %d diagonal covariance (kind = %d) found.\n", dim, dim, cov_kind);
636 vals = Map<const VectorXd>(tag->toDouble(),nn);
640 vals = Map<const VectorXf>(tag->toFloat(),nn).cast<
double>();
644 qDebug() << tag->getInfo();
653 cov = MatrixXd::Zero(dim,dim);
657 for(qint32 j = 0; j < dim; ++j)
659 for(qint32 k = 0; k <= j; ++k)
665 for(qint32 j = 0; j < dim; ++j)
666 for(qint32 k = j+1; k < dim; ++k)
670 qInfo(
"\t%d x %d full covariance (kind = %d) found.\n", dim, dim, cov_kind);
676 qDebug() <<
"ToDo: FiffStream::read_cov - this needs to be debugged.\n";
678 qInfo(
"\t%d x %d sparse covariance (kind = %d) found.\n", dim, dim, cov_kind);
717 eig = VectorXd(Map<const VectorXd>(tag1->toDouble(),dim));
718 eigvec = tag2->toFloatMatrix().cast<
double>();
719 eigvec.transposeInPlace();
724 QList<FiffProj> projs = this->
read_proj(current);
734 p_covData.
kind = cov_kind;
735 p_covData.
diag = diagmat;
737 p_covData.
names = names;
739 if(cov_diag.size() > 0)
740 p_covData.
data = cov_diag;
741 else if(cov.size() > 0)
742 p_covData.
data = cov;
743 else if(cov_sparse.size() > 0)
744 p_covData.
data = cov_sparse;
746 p_covData.
projs = projs;
747 p_covData.
bads = bads;
748 p_covData.
nfree = nfree;
750 p_covData.
eigvec = eigvec;
757 qInfo(
"Did not find the desired covariance matrix\n");
765 QList<FiffCtfComp> compdata;
768 qint32 i, k, p, col, row;
769 fiff_int_t kind, pos;
771 for (k = 0; k < t_qListComps.size(); ++k)
779 for(p = 0; p < node->nent(); ++p)
781 kind = node->dir[p]->kind;
782 pos = node->dir[p]->pos;
791 qWarning(
"Compensation type not found\n");
798 one.
ctfkind = *t_pTag->toInt();
805 else if (one.
ctfkind == 1194476114)
807 else if (one.
ctfkind == 1194541650)
809 else if (one.
ctfkind == 1194479433)
811 else if (one.
ctfkind == 1194544969)
816 for (p = 0; p < node->nent(); ++p)
818 kind = node->dir[p]->kind;
819 pos = node->dir[p]->pos;
830 calibrated = (bool)*t_pTag->toInt();
833 one.
rowcals = MatrixXd::Ones(1,mat->data.rows());
834 one.
colcals = MatrixXd::Ones(1,mat->data.cols());
843 QStringList ch_names;
844 for (p = 0; p < p_Chs.size(); ++p)
845 ch_names.append(p_Chs[p].ch_name);
848 MatrixXd col_cals(mat->data.cols(), 1);
850 for (col = 0; col < mat->data.cols(); ++col)
853 for (i = 0; i < ch_names.size(); ++i)
855 if (QString::compare(mat->col_names.at(col),ch_names.at(i)) == 0)
863 qWarning(
"Channel %s is not available in data",mat->col_names.at(col).toUtf8().constData());
868 qWarning(
"Ambiguous channel %s",mat->col_names.at(col).toUtf8().constData());
871 col_cals(col,0) = 1.0f/(p_Chs[p].range*p_Chs[p].cal);
876 MatrixXd row_cals(mat->data.rows(), 1);
878 for (row = 0; row < mat->data.rows(); ++row)
881 for (i = 0; i < ch_names.size(); ++i)
883 if (QString::compare(mat->row_names.at(row),ch_names.at(i)) == 0)
892 qWarning(
"Channel %s is not available in data",mat->row_names.at(row).toUtf8().constData());
897 qWarning(
"Ambiguous channel %s",mat->row_names.at(row).toUtf8().constData());
901 row_cals(row, 0) =
static_cast<double>(p_Chs[p].range)*p_Chs[p].cal;
903 mat->data = row_cals.asDiagonal()* mat->data *col_cals.asDiagonal();
908 compdata.append(one);
911 if (compdata.size() > 0)
912 qInfo(
"\tRead %lld compensation matrices\n",compdata.size());
922 fiff_int_t kind = -1;
927 QList<FiffDirNode::SPtr> t_qListDigData = p_Node->dir_tree_find(
FIFFB_ISOTRAK);
930 if(t_qListDigData.isEmpty()) {
933 if(t_qListDigData.isEmpty()) {
934 qWarning(
"No Isotrak data found in %s", this->
streamName().toLatin1().data());
944 for (
int k = 0; k < t_qListDigData.first()->
nent(); ++k) {
945 kind = t_qListDigData.first()->dir[k]->kind;
946 pos = t_qListDigData.first()->dir[k]->pos;
951 p_digData.
points.append(t_pTag->toDigPoint());
960 npoint = p_digData.
points.size();
963 qWarning(
"No digitizer data in %s", this->
streamName().toLatin1().data());
967 for (
auto& dig : p_digData.
points){
973 p_digData.
npoint = npoint;
975 for (
int k = 0; k < p_digData.
npoint; k++) {
976 p_digData.
active.append(1);
987 p_InfoForward.
clear();
994 if (parent_meg.size() == 0)
996 qWarning(
"No parent MEG information found in operator\n");
1002 QList<FiffChInfo> chs;
1004 fiff_int_t kind = -1;
1005 fiff_int_t pos = -1;
1007 for (qint32 k = 0; k < parent_meg[0]->nent(); ++k)
1009 kind = parent_meg[0]->dir[k]->kind;
1010 pos = parent_meg[0]->dir[k]->pos;
1014 chs.append( t_pTag->toChInfo() );
1022 p_InfoForward.
chs = chs;
1023 for (qint32 c = 0; c < p_InfoForward.
chs.size(); ++c)
1024 p_InfoForward.
ch_names << p_InfoForward.
chs[c].ch_name;
1026 p_InfoForward.
nchan = chs.size();
1033 cand = t_pTag->toCoordTrans();
1039 qWarning(
"MEG device/head coordinate transformation not found");
1042 qWarning(
"MEG/head coordinate transformation not found.\n");
1062 QList<FiffDirNode::SPtr> meas = p_Node->dir_tree_find(
FIFFB_MEAS);
1064 if (meas.size() == 0)
1066 qWarning(
"Could not find measurement data\n");
1070 QList<FiffDirNode::SPtr> meas_info = meas[0]->dir_tree_find(
FIFFB_MEAS_INFO);
1071 if (meas_info.count() == 0) {
1072 qWarning(
"Could not find measurement info\n");
1081 fiff_int_t nchan = -1;
1082 float sfreq = -1.0f;
1083 float linefreq = -1.0f;
1084 QList<FiffChInfo> chs;
1085 float lowpass = -1.0f;
1086 float highpass = -1.0f;
1089 QString proj_name =
"";
1090 QString xplotter_layout =
"";
1092 QString utc_offset =
"";
1093 fiff_int_t gantry_angle = -1;
1095 QString experimenter =
"";
1096 QString description =
"";
1103 QList<FiffCoordTrans> all_coord_trans;
1105 fiff_int_t meas_date[2];
1109 fiff_int_t kind = -1;
1110 fiff_int_t pos = -1;
1112 for (qint32 k = 0; k < meas_info[0]->nent(); ++k)
1114 kind = meas_info[0]->dir[k]->kind;
1115 pos = meas_info[0]->dir[k]->pos;
1120 nchan = *t_pTag->toInt();
1124 sfreq = *t_pTag->toFloat();
1128 linefreq = *t_pTag->toFloat();
1132 chs.append( t_pTag->toChInfo() );
1136 lowpass = *t_pTag->toFloat();
1140 highpass = *t_pTag->toFloat();
1144 meas_date[0] = t_pTag->toInt()[0];
1145 meas_date[1] = t_pTag->toInt()[1];
1150 cand = t_pTag->toCoordTrans();
1151 all_coord_trans.append(cand);
1159 proj_id = *t_pTag->toInt();
1163 proj_name = t_pTag->toString();
1167 xplotter_layout = t_pTag->toString();
1171 experimenter = t_pTag->toString();
1175 description = t_pTag->toString();
1181 gantry_angle =
static_cast<fiff_int_t
>(*t_pTag->toFloat());
1182 }
else if (t_pTag->getType() ==
FIFFT_INT) {
1183 gantry_angle = *t_pTag->toInt();
1188 utc_offset = t_pTag->toString();
1197 qWarning(
"Number of channels in not defined\n");
1202 qWarning(
"Sampling frequency is not defined\n");
1207 qWarning(
"Line frequency is not defined\n");
1209 if (chs.size() == 0)
1211 qWarning(
"Channel information not defined\n");
1214 if (chs.size() != nchan)
1216 qWarning(
"Incorrect number of channel definitions found\n");
1222 QList<FiffDirNode::SPtr> hpi_result = meas_info[0]->dir_tree_find(
FIFFB_HPI_RESULT);
1223 if (hpi_result.size() == 1)
1225 for( qint32 k = 0; k < hpi_result[0]->nent(); ++k)
1227 kind = hpi_result[0]->dir[k]->kind;
1228 pos = hpi_result[0]->dir[k]->pos;
1232 cand = t_pTag->toCoordTrans();
1244 QList<FiffDirNode::SPtr> isotrak = meas_info[0]->dir_tree_find(
FIFFB_ISOTRAK);
1246 QList<FiffDigPoint> dig;
1251 if (isotrak.size() == 1)
1253 for (k = 0; k < isotrak[0]->nent(); ++k)
1255 kind = isotrak[0]->dir[k]->kind;
1256 pos = isotrak[0]->dir[k]->pos;
1260 dig.append(t_pTag->toDigPoint());
1267 qDebug() <<
"NEEDS To BE DEBBUGED: FIFF_MNE_COORD_FRAME" << t_pTag->getType();
1268 coord_frame = *t_pTag->toInt();
1273 qDebug() <<
"NEEDS To BE DEBBUGED: FIFF_COORD_TRANS" << t_pTag->getType();
1274 dig_trans = t_pTag->toCoordTrans();
1279 for(k = 0; k < dig.size(); ++k)
1280 dig[k].coord_frame = coord_frame;
1283 if (dig_trans.
from != coord_frame && dig_trans.
to != coord_frame)
1289 QList<FiffDirNode::SPtr> acqpars = meas_info[0]->dir_tree_find(
FIFFB_DACQ_PARS);
1292 if (acqpars.size() == 1)
1294 for( k = 0; k < acqpars[0]->nent(); ++k)
1296 kind = acqpars[0]->dir[k]->kind;
1297 pos = acqpars[0]->dir[k]->pos;
1301 acq_pars = t_pTag->toString();
1306 acq_stim = t_pTag->toString();
1313 QList<FiffProj> projs = this->
read_proj(meas_info[0]);
1317 QList<FiffCtfComp> comps = this->
read_ctf_comp(meas_info[0], chs);
1326 if (p_Node->id.version != -1)
1334 if (meas_info[0]->parent_id.version == -1)
1336 if (meas_info[0]->
id.version == -1)
1338 if (meas[0]->
id.version == -1)
1340 if (meas[0]->parent_id.version == -1)
1343 info.
meas_id = meas[0]->parent_id;
1349 info.
meas_id = meas_info[0]->id;
1352 info.
meas_id = meas_info[0]->parent_id;
1354 if (meas_date[0] == -1)
1369 if (highpass != -1.0f)
1374 if (lowpass != -1.0f)
1384 for (qint32 c = 0; c < info.
nchan; ++c)
1423 p_NodeInfo = meas[0];
1438 bool found_it =
false;
1441 for (
int k = 0; k < node->nchild(); ++k)
1445 if(node->children[k]->has_tag(matkind))
1447 node = node->children[k];
1455 qWarning(
"Fiff::read_named_matrix: Desired named matrix (kind = %d) not available\n",matkind);
1461 if (!node->has_tag(matkind))
1463 qWarning(
"Desired named matrix (kind = %d) not available",matkind);
1472 if(!node->find_tag(
this, matkind, t_pTag))
1474 qWarning(
"Matrix data missing.\n");
1480 mat.
data = t_pTag->toFloatMatrix().cast<
double>();
1481 mat.
data.transposeInPlace();
1488 if (*t_pTag->toInt() != mat.
nrow)
1490 qWarning(
"Number of rows in matrix data and FIFF_MNE_NROW tag do not match");
1494 if (*t_pTag->toInt() != mat.
ncol)
1496 qWarning(
"Number of columns in matrix data and FIFF_MNE_NCOL tag do not match");
1502 row_names = t_pTag->toString();
1506 col_names = t_pTag->toString();
1511 if (!row_names.isEmpty())
1514 if (!col_names.isEmpty())
1519 qWarning(
"FiffStream::read_named_matrix - Number of rows in matrix data and row names do not match\n");
1524 qWarning(
"FiffStream::read_named_matrix - Number of columns in matrix data and column names do not match\n");
1534 QList<FiffProj> projdata;
1538 QList<FiffDirNode::SPtr> t_qListNodes = p_Node->dir_tree_find(
FIFFB_PROJ);
1539 if ( t_qListNodes.size() == 0 )
1543 t_qListNodes[0]->find_tag(
this,
FIFF_NCHAN, t_pTag);
1544 fiff_int_t global_nchan = 0;
1546 global_nchan = *t_pTag->toInt();
1549 QList<FiffDirNode::SPtr> t_qListItems = t_qListNodes[0]->dir_tree_find(
FIFFB_PROJ_ITEM);
1550 for ( qint32 i = 0; i < t_qListItems.size(); ++i)
1556 t_pFiffDirTreeItem->find_tag(
this,
FIFF_NCHAN, t_pTag);
1558 nchan = *t_pTag->toInt();
1560 nchan = global_nchan;
1566 qDebug() <<
"read_proj: this has to be debugged";
1567 desc = t_pTag->toString();
1571 t_pFiffDirTreeItem->find_tag(
this,
FIFF_NAME, t_pTag);
1573 desc = t_pTag->toString();
1576 qWarning(
"Projection item description missing\n");
1595 kind = *t_pTag->toInt();
1599 qWarning(
"Projection item kind missing");
1606 nvec = *t_pTag->toInt();
1610 qWarning(
"Number of projection vectors not specified\n");
1621 qWarning(
"Projection item channel list missing\n");
1628 data = t_pTag->toFloatMatrix().cast<
double>();
1629 data.transposeInPlace();
1633 qWarning(
"Projection item data missing\n");
1639 active = *t_pTag->toInt();
1643 if (data.cols() != names.size())
1645 qWarning(
"Number of channel names does not match the size of data matrix\n");
1652 QStringList defaultList;
1653 FiffNamedMatrix t_fiffNamedMatrix(nvec, nchan, defaultList, names, data);
1655 FiffProj one(kind, active, desc, t_fiffNamedMatrix);
1657 projdata.append(one);
1660 if (projdata.size() > 0)
1662 qInfo(
"\tRead a total of %lld projection items:\n", projdata.size());
1663 for(qint32 k = 0; k < projdata.size(); ++k)
1665 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");
1678 this->device()->seek(pos);
1687 if (p_pTag->size() > 0)
1689 this->readRawData(p_pTag->data(), p_pTag->size());
1694 this->device()->seek(p_pTag->next);
1703 fiff_long_t pos = this->device()->pos();
1705 p_pTag = std::make_unique<FiffTag>();
1715 *
this >> p_pTag->kind;
1716 *
this >> p_pTag->type;
1719 p_pTag->resize(size);
1720 *
this >> p_pTag->next;
1726 QTcpSocket* t_qTcpSocket = qobject_cast<QTcpSocket*>(this->device());
1729 this->skipRawData(p_pTag->size());
1733 if (p_pTag->next > 0)
1735 if(!this->device()->seek(p_pTag->next)) {
1742 if(!this->device()->seek(this->device()->pos()+p_pTag->size())) {
1756 while(this->device()->bytesAvailable() < 16)
1757 this->device()->waitForReadyRead(10);
1763 while(this->device()->bytesAvailable() < p_pTag->size())
1764 this->device()->waitForReadyRead(10);
1778 this->device()->seek(pos);
1781 p_pTag = std::make_unique<FiffTag>();
1786 *
this >> p_pTag->kind;
1787 *
this >> p_pTag->type;
1790 p_pTag->resize(size);
1791 *
this >> p_pTag->next;
1799 if (this->byteOrder() == QDataStream::LittleEndian){
1807 if (p_pTag->size() > 0)
1809 this->readRawData(p_pTag->data(), p_pTag->size());
1816 this->device()->seek(p_pTag->next);
1825 bool allow_maxshield,
1826 bool is_littleEndian)
1832 QString t_sFileName = t_pStream->streamName();
1834 if(is_littleEndian){
1836 t_pStream->setByteOrder(QDataStream::LittleEndian);
1839 qInfo(
"Opening raw data %s...\n",t_sFileName.toUtf8().constData());
1841 if(!t_pStream->open()){
1850 if(!t_pStream->read_meas_info(t_pStream->dirtree(), info, meas))
1856 QList<FiffDirNode::SPtr> raw = meas->dir_tree_find(
FIFFB_RAW_DATA);
1857 if (raw.size() == 0)
1866 qInfo(
"Maxshield data found\n");
1868 if (raw.size() == 0)
1870 qWarning(
"No raw data in %s\n", t_sFileName.toUtf8().constData());
1876 if (raw.size() == 0)
1878 qWarning(
"No raw data in %s\n", t_sFileName.toUtf8().constData());
1889 data.
file = t_pStream;
1896 QList<FiffDirEntry::SPtr>
dir = raw[0]->dir;
1897 fiff_int_t
nent = raw[0]->nent();
1898 fiff_int_t nchan = info.
nchan;
1899 fiff_int_t first = 0;
1900 fiff_int_t first_samp = 0;
1901 fiff_int_t first_skip = 0;
1908 t_pStream->read_tag(t_pTag,
dir[first]->pos);
1909 first_samp = *t_pTag->toInt();
1920 t_pStream->read_tag(t_pTag,
dir[first]->pos);
1921 first_skip = *t_pTag->toInt();
1928 QList<FiffRawDir> rawdir;
1930 fiff_int_t nskip = 0;
1931 fiff_int_t ndir = 0;
1932 fiff_int_t nsamp = 0;
1933 for (qint32 k = first; k <
nent; ++k)
1938 t_pStream->read_tag(t_pTag, ent->pos);
1939 nskip = *t_pTag->toInt();
1949 nsamp = ent->size/(2*nchan);
1952 nsamp = ent->size/(2*nchan);
1955 nsamp = ent->size/(4*nchan);
1958 nsamp = ent->size/(4*nchan);
1961 qWarning(
"Cannot handle data buffers of type %d\n",ent->type);
1969 first_samp += nsamp*first_skip;
1979 t_RawDir.
first = first_samp;
1980 t_RawDir.
last = first_samp + nskip*nsamp - 1;
1981 t_RawDir.
nsamp = nskip*nsamp;
1982 rawdir.append(t_RawDir);
1983 first_samp = first_samp + nskip*nsamp;
1992 t_RawDir.
first = first_samp;
1993 t_RawDir.
last = first_samp + nsamp - 1;
1994 t_RawDir.
nsamp = nsamp;
1995 rawdir.append(t_RawDir);
1996 first_samp += nsamp;
2006 for (qint32 k = 0; k < data.
info.
nchan; ++k)
2007 cals[k] =
static_cast<double>(data.
info.
chs[k].range)*data.
info.
chs[k].cal;
2014 qInfo(
"\tRange : %d ... %d = %9.3f ... %9.3f secs",
2028 return p_sNameList.replace(
" ",
"").split(
":");
2043 QString t_sFileName = p_pStream->streamName();
2045 if(!p_IODevice.isOpen())
2047 if(!p_pStream->device()->open(QIODevice::WriteOnly))
2049 qWarning(
"Cannot write to %s\n", t_sFileName.toUtf8().constData());
2051 return p_pEmptyStream;
2074 QString t_sFileName = t_pStream->streamName();
2079 if(!t_pStream->open(QIODevice::ReadWrite)) {
2080 qCritical(
"Cannot open %s\n", t_sFileName.toUtf8().constData());
2085 long dirpos,pointerpos;
2087 QFile *file = qobject_cast<QFile *>(t_pStream->device());
2089 if (file !=
nullptr) {
2093 pointerpos = t_pStream->dir()[t_pStream->nent()-2]->pos;
2094 if(!t_pStream->read_tag(t_pTag,pointerpos)){
2095 qCritical(
"Could not read last tag in the directory list!");
2101 t_pStream->write_tag(t_pTag,pointerpos);
2106 pointerpos = t_pStream->dir()[1]->pos;
2107 if(!t_pStream->read_tag(t_pTag,pointerpos)){
2108 qCritical(
"Could not read directory pointer!");
2115 dirpos = *t_pTag->toInt();
2120 t_pStream->write_dir_pointer(-1, pointerpos);
2124 file->resize(dirpos);
2129 t_pStream->device()->seek(file->size());
2145 fiff_int_t data_type = 4;
2150 sel.resize(1,info.
nchan);
2151 for (k = 0; k < info.
nchan; ++k)
2155 QList<FiffChInfo> chs;
2157 for(k = 0; k < sel.cols(); ++k)
2158 chs << info.
chs.at(sel(0,k));
2160 fiff_int_t nchan = chs.size();
2182 QList<fiff_int_t> blocks;
2184 bool have_hpi_result =
false;
2185 bool have_isotrak =
false;
2186 if (blocks.size() > 0 && !info.
filename.isEmpty())
2191 if(!t_pStream2->open()){
2192 qDebug() <<
"Failed to open file. Returning early";
2196 for(qint32 k = 0; k < blocks.size(); ++k)
2198 QList<FiffDirNode::SPtr> nodes = t_pStream2->dirtree()->dir_tree_find(blocks[k]);
2201 have_hpi_result =
true;
2204 have_isotrak =
true;
2230 if (!have_hpi_result)
2233 t_pStream->write_coord_trans(info.
dev_head_t);
2236 t_pStream->write_coord_trans(info.
ctf_head_t);
2241 if (info.
dig.size() > 0 && !have_isotrak)
2244 for (qint32 k = 0; k < info.
dig.size(); ++k)
2245 t_pStream->write_dig_point(info.
dig[k]);
2254 t_pStream->write_proj(info.
projs);
2258 t_pStream->write_ctf_comp(info.
comps);
2262 if (info.
bads.size() > 0)
2288 cals = RowVectorXd(nchan);
2289 for(k = 0; k < nchan; ++k)
2294 chs[k].scanNo = k+1;
2298 cals[k] = chs[k].cal;
2299 t_pStream->write_ch_info(chs[k]);
2320 this->device()->seek(pos);
2323 QFile* file = qobject_cast<QFile*> (this->device());
2325 this->device()->seek(file->size());
2327 pos = this->device()->pos();
2329 fiff_int_t datasize = p_pTag->size();
2331 *this << static_cast<qint32>(p_pTag->kind);
2332 *this << static_cast<qint32>(p_pTag->type);
2333 *this << static_cast<qint32>(datasize);
2334 *this << static_cast<qint32>(p_pTag->next);
2343 this->writeRawData(p_pTag->data(),datasize);
2353 fiff_long_t pos = this->device()->pos();
2374 fiff_int_t datasize= 4*13 + 4*7 + 16;
2378 *
this << (qint32)datasize;
2384 *
this << (qint32)ch.
scanNo;
2385 *
this << (qint32)ch.
logNo;
2386 *
this << (qint32)ch.
kind;
2399 *
this << (qint32)ch.
unit;
2405 fiff_int_t len = ch.
ch_name.size();
2408 ch_name = ch.
ch_name.mid(0, 15);
2412 len = ch_name.size();
2414 this->writeRawData(ch_name.toUtf8().constData(),len);
2417 const char* chNull =
"";
2418 for(qint32 i = 0; i < 16-len; ++i)
2419 this->writeRawData(chNull,1);
2429 fiff_long_t pos = this->device()->pos();
2438 for(i = 0; i < 3; ++i)
2439 *
this << chpos.
r0[i];
2441 for(i = 0; i < 3; ++i)
2442 *
this << chpos.
ex[i];
2444 for(i = 0; i < 3; ++i)
2445 *
this << chpos.
ey[i];
2447 for(i = 0; i < 3; ++i)
2448 *
this << chpos.
ez[i];
2457 fiff_long_t pos = this->device()->pos();
2467 fiff_int_t datasize = 4*2*12 + 4*2;
2471 *
this << (qint32)datasize;
2477 *
this << (qint32)trans.
from;
2478 *
this << (qint32)trans.
to;
2484 for (r = 0; r < 3; ++r)
2485 for (c = 0; c < 3; ++c)
2486 *
this <<
static_cast<float>(trans.
trans(r,c));
2487 for (r = 0; r < 3; ++r)
2488 *
this <<
static_cast<float>(trans.
trans(r,3));
2493 for (r = 0; r < 3; ++r)
2494 for (c = 0; c < 3; ++c)
2495 *
this <<
static_cast<float>(trans.
invtrans(r,c));
2496 for (r = 0; r < 3; ++r)
2497 *
this <<
static_cast<float>(trans.
invtrans(r,3));
2506 fiff_long_t pos = this->device()->pos();
2515 if (p_FiffCov.
nfree > 0)
2520 if(p_FiffCov.
names.size() > 0)
2534 qint32 dim = p_FiffCov.
dim;
2535 qint32 n = dim*(dim+1)/2;
2539 for(qint32 i = 0; i < dim; ++i)
2540 for(qint32 j = 0; j <= i; ++j)
2541 vals(count++) = p_FiffCov.
data(i,j);
2549 if(p_FiffCov.
eig.size() > 0 && p_FiffCov.
eigvec.size() > 0)
2561 if(p_FiffCov.
bads.size() > 0)
2579 fiff_long_t pos = this->device()->pos();
2581 if (comps.size() <= 0)
2587 for(qint32 k = 0; k < comps.size(); ++k)
2601 if(comps[k].save_calibrated) {
2602 comp.
data->data = (comp.
rowcals.asDiagonal()).inverse()* comp.
data->data * (comp.
colcals.asDiagonal()).inverse();
2617 fiff_long_t pos = this->device()->pos();
2626 fiff_int_t datasize = 5*4;
2630 *
this << (qint32)datasize;
2636 *
this << (qint32)dig.
kind;
2637 *
this << (qint32)dig.
ident;
2638 for(qint32 i = 0; i < 3; ++i)
2652 this->device()->seek(pos);
2655 QFile* file = qobject_cast<QFile*> (this->device());
2657 this->device()->seek(file->size());
2659 pos = this->device()->pos();
2661 fiff_int_t datasize = 1 * 4;
2665 *
this << (qint32)datasize;
2666 *
this << (qint32)next;
2691 this->device()->seek(pos);
2694 QFile* file = qobject_cast<QFile*> (this->device());
2696 this->device()->seek(file->size());
2699 pos = this->device()->pos();
2706 *
this << (qint32)datasize;
2712 for(qint32 i = 0; i <
nent; ++i) {
2713 *
this << (qint32)
dir[i]->kind;
2714 *
this << (qint32)
dir[i]->type;
2715 *
this << (qint32)
dir[i]->size;
2716 *
this << (qint32)
dir[i]->pos;
2726 fiff_long_t pos = this->device()->pos();
2728 qint32 datasize = nel * 8;
2730 *
this << (qint32)kind;
2732 *
this << (qint32)datasize;
2741 for(qint32 i = 0; i < nel; ++i)
2744 memcpy(&bits, &data[i],
sizeof(
double));
2755 fiff_long_t pos = this->device()->pos();
2757 qint32 datasize = nel * 4;
2759 *
this << (qint32)kind;
2761 *
this << (qint32)datasize;
2764 for(qint32 i = 0; i < nel; ++i)
2774 fiff_long_t pos = this->device()->pos();
2776 qint32 numel = mat.rows() * mat.cols();
2778 fiff_int_t datasize = 4*numel + 4*3;
2780 *
this << (qint32)kind;
2782 *
this << (qint32)datasize;
2787 for(i = 0; i < mat.rows(); ++i)
2788 for(j = 0; j < mat.cols(); ++j)
2792 dims[0] = mat.cols();
2793 dims[1] = mat.rows();
2796 for(i = 0; i < 3; ++i)
2806 fiff_long_t pos = this->device()->pos();
2816 qint32 nnzm = mat.nonZeros();
2817 qint32 ncol = mat.cols();
2818 fiff_int_t datasize = 4*nnzm + 4*nnzm + 4*(ncol+1) + 4*4;
2822 using T = Eigen::Triplet<float>;
2824 s.reserve(mat.nonZeros());
2825 for (
int k=0; k < mat.outerSize(); ++k)
2826 for (SparseMatrix<float>::InnerIterator it(mat,k); it; ++it)
2827 s.push_back(T(it.row(), it.col(), it.value()));
2832 std::vector<qint32> cols, starts;
2835 for(i = 0; i < s.size(); ++i)
2837 if((
signed) s[i].col() != v_old)
2840 cols.push_back(s[i].col());
2841 starts.push_back(i);
2845 *
this << (qint32)kind;
2847 *
this << (qint32)datasize;
2853 for(i = 0; i < s.size(); ++i)
2854 *
this << s[i].value();
2859 for(i = 0; i < s.size(); ++i)
2860 *
this << s[i].row();
2865 RowVectorXi ptrs = RowVectorXi::Ones(ncol+1);
2868 for(k = 0; k < cols.size(); ++k)
2869 ptrs[cols[k]] = starts[k];
2874 for(k = ncol; k >= 1; --k)
2876 ptrs[k-1] = ptrs[k];
2878 for(i = 0; i < (quint32)ptrs.size(); ++i)
2884 dims[0] = mat.nonZeros();
2885 dims[1] = mat.rows();
2886 dims[2] = mat.cols();
2889 for(i = 0; i < 4; ++i)
2899 fiff_long_t pos = this->device()->pos();
2909 qint32 nnzm = mat.nonZeros();
2910 qint32 nrow = mat.rows();
2911 fiff_int_t datasize = 4*nnzm + 4*nnzm + 4*(nrow+1) + 4*4;
2915 using T = Eigen::Triplet<float>;
2917 s.reserve(mat.nonZeros());
2918 for (
int k=0; k < mat.outerSize(); ++k)
2919 for (SparseMatrix<float>::InnerIterator it(mat,k); it; ++it)
2920 s.push_back(T(it.row(), it.col(), it.value()));
2925 std::vector<qint32> rows, starts;
2928 for(i = 0; i < s.size(); ++i)
2930 if((
signed) s[i].row() != v_old)
2933 rows.push_back(s[i].row());
2934 starts.push_back(i);
2941 *
this << (qint32)kind;
2943 *
this << (qint32)datasize;
2949 for(i = 0; i < s.size(); ++i)
2950 *
this << s[i].value();
2955 for(i = 0; i < s.size(); ++i)
2956 *
this << s[i].col();
2961 RowVectorXi ptrs = RowVectorXi::Ones(nrow+1);
2964 for(k = 0; k < rows.size(); ++k)
2965 ptrs[rows[k]] = starts[k];
2971 for(k = nrow; k >= 1; --k)
2973 ptrs[k-1] = ptrs[k];
2976 for(i = 0; i < (quint32)ptrs.size(); ++i)
2983 dims[0] = mat.nonZeros();
2984 dims[1] = mat.rows();
2985 dims[2] = mat.cols();
2988 for(i = 0; i < 4; ++i)
2998 fiff_long_t pos = this->device()->pos();
3011 fiff_int_t datasize = 5*4;
3013 *
this << (qint32)kind;
3015 *
this << (qint32)datasize;
3022 data[1] = t_id.
machid[0];
3023 data[2] = t_id.
machid[1];
3027 for(qint32 i = 0; i < 5; ++i)
3037 fiff_long_t pos = this->device()->pos();
3056 QList<FiffChInfo> chs;
3057 for(k = 0; k < p_FiffInfoBase.
nchan; ++k)
3058 chs << p_FiffInfoBase.
chs[k];
3060 for(k = 0; k < p_FiffInfoBase.
nchan; ++k)
3065 chs[k].scanNo = k+1;
3072 bool have_hpi_result =
false;
3077 if (!have_hpi_result)
3088 if (p_FiffInfoBase.
bads.size() > 0)
3104 fiff_long_t pos = this->device()->pos();
3106 fiff_int_t datasize = nel * 4;
3108 *
this << (qint32)kind;
3110 *
this << (qint32)datasize;
3111 *
this << (qint32)next;
3113 for(qint32 i = 0; i < nel; ++i)
3123 fiff_long_t pos = this->device()->pos();
3128 qint32 numel = mat.rows() * mat.cols();
3130 fiff_int_t datasize = 4*numel + 4*3;
3132 *
this << (qint32)kind;
3134 *
this << (qint32)datasize;
3139 for(i = 0; i < mat.rows(); ++i)
3140 for(j = 0; j < mat.cols(); ++j)
3144 dims[0] = mat.cols();
3145 dims[1] = mat.rows();
3148 for(i = 0; i < 3; ++i)
3158 QString all = data.join(
":");
3166 fiff_long_t pos = this->device()->pos();
3185 fiff_long_t pos = this->device()->pos();
3187 if (projs.size() <= 0)
3192 for(qint32 k = 0; k < projs.size(); ++k)
3199 float fValue = 0.0f;
3205 qint32 bValue = (qint32)projs[k].active;
3220 fiff_long_t pos = this->device()->pos();
3222 if (p_FiffEvokedSet.
evoked.isEmpty())
3238 float sfreq = p_FiffEvokedSet.
info.
sfreq;
3241 for (
int k = 0; k < p_FiffEvokedSet.
info.
nchan; ++k) {
3250 if (!p_FiffEvokedSet.
info.
projs.isEmpty())
3255 for (
int j = 0; j < p_FiffEvokedSet.
evoked.size(); ++j) {
3263 int first = evoked.
first;
3266 int last = evoked.
last;
3274 int nave = evoked.
nave;
3277 Eigen::MatrixXf floatData = evoked.
data.cast<
float>();
3293 const RowVectorXd& cals)
3295 if (buf.rows() != cals.cols())
3297 qWarning(
"buffer and calibration sizes do not match\n");
3301 using T = Eigen::Triplet<double>;
3302 std::vector<T> tripletList;
3303 tripletList.reserve(cals.cols());
3304 for(qint32 i = 0; i < cals.cols(); ++i)
3305 tripletList.push_back(T(i, i, 1.0/cals[i]));
3307 SparseMatrix<double> inv_calsMat(cals.cols(), cals.cols());
3308 inv_calsMat.setFromTriplets(tripletList.begin(), tripletList.end());
3310 MatrixXf tmp = (inv_calsMat*buf).cast<float>();
3318 const SparseMatrix<double>& mult)
3320 if (buf.rows() != mult.cols()) {
3321 qWarning(
"buffer and mult sizes do not match\n");
3325 SparseMatrix<double> inv_mult(mult.rows(), mult.cols());
3326 for (
int k=0; k<inv_mult.outerSize(); ++k)
3327 for (SparseMatrix<double>::InnerIterator it(mult,k); it; ++it)
3328 inv_mult.coeffRef(it.row(),it.col()) = 1/it.value();
3330 MatrixXf tmp = (inv_mult*buf).cast<float>();
3339 MatrixXf tmp = buf.cast<
float>();
3347 const QString& data)
3349 fiff_long_t pos = this->device()->pos();
3351 fiff_int_t datasize = data.size();
3352 *
this << (qint32)kind;
3354 *
this << (qint32)datasize;
3357 this->writeRawData(data.toUtf8().constData(),datasize);
3366 fiff_int_t datasize = data.size();
3369 *
this << 4+(qint32)datasize;
3373 this->writeRawData(data.toUtf8().constData(),datasize);
3378QList<FiffDirEntry::SPtr> FiffStream::make_dir(
bool *ok)
3381 QList<FiffDirEntry::SPtr>
dir;
3388 if(!this->device()->seek(SEEK_SET))
3397 if (this->status() != QDataStream::Ok) {
3398 this->resetStatus();
3410 t_pFiffDirEntry->kind = t_pTag->kind;
3411 t_pFiffDirEntry->type = t_pTag->type;
3412 t_pFiffDirEntry->size = t_pTag->size();
3413 t_pFiffDirEntry->pos = (fiff_long_t)pos;
3415 dir.append(t_pFiffDirEntry);
3416 if (t_pTag->next < 0)
3423 t_pFiffDirEntry->kind = -1;
3424 t_pFiffDirEntry->type = -1;
3425 t_pFiffDirEntry->size = -1;
3426 t_pFiffDirEntry->pos = -1;
3427 dir.append(t_pFiffDirEntry);
3438 QFile srcFile(fromPath);
3439 if (!srcFile.open(QIODevice::ReadOnly)) {
3440 qWarning(
"FiffStream::copyProcessingHistory - Cannot open source file %s",
3441 fromPath.toUtf8().constData());
3446 if (!srcStream.
open()) {
3447 qWarning(
"FiffStream::copyProcessingHistory - Cannot parse source FIFF file %s",
3448 fromPath.toUtf8().constData());
3455 if (histNodes.isEmpty()) {
3456 qWarning(
"FiffStream::copyProcessingHistory - No processing history block found in %s",
3457 fromPath.toUtf8().constData());
3464 std::vector<FiffTag::UPtr> histTags;
3465 for (
int i = 0; i < histNode->nent(); ++i) {
3467 if (srcStream.
read_tag(tag, histNode->dir[i]->pos)) {
3468 histTags.push_back(std::move(tag));
3474 QFile dstFile(toPath);
3477 qWarning(
"FiffStream::copyProcessingHistory - Cannot open destination file %s for update",
3478 toPath.toUtf8().constData());
3484 for (
const auto& tag : histTags) {
3485 dstStream->write_tag(tag);
3501 qWarning(
"Fiff::open: file does not start with a file id tag\n");
3507 qWarning(
"Fiff::open: file does not start with a file id tag\n");
3510 if (p_pTag->size() != 20)
3512 qWarning(
"Fiff::open: file does not start with a file id tag\n");
Header-only Eigen matrix text I/O — round-trips dense matrices to whitespace-separated ASCII for cros...
128-bit FIFF identifier record (machine ID + creation time) used to stamp files, blocks and parent re...
FIFF continuous raw recording: FiffInfo plus a directory of FIFF_DATA_BUFFER tags for random-access s...
#define FIFF_MNE_COV_KIND
#define FIFF_MNE_COORD_FRAME
#define FIFF_MNE_CTF_COMP_KIND
#define FIFFV_COORD_DEVICE
#define FIFF_MNE_COV_DIAG
#define FIFFB_MNE_CTF_COMP_DATA
#define FIFF_MNE_CTF_COMP_CALIBRATED
#define FIFF_MNE_ROW_NAMES
#define FIFF_MNE_COV_EIGENVALUES
#define FIFF_MNE_PROJ_ITEM_ACTIVE
#define FIFFV_MNE_COORD_CTF_HEAD
#define FIFF_MNE_COL_NAMES
#define FIFF_MNE_ENV_WORKING_DIR
#define FIFF_MNE_ENV_COMMAND_LINE
#define FIFF_MNE_RT_COMMAND
#define FIFF_MNE_CTF_COMP_DATA
#define FIFF_MNE_CH_NAME_LIST
#define FIFFB_MNE_CTF_COMP
#define FIFF_MNE_COV_NFREE
#define FIFFB_MNE_PARENT_MEAS_FILE
#define FIFF_MNE_COV_EIGENVECTORS
#define FIFFV_COORD_UNKNOWN
#define FIFFB_MNE_BAD_CHANNELS
#define FIFFB_MNE_NAMED_MATRIX
#define FIFF_MNE_FILE_NAME
High-level digitization data: dig points plus the device→head transform and fitting metadata that tog...
Minimal measurement-info subset (channel list, sampling rate, basic transforms) shared by FIFF reader...
Recursive node of the parsed FIFF block tree (FIFFB_* hierarchy with directory entries and children).
FIFF channel descriptor record (FIFF_CH_INFO): per-channel logical/scanner numbers,...
Set of averaged evoked responses sharing a FiffInfo, plus the ave-style category / rejection descript...
Full FIFF measurement metadata: everything from FIFFB_MEAS / FIFFB_MEAS_INFO needed to interpret a re...
Noise / data covariance matrix as stored under FIFFB_MNE_COV, with channel names, kind,...
Coil-frame position record embedded inside FIFF_CH_INFO: coil location and 3x3 EX/EY/EZ orientation t...
#define FIFF_GANTRY_ANGLE
#define FIFF_PARENT_BLOCK_ID
#define FIFFV_PROJ_ITEM_FIELD
#define FIFF_XPLOTTER_LAYOUT
#define FIFFB_PROCESSING_HISTORY
#define FIFFT_MATRIX_FLOAT
#define FIFFT_CH_INFO_STRUCT
#define FIFF_EXPERIMENTER
#define FIFFT_RCS_MATRIX_FLOAT
#define FIFFT_CCS_MATRIX_FLOAT
#define FIFF_FIRST_SAMPLE
#define FIFFV_ASPECT_AVERAGE
#define FIFFB_SMSH_RAW_DATA
#define FIFF_PROJ_ITEM_TIME
#define FIFFV_LITTLE_ENDIAN
#define FIFFB_PROCESSED_DATA
#define FIFFV_ASPECT_STD_ERR
#define FIFF_PROJ_ITEM_VECTORS
#define FIFF_PROJ_ITEM_KIND
#define FIFFB_HPI_SUBSYSTEM
#define FIFFB_CONTINUOUS_DATA
#define FIFFV_NATIVE_ENDIAN
#define FIFF_PROJ_ITEM_CH_NAME_LIST
#define FIFFT_DIR_ENTRY_STRUCT
#define FIFFT_COORD_TRANS_STRUCT
#define FIFFT_DIG_POINT_STRUCT
#define FIFF_PROJ_ITEM_NVEC
FIFF tag: the 16-byte tag header (kind, type, size, next) plus its decoded payload.
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
FIFF binary tag-stream layer: wraps a QIODevice to read and write FIFF tags, directories,...
Single digitization point (FIFF_DIG_POINT) with kind (cardinal/HPI/EEG/extra), identifier and 3D coor...
CTF / 4D Neuroimaging software gradient-compensation matrix block (FIFFB_MNE_CTF_COMP_DATA).
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 > trans
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > invtrans
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...
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< 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.
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)