v2.0.0
Loading...
Searching...
No Matches
fiff_tag.h
Go to the documentation of this file.
1//=============================================================================================================
35
36#ifndef FIFF_TAG_H
37#define FIFF_TAG_H
38
39//=============================================================================================================
40// DEFINES
41//=============================================================================================================
42
43/* NOTE:
44 The architecture is now deduced from the operating system, which is
45 a bit stupid way, since the same operating system can me run on various
46 architectures. This may need revision later on. */
47
48#if defined(DARWIN)
49
50#if defined(__LITTLE_ENDIAN__)
51#define INTEL_X86_ARCH
52#else
53#define BIG_ENDIAN_ARCH
54#endif
55
56#else
57
58#if defined(__hpux) || defined(__Lynx__) || defined(__sun)
59#define BIG_ENDIAN_ARCH
60#else
61#if defined(__linux) || defined(WIN32) || defined(__APPLE__)
62#define INTEL_X86_ARCH
63#endif
64
65#endif
66#endif
67
68#define NATIVE_ENDIAN FIFFV_LITTLE_ENDIAN
69
70#ifdef INTEL_X86_ARCH
71#define NATIVE_ENDIAN FIFFV_LITTLE_ENDIAN
72#endif
73
74#ifdef BIG_ENDIAN_ARCH
75#define NATIVE_ENDIAN FIFFV_BIG_ENDIAN
76#endif
77
78//=============================================================================================================
79// INCLUDES
80//=============================================================================================================
81
82#include "fiff_global.h"
83#include "fiff_constants.h"
84#include "fiff_file.h"
85#include "fiff_types.h"
86#include "fiff_id.h"
87#include "fiff_coord_trans.h"
88#include "fiff_ch_info.h"
89#include "fiff_ch_pos.h"
90#include "fiff_dir_entry.h"
91#include "fiff_dig_point.h"
92
93//=============================================================================================================
94// EIGEN INCLUDES
95//=============================================================================================================
96
97#include <Eigen/Core>
98#include <Eigen/SparseCore>
99
100//=============================================================================================================
101// QT INCLUDES
102//=============================================================================================================
103
104#include <QDebug>
105#include <QByteArray>
106#include <QList>
107#include <QSharedPointer>
108#include <QVector>
109
110//=============================================================================================================
111// STL INCLUDES
112//=============================================================================================================
113
114#include <iostream>
115#include <memory>
116
117//=============================================================================================================
118// DEFINE NAMESPACE FIFFLIB
119//=============================================================================================================
120
121namespace FIFFLIB
122{
123
124class FiffStream;
125class FiffDirNode;
126
127//=============================================================================================================
128// FORWARD DECLARATIONS
129//=============================================================================================================
130//
131// The magic hexadecimal values
132//
133#define IS_MATRIX 0xFFFF0000
134#define MATRIX_CODING_DENSE 0x00004000
135#define MATRIX_CODING_CCS 0x00004010
136#define MATRIX_CODING_RCS 0x00004020
137#define DATA_TYPE 0x0000FFFF
138
139//const fiff_int_t IS_MATRIX = 4294901760; /**< Is Matrix encoding. ffff0000. */
140//const fiff_int_t MATRIX_CODING_DENSE = 16384; /**< MATRIX_CODING_DENSE encoding. 4000. */
141//const fiff_int_t MATRIX_CODING_CCS = 16400; /**< MATRIX_CODING_CCS encoding. 4010. */
142//const fiff_int_t MATRIX_CODING_RCS = 16416; /**< MATRIX_CODING_RCS encoding. 4020. */
143//const fiff_int_t DATA_TYPE = 65535; /**< DATA_TYPE encoding. ffff. */
144
145//=============================================================================================================
158class FIFFSHARED_EXPORT FiffTag : public QByteArray
159{
160
161public:
162 using SPtr = QSharedPointer<FiffTag>;
163 using ConstSPtr = QSharedPointer<const FiffTag>;
164 using UPtr = std::unique_ptr<FiffTag>;
165 using ConstUPtr = std::unique_ptr<const FiffTag>;
166
167 //=========================================================================================================
171 FiffTag();
172
173 //=========================================================================================================
179 FiffTag(const FiffTag& p_FiffTag) = default;
180
181 //=========================================================================================================
185 FiffTag(FiffTag&& other) = default;
186
187 //=========================================================================================================
191 FiffTag& operator=(const FiffTag& other) = default;
192
193 //=========================================================================================================
197 FiffTag& operator=(FiffTag&& other) = default;
198
199 //=========================================================================================================
203 ~FiffTag() = default;
204
205 //=========================================================================================================
211 fiff_int_t getMatrixCoding() const;
212
213 //=========================================================================================================
219 bool isMatrix() const;
220
221 //=========================================================================================================
231 bool getMatrixDimensions(qint32& p_ndim, QVector<qint32>& p_Dims) const;
232
233 //=========================================================================================================
239 fiff_int_t getType() const;
240
241 //=========================================================================================================
247 QString getInfo() const;
248
249 //
250 // Simple types
251 //
252 //=========================================================================================================
259 inline quint8* toByte() const;
260
261 //=========================================================================================================
268 inline quint16* toUnsignedShort() const;
269
270 //=========================================================================================================
277 inline qint16* toShort() const;
278
279 //=========================================================================================================
286 inline quint32* toUnsignedInt() const;
287
288 //=========================================================================================================
295 inline qint32* toInt() const;
296
297 //=========================================================================================================
304 inline qint32* toJulian() const;
305
306 //=========================================================================================================
313 inline const float* toFloat() const;
314
315 //=========================================================================================================
322 inline const double* toDouble() const;
323
324 //=========================================================================================================
330 inline QString toString() const;
331
332 //=========================================================================================================
339 inline qint16* toDauPack16() const;
340
341 //
342 // Structures
343 //
344 //=========================================================================================================
350 inline FiffId toFiffID() const;
351
352 //=========================================================================================================
358 inline FiffDigPoint toDigPoint() const;
359
360 //=========================================================================================================
366 inline FiffCoordTrans toCoordTrans() const;
367
368 //=========================================================================================================
374 inline FiffChInfo toChInfo() const;
375
376// //=========================================================================================================
377// /**
378// * to fiff OLD PACK
379// */
380// inline fiff_coord_trans_t toCoordTrans() const;
381
382 //=========================================================================================================
388 inline QList< QSharedPointer<FiffDirEntry> > toDirEntry() const;
389
390 //
391 // MATRIX
392 //
393 //=========================================================================================================
399 inline Eigen::MatrixXi toIntMatrix() const;
400
401 //=========================================================================================================
409 inline Eigen::MatrixXf toFloatMatrix() const;
410
411 //=========================================================================================================
419 inline Eigen::SparseMatrix<double> toSparseFloatMatrix() const;
420
421 //
422 //from fiff_combat.c
423 //
424
425 //=========================================================================================================
431 static void convert_ch_pos(FiffChPos* pos);
432
433 /*
434 * Data type conversions for the little endian systems.
435 */
444 static void convert_matrix_from_file_data(const FiffTag::UPtr& tag);
445
446 //=========================================================================================================
452 static void convert_matrix_to_file_data(const FiffTag::UPtr& tag);
453
454 //
455 // Data type conversions for the little endian systems.
456 //
457 //=========================================================================================================
471 static void convert_tag_data(const FiffTag::UPtr& tag, int from_endian, int to_endian);
472
473 //
474 // from fiff_type_spec.c
475 //
476 //=========================================================================================================
484 static fiff_int_t fiff_type_fundamental(fiff_int_t type);
485
486 //=========================================================================================================
494 static fiff_int_t fiff_type_base(fiff_int_t type);
495
496 //=========================================================================================================
504 static fiff_int_t fiff_type_matrix_coding(fiff_int_t type);
505
506 //=========================================================================================================
513 inline static qint32 storageSize();
514
515public:
516 fiff_int_t kind;
518 fiff_int_t type;
520 fiff_int_t next;
524};
525
526//=============================================================================================================
527// INLINE DEFINITIONS
528//=============================================================================================================
529
530inline qint32 FiffTag::storageSize()
531{
532 // On-disk layout: kind, type, size, next (4 x fiff_int_t)
533 // Note: 'size' is not a class member (QByteArray::size() is used at runtime),
534 // but it is part of the on-disk wire format.
535 return sizeof(FiffTag::kind) + sizeof(FiffTag::type)
536 + sizeof(fiff_int_t) /* size field on disk */
537 + sizeof(FiffTag::next);
538}
539
540//=============================================================================================================
541// Simple types
542//=============================================================================================================
543
544inline quint8* FiffTag::toByte() const
545{
546 if(this->isMatrix() || this->getType() != FIFFT_BYTE)
547 return nullptr;
548 else
549 return (quint8*)this->data();
550}
551
552//=============================================================================================================
553
554inline quint16* FiffTag::toUnsignedShort() const
555{
556 if(this->isMatrix() || this->getType() != FIFFT_USHORT)
557 return nullptr;
558 else
559 return (quint16*)this->data();
560}
561
562//=============================================================================================================
563
564inline qint16* FiffTag::toShort() const
565{
566 if(this->isMatrix() || this->getType() != FIFFT_SHORT)
567 return nullptr;
568 else
569 return (qint16*)this->data();
570}
571
572//=============================================================================================================
573
574inline quint32* FiffTag::toUnsignedInt() const
575{
576 if(this->isMatrix() || this->getType() != FIFFT_UINT)
577 return nullptr;
578 else
579 return (quint32*)this->data();
580}
581
582//=============================================================================================================
583
584inline qint32* FiffTag::toInt() const
585{
586 if(this->isMatrix() || this->getType() != FIFFT_INT) {
587 qWarning("Expected an integer tag : %d (found data type %d instead)\n",this->kind,this->getType());
588 return nullptr;
589 }
590 else
591 return (qint32*)this->data();
592}
593
594//=============================================================================================================
595
596inline qint32* FiffTag::toJulian() const
597{
598 if(this->isMatrix() || this->getType() != FIFFT_JULIAN) {
599 qWarning("Expected a julian tag : %d (found data type %d instead)\n",this->kind,this->getType());
600 return nullptr;
601 }
602 else
603 return (qint32*)this->data();
604}
605
606//=============================================================================================================
607
608inline const float* FiffTag::toFloat() const
609{
610 if(this->isMatrix() || this->getType() != FIFFT_FLOAT)
611 return nullptr;
612 else
613 return reinterpret_cast<const float*>(this->data());
614}
615
616//=============================================================================================================
617
618inline const double* FiffTag::toDouble() const
619{
620 if(this->isMatrix() || this->getType() != FIFFT_DOUBLE)
621 return nullptr;
622 else
623 return reinterpret_cast<const double*>(this->data());
624}
625
626//=============================================================================================================
627
628inline QString FiffTag::toString() const
629{
630 if(this->isMatrix() || this->getType() != FIFFT_STRING)
631 return nullptr;
632 else
633 return *this;
634}
635
636//=============================================================================================================
637
638inline qint16* FiffTag::toDauPack16() const
639{
640 if(this->isMatrix() || this->getType() != FIFFT_DAU_PACK16)
641 return nullptr;
642 else
643 return (qint16*)this->data();
644}
645
646//=============================================================================================================
647// Structures
648//=============================================================================================================
649
651{
652 FiffId p_fiffID;
653 if(this->isMatrix() || this->getType() != FIFFT_ID_STRUCT || this->data() == nullptr)
654 return p_fiffID;
655 else
656 {
657 const qint32* t_pInt32 = (qint32*)this->data();
658
659 p_fiffID.version = t_pInt32[0];
660 p_fiffID.machid[0] = t_pInt32[1];
661 p_fiffID.machid[1] = t_pInt32[2];
662 p_fiffID.time.secs = t_pInt32[3];
663 p_fiffID.time.usecs = t_pInt32[4];
664
665 return p_fiffID;
666 }
667}
668
669//=============================================================================================================
670
672{
673
674 FiffDigPoint t_fiffDigPoint;
675 if(this->isMatrix() || this->getType() != FIFFT_DIG_POINT_STRUCT || this->data() == nullptr)
676 return t_fiffDigPoint;
677 else
678 {
679 auto *t_pInt32 = reinterpret_cast<const qint32*>(this->data());
680
681 t_fiffDigPoint.kind = t_pInt32[0];
682 t_fiffDigPoint.ident = t_pInt32[1];
683
684 auto *t_pFloat = reinterpret_cast<const float*>(this->data());
685 t_fiffDigPoint.r[0] = t_pFloat[2];
686 t_fiffDigPoint.r[1] = t_pFloat[3];
687 t_fiffDigPoint.r[2] = t_pFloat[4];
688 t_fiffDigPoint.coord_frame = 0;
689
690 return t_fiffDigPoint;
691 }
692}
693
694//=============================================================================================================
695
697{
698
699 FiffCoordTrans p_FiffCoordTrans;
700 if(this->isMatrix() || this->getType() != FIFFT_COORD_TRANS_STRUCT || this->data() == nullptr)
701 return p_FiffCoordTrans;
702 else
703 {
704 auto *t_pInt32 = reinterpret_cast<const qint32*>(this->data());
705 p_FiffCoordTrans.from = t_pInt32[0];
706 p_FiffCoordTrans.to = t_pInt32[1];
707
708 p_FiffCoordTrans.trans.setIdentity(4,4);
709 auto *t_pFloat = reinterpret_cast<const float*>(this->data());
710 int count = 0;
711 int r, c;
712 for (r = 0; r < 3; ++r) {
713 p_FiffCoordTrans.trans(r,3) = t_pFloat[11+r];
714 for (c = 0; c < 3; ++c) {
715 p_FiffCoordTrans.trans(r,c) = t_pFloat[2+count];
716 ++count;
717 }
718 }
719
720 p_FiffCoordTrans.invtrans.setIdentity(4,4);
721 count = 0;
722 for (r = 0; r < 3; ++r) {
723 p_FiffCoordTrans.invtrans(r,3) = t_pFloat[23+r];
724 for (c = 0; c < 3; ++c) {
725 p_FiffCoordTrans.invtrans(r,c) = t_pFloat[14+count];
726 ++count;
727 }
728 }
729
730 return p_FiffCoordTrans;
731 }
732}
733
734//=========================================================================================================
739{
740 FiffChInfo p_FiffChInfo;
741
742 if(this->isMatrix() || this->getType() != FIFFT_CH_INFO_STRUCT || this->data() == nullptr)
743 return p_FiffChInfo;
744 else
745 {
746 auto *t_pInt32 = reinterpret_cast<const qint32*>(this->data());
747 p_FiffChInfo.scanNo = t_pInt32[0];
748 p_FiffChInfo.logNo = t_pInt32[1];
749 p_FiffChInfo.kind = t_pInt32[2];
750 auto *t_pFloat = reinterpret_cast<const float*>(this->data());
751 p_FiffChInfo.range = t_pFloat[3];
752 p_FiffChInfo.cal = t_pFloat[4];
753
754 p_FiffChInfo.chpos.coil_type = t_pInt32[5];
755
756 //
757 // Read the coil coordinate system definition
758 //
759 qint32 r;
760 // r0
761 for (r = 0; r < 3; ++r)
762 p_FiffChInfo.chpos.r0[r] = t_pFloat[6+r];
763 // ex
764 for (r = 0; r < 3; ++r)
765 p_FiffChInfo.chpos.ex[r] = t_pFloat[6+3+r];
766 // ey
767 for (r = 0; r < 3; ++r)
768 p_FiffChInfo.chpos.ey[r] = t_pFloat[6+6+r];
769 // ez
770 for (r = 0; r < 3; ++r)
771 p_FiffChInfo.chpos.ez[r] = t_pFloat[6+9+r];
772
773 p_FiffChInfo.coord_frame = FIFFV_COORD_UNKNOWN;
774
775 //
776 // Convert loc into a more useful format
777 //
778 if (p_FiffChInfo.kind == FIFFV_MEG_CH || p_FiffChInfo.kind == FIFFV_REF_MEG_CH)
779 {
780 p_FiffChInfo.coil_trans.setIdentity(4,4);
781 // r0
782 for (r = 0; r < 3; ++r)
783 p_FiffChInfo.coil_trans(r,3) = p_FiffChInfo.chpos.r0[r];
784 // ex
785 for (r = 0; r < 3; ++r)
786 p_FiffChInfo.coil_trans(r,0) = p_FiffChInfo.chpos.ex[r];
787 // ey
788 for (r = 0; r < 3; ++r)
789 p_FiffChInfo.coil_trans(r,1) = p_FiffChInfo.chpos.ey[r];
790 // ez
791 for (r = 0; r < 3; ++r)
792 p_FiffChInfo.coil_trans(r,2) = p_FiffChInfo.chpos.ez[r];
793
794 p_FiffChInfo.coord_frame = FIFFV_COORD_DEVICE;
795 }
796 else if (p_FiffChInfo.kind == FIFFV_EEG_CH)
797 {
798 if (p_FiffChInfo.chpos.ex.norm() > 0) {
799 p_FiffChInfo.eeg_loc.block(0,0,3,1) = p_FiffChInfo.chpos.r0.block(0,0,3,1);
800 p_FiffChInfo.eeg_loc.block(0,1,3,1) = p_FiffChInfo.chpos.ex.block(0,0,3,1);
801 }
802 else {
803 p_FiffChInfo.eeg_loc.block(0,0,3,1) = p_FiffChInfo.chpos.r0.block(0,0,3,1);
804 }
805 p_FiffChInfo.coord_frame = FIFFV_COORD_HEAD;
806 }
807 //
808 // Unit and exponent
809 //
810 p_FiffChInfo.unit = t_pInt32[18];
811 p_FiffChInfo.unit_mul = t_pInt32[19];
812
813 //
814 // Handle the channel name
815 //
816 const char* orig = static_cast<const char*>(this->data());
817 p_FiffChInfo.ch_name = QString::fromUtf8(orig + 80).replace(" ","");
818
819 return p_FiffChInfo;
820 }
821}
822
823// //=========================================================================================================
824// /**
825// * to fiff OLD PACK
826// */
827// inline fiff_coord_trans_t toCoordTrans() const
828// {
829
830// }
831
832//=============================================================================================================
833
834inline QList< QSharedPointer<FiffDirEntry> > FiffTag::toDirEntry() const
835{
836// tag.data = struct('kind',{},'type',{},'size',{},'pos',{});
837 QList< QSharedPointer<FiffDirEntry> > p_ListFiffDir;
838 if(this->isMatrix() || this->getType() != FIFFT_DIR_ENTRY_STRUCT || this->data() == nullptr)
839 return p_ListFiffDir;
840 else
841 {
842 QSharedPointer<FiffDirEntry> t_pFiffDirEntry;
843 qint32* t_pInt32 = (qint32*)this->data();
844 for (int k = 0; k < this->size()/16; ++k)
845 {
846 t_pFiffDirEntry = QSharedPointer<FiffDirEntry>(new FiffDirEntry);
847 t_pFiffDirEntry->kind = t_pInt32[k*4];//fread(fid,1,'int32');
848 t_pFiffDirEntry->type = t_pInt32[k*4+1];//fread(fid,1,'uint32');
849 t_pFiffDirEntry->size = t_pInt32[k*4+2];//fread(fid,1,'int32');
850 t_pFiffDirEntry->pos = t_pInt32[k*4+3];//fread(fid,1,'int32');
851 p_ListFiffDir.append(t_pFiffDirEntry);
852 }
853 }
854 return p_ListFiffDir;
855}
856
857//=============================================================================================================
858// MATRIX
859//=============================================================================================================
860
861//=============================================================================================================
862
863inline Eigen::MatrixXi FiffTag::toIntMatrix() const
864{
865 if(!this->isMatrix() || this->getType() != FIFFT_INT || this->data() == nullptr)
866 return Eigen::MatrixXi();
867
868 qint32 ndim;
869 QVector<qint32> dims;
870 this->getMatrixDimensions(ndim, dims);
871
872 if (ndim != 2)
873 {
874 qWarning("Only two-dimensional matrices are supported at this time");
875 return Eigen::MatrixXi();
876 }
877
878 // Use copy constructor instead --> slower performance but higher memory management reliability
879 Eigen::MatrixXi p_Matrix(Eigen::Map<const Eigen::MatrixXi>(reinterpret_cast<const int*>(this->data()), dims[0], dims[1]));
880
881 return p_Matrix;
882}
883
884//=============================================================================================================
885
886inline Eigen::MatrixXf FiffTag::toFloatMatrix() const
887{
888 if(!this->isMatrix() || this->getType() != FIFFT_FLOAT || this->data() == nullptr)
889 return Eigen::MatrixXf();//NULL;
890
892 {
893 qWarning("Error in FiffTag::toFloatMatrix(): Matrix is not dense!");
894 return Eigen::MatrixXf();
895 }
896
897 qint32 ndim;
898 QVector<qint32> dims;
899 this->getMatrixDimensions(ndim, dims);
900
901 if (ndim != 2)
902 {
903 qWarning("Only two-dimensional matrices are supported at this time");
904 return Eigen::MatrixXf();
905 }
906
907 // Use copy constructor instead --> slower performance but higher memory management reliability
908 Eigen::MatrixXf p_Matrix(Eigen::Map<const Eigen::MatrixXf>(reinterpret_cast<const float*>(this->data()), dims[0], dims[1]));
909
910 return p_Matrix;
911}
912
913//=============================================================================================================
914
915inline Eigen::SparseMatrix<double> FiffTag::toSparseFloatMatrix() const
916{
917 if(!this->isMatrix() || this->getType() != FIFFT_FLOAT || this->data() == nullptr)
918 return Eigen::SparseMatrix<double>();//NULL;
919
921 {
922 qCritical("Error in FiffTag::toSparseFloatMatrix(): Matrix is not sparse!\n");
923 return Eigen::SparseMatrix<double>();//NULL;
924 }
925
926 qint32 ndim;
927 QVector<qint32> dims;
928 this->getMatrixDimensions(ndim, dims);
929
930 if (ndim != 2)
931 {
932 qWarning("Only two-dimensional matrices are supported at this time");
933 return Eigen::SparseMatrix<double>();
934 }
935
936 qint32 nnz = dims[0];
937 qint32 nrow = dims[1];
938 qint32 ncol = dims[2];
939
940 using T = Eigen::Triplet<double>;
941 std::vector<T> tripletList;
942 tripletList.reserve(nnz);
943
944 auto *t_pFloat = reinterpret_cast<const float*>(this->data());
945 auto *t_pInt = reinterpret_cast<const int*>(this->data());
946 qint32 offset1 = nnz;
947 qint32 offset2 = 2*nnz;
949 {
950 //
951 // CCS
952 //
953 qWarning("Warning in FiffTag::toSparseFloatMatrix(): CCS has to be debugged - never done before.");
954 qint32 p = 0;
955 for(qint32 j = 0; j < ncol; ++j)
956 {
957 while( p < t_pInt[offset2+j+1])
958 {
959// tripletList[p] = T(tripletList[p].row(), j, tripletList[p].value());
960 tripletList.push_back(T(t_pInt[offset1+p], j, static_cast<double>(t_pFloat[p])));
961 ++p;
962 }
963 }
964 }
965 else
966 {
967 //
968 // RCS
969 //
970 qint32 p = 0;
971 for(qint32 j = 0; j < nrow; ++j)
972 {
973 while( p < t_pInt[offset2+j+1])
974 {
975// tripletList[p] = T(j, tripletList[p].col(), tripletList[p].value());
976 tripletList.push_back(T(j, t_pInt[offset1+p], static_cast<double>(t_pFloat[p])));
977 ++p;
978 }
979 }
980 }
981
982// std::cout << "Size: " << tripletList.size() << std::endl;
983// qint32 offsetTest = tripletList.size() - 10;
984// for(qint32 i = 0; i < 10; ++i)
985// std::cout << std::endl << tripletList[offsetTest + i].row() << " " << tripletList[offsetTest + i].col() << " " << tripletList[offsetTest + i].value();
986
987 Eigen::SparseMatrix<double> p_Matrix(nrow, ncol);
988 p_Matrix.setFromTriplets(tripletList.begin(), tripletList.end());
989
990 return p_Matrix;
991}
992} // NAMESPACE
993
994#endif // FIFF_TAG_H
128-bit FIFF identifier record (machine ID + creation time) used to stamp files, blocks and parent re...
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
#define FIFFV_EEG_CH
#define FIFFV_COORD_DEVICE
#define FIFFV_REF_MEG_CH
#define FIFFV_MEG_CH
#define FIFFV_COORD_HEAD
#define FIFFV_COORD_UNKNOWN
fiff_int_t fiff_type_base(fiff_int_t type)
fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
fiff_int_t fiff_type_fundamental(fiff_int_t type)
FIFF channel descriptor record (FIFF_CH_INFO): per-channel logical/scanner numbers,...
Single entry of the FIFF tag directory: kind, type, byte size and absolute file position.
Coil-frame position record embedded inside FIFF_CH_INFO: coil location and 3x3 EX/EY/EZ orientation t...
FIFF tag-kind, block-kind and type-code numerical definitions, authoritative for FIFFLIB.
#define FIFFT_ID_STRUCT
Definition fiff_file.h:241
#define FIFFTS_MC_RCS
Definition fiff_file.h:263
#define FIFFT_CH_INFO_STRUCT
Definition fiff_file.h:240
#define FIFFT_UINT
Definition fiff_file.h:229
#define FIFFT_INT
Definition fiff_file.h:224
#define FIFFT_SHORT
Definition fiff_file.h:223
#define FIFFT_BYTE
Definition fiff_file.h:222
#define FIFFT_DAU_PACK16
Definition fiff_file.h:236
#define FIFFTS_MC_CCS
Definition fiff_file.h:262
#define FIFFT_DOUBLE
Definition fiff_file.h:226
#define FIFFT_USHORT
Definition fiff_file.h:228
#define FIFFT_JULIAN
Definition fiff_file.h:227
#define FIFFT_FLOAT
Definition fiff_file.h:225
#define FIFFT_STRING
Definition fiff_file.h:231
#define FIFFTS_MC_DENSE
Definition fiff_file.h:261
#define FIFFT_DIR_ENTRY_STRUCT
Definition fiff_file.h:242
#define FIFFT_COORD_TRANS_STRUCT
Definition fiff_file.h:245
#define FIFFT_DIG_POINT_STRUCT
Definition fiff_file.h:243
Export/import macros and build-info accessors for the FIFFLIB shared library.
#define FIFFSHARED_EXPORT
Definition fiff_global.h:44
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
Single digitization point (FIFF_DIG_POINT) with kind (cardinal/HPI/EEG/extra), identifier and 3D coor...
Primitive scalar typedefs and forward-compatible aliases backing the FIFF type system.
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...
Eigen::Matrix< float, 3, 2, Eigen::DontAlign > eeg_loc
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > coil_trans
Channel coil-frame placement: origin r0 (m) and orthonormal axes ex / ey / ez in FIFFV_COORD_DEVICE.
Definition fiff_ch_pos.h:63
Eigen::Vector3f r0
fiff_int_t coil_type
Eigen::Vector3f ey
Eigen::Vector3f ex
Eigen::Vector3f ez
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
One digitizer point: kind (cardinal/HPI/EEG/extra), ident, 3D position in FIFFV_COORD_HEAD.
Directory entry: tag kind + on-disk type + byte size + absolute file offset (16-byte record).
128-bit FIFF identifier: hardware machine ID plus creation time, stamped on every file and block.
Definition fiff_id.h:66
fiff_int_t machid[2]
Definition fiff_id.h:178
FiffTime time
Definition fiff_id.h:179
fiff_int_t version
Definition fiff_id.h:177
static fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
Definition fiff_tag.cpp:691
~FiffTag()=default
QString toString() const
Definition fiff_tag.h:628
qint16 * toShort() const
Definition fiff_tag.h:564
QSharedPointer< FiffTag > SPtr
Definition fiff_tag.h:162
Eigen::MatrixXf toFloatMatrix() const
Definition fiff_tag.h:886
quint32 * toUnsignedInt() const
Definition fiff_tag.h:574
fiff_int_t kind
Definition fiff_tag.h:516
FiffTag(FiffTag &&other)=default
std::unique_ptr< FiffTag > UPtr
Definition fiff_tag.h:164
FiffCoordTrans toCoordTrans() const
Definition fiff_tag.h:696
std::unique_ptr< const FiffTag > ConstUPtr
Definition fiff_tag.h:165
qint32 * toJulian() const
Definition fiff_tag.h:596
fiff_int_t getMatrixCoding() const
Definition fiff_tag.cpp:58
Eigen::MatrixXi toIntMatrix() const
Definition fiff_tag.h:863
quint16 * toUnsignedShort() const
Definition fiff_tag.h:554
FiffChInfo toChInfo() const
Definition fiff_tag.h:738
qint16 * toDauPack16() const
Definition fiff_tag.h:638
FiffDigPoint toDigPoint() const
Definition fiff_tag.h:671
qint32 * toInt() const
Definition fiff_tag.h:584
const double * toDouble() const
Definition fiff_tag.h:618
const float * toFloat() const
Definition fiff_tag.h:608
static void convert_tag_data(const FiffTag::UPtr &tag, int from_endian, int to_endian)
Definition fiff_tag.cpp:422
static void convert_matrix_to_file_data(const FiffTag::UPtr &tag)
Definition fiff_tag.cpp:346
FiffTag & operator=(FiffTag &&other)=default
QString getInfo() const
Definition fiff_tag.cpp:122
quint8 * toByte() const
Definition fiff_tag.h:544
bool isMatrix() const
Definition fiff_tag.cpp:65
fiff_int_t getType() const
Definition fiff_tag.cpp:108
Eigen::SparseMatrix< double > toSparseFloatMatrix() const
Definition fiff_tag.h:915
FiffId toFiffID() const
Definition fiff_tag.h:650
fiff_int_t type
Definition fiff_tag.h:518
static qint32 storageSize()
Definition fiff_tag.h:530
FiffTag & operator=(const FiffTag &other)=default
static void convert_matrix_from_file_data(const FiffTag::UPtr &tag)
Definition fiff_tag.cpp:272
fiff_int_t next
Definition fiff_tag.h:520
static void convert_ch_pos(FiffChPos *pos)
Definition fiff_tag.cpp:257
FiffTag(const FiffTag &p_FiffTag)=default
QSharedPointer< const FiffTag > ConstSPtr
Definition fiff_tag.h:163
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const
Definition fiff_tag.cpp:75
QList< QSharedPointer< FiffDirEntry > > toDirEntry() const
Definition fiff_tag.h:834