50#if defined(__LITTLE_ENDIAN__)
53#define BIG_ENDIAN_ARCH
58#if defined(__hpux) || defined(__Lynx__) || defined(__sun)
59#define BIG_ENDIAN_ARCH
61#if defined(__linux) || defined(WIN32) || defined(__APPLE__)
68#define NATIVE_ENDIAN FIFFV_LITTLE_ENDIAN
71#define NATIVE_ENDIAN FIFFV_LITTLE_ENDIAN
75#define NATIVE_ENDIAN FIFFV_BIG_ENDIAN
98#include <Eigen/SparseCore>
107#include <QSharedPointer>
163 using SPtr = QSharedPointer<FiffTag>;
165 using UPtr = std::unique_ptr<FiffTag>;
270 inline const quint8*
toByte()
const;
288 inline const qint16*
toShort()
const;
306 inline const qint32*
toInt()
const;
315 inline const qint32*
toJulian()
const;
324 inline const float*
toFloat()
const;
333 inline const double*
toDouble()
const;
399 inline QList<QSharedPointer<FiffDirEntry>>
toDirEntry()
const;
562 return reinterpret_cast<const quint8*
>(this->data());
572 return reinterpret_cast<const quint16*
>(this->data());
582 return reinterpret_cast<const qint16*
>(this->data());
592 return reinterpret_cast<const quint32*
>(this->data());
600 qWarning(
"Expected an integer tag : %d (found data type %d instead)\n", this->
kind, this->
getType());
603 return reinterpret_cast<const qint32*
>(this->data());
611 qWarning(
"Expected a julian tag : %d (found data type %d instead)\n", this->
kind, this->
getType());
614 return reinterpret_cast<const qint32*
>(this->data());
624 return reinterpret_cast<const float*
>(this->data());
634 return reinterpret_cast<const double*
>(this->data());
654 return reinterpret_cast<const qint16*
>(this->data());
667 const auto* t_pInt32 =
reinterpret_cast<const qint32*
>(this->data());
669 p_fiffID.
version = t_pInt32[0];
670 p_fiffID.
machid[0] = t_pInt32[1];
671 p_fiffID.
machid[1] = t_pInt32[2];
685 return t_fiffDigPoint;
687 auto* t_pInt32 =
reinterpret_cast<const qint32*
>(this->data());
689 t_fiffDigPoint.
kind = t_pInt32[0];
690 t_fiffDigPoint.
ident = t_pInt32[1];
692 auto* t_pFloat =
reinterpret_cast<const float*
>(this->data());
693 t_fiffDigPoint.
r[0] = t_pFloat[2];
694 t_fiffDigPoint.
r[1] = t_pFloat[3];
695 t_fiffDigPoint.
r[2] = t_pFloat[4];
698 return t_fiffDigPoint;
708 return p_FiffCoordTrans;
710 auto* t_pInt32 =
reinterpret_cast<const qint32*
>(this->data());
711 p_FiffCoordTrans.
from = t_pInt32[0];
712 p_FiffCoordTrans.
to = t_pInt32[1];
714 p_FiffCoordTrans.
trans.setIdentity(4, 4);
715 auto* t_pFloat =
reinterpret_cast<const float*
>(this->data());
718 for (r = 0; r < 3; ++r) {
719 p_FiffCoordTrans.
trans(r, 3) = t_pFloat[11 + r];
720 for (c = 0; c < 3; ++c) {
721 p_FiffCoordTrans.
trans(r, c) = t_pFloat[2 + count];
726 p_FiffCoordTrans.
invtrans.setIdentity(4, 4);
728 for (r = 0; r < 3; ++r) {
729 p_FiffCoordTrans.
invtrans(r, 3) = t_pFloat[23 + r];
730 for (c = 0; c < 3; ++c) {
731 p_FiffCoordTrans.
invtrans(r, c) = t_pFloat[14 + count];
736 return p_FiffCoordTrans;
751 auto* t_pInt32 =
reinterpret_cast<const qint32*
>(this->data());
752 p_FiffChInfo.
scanNo = t_pInt32[0];
753 p_FiffChInfo.
logNo = t_pInt32[1];
754 p_FiffChInfo.
kind = t_pInt32[2];
755 auto* t_pFloat =
reinterpret_cast<const float*
>(this->data());
756 p_FiffChInfo.
range = t_pFloat[3];
757 p_FiffChInfo.
cal = t_pFloat[4];
766 for (r = 0; r < 3; ++r)
767 p_FiffChInfo.
chpos.
r0[r] = t_pFloat[6 + r];
769 for (r = 0; r < 3; ++r)
770 p_FiffChInfo.
chpos.
ex[r] = t_pFloat[6 + 3 + r];
772 for (r = 0; r < 3; ++r)
773 p_FiffChInfo.
chpos.
ey[r] = t_pFloat[6 + 6 + r];
775 for (r = 0; r < 3; ++r)
776 p_FiffChInfo.
chpos.
ez[r] = t_pFloat[6 + 9 + r];
786 for (r = 0; r < 3; ++r)
789 for (r = 0; r < 3; ++r)
792 for (r = 0; r < 3; ++r)
795 for (r = 0; r < 3; ++r)
800 if (p_FiffChInfo.
chpos.
ex.norm() > 0) {
801 p_FiffChInfo.
eeg_loc.block(0, 0, 3, 1) = p_FiffChInfo.
chpos.
r0.block(0, 0, 3, 1);
802 p_FiffChInfo.
eeg_loc.block(0, 1, 3, 1) = p_FiffChInfo.
chpos.
ex.block(0, 0, 3, 1);
804 p_FiffChInfo.
eeg_loc.block(0, 0, 3, 1) = p_FiffChInfo.
chpos.
r0.block(0, 0, 3, 1);
811 p_FiffChInfo.
unit = t_pInt32[18];
812 p_FiffChInfo.
unit_mul = t_pInt32[19];
817 const char* orig =
static_cast<const char*
>(this->data());
818 p_FiffChInfo.
ch_name = QString::fromUtf8(orig + 80,
static_cast<qsizetype
>(qstrnlen(orig + 80, 16))).replace(
" ",
"");
838 QList<QSharedPointer<FiffDirEntry>> p_ListFiffDir;
840 return p_ListFiffDir;
842 QSharedPointer<FiffDirEntry> t_pFiffDirEntry;
843 const auto* t_pInt32 =
reinterpret_cast<const qint32*
>(this->data());
844 for (
int k = 0; k < this->size() / 16; ++k) {
845 t_pFiffDirEntry = QSharedPointer<FiffDirEntry>(
new FiffDirEntry);
846 t_pFiffDirEntry->kind = t_pInt32[k * 4];
847 t_pFiffDirEntry->type = t_pInt32[k * 4 + 1];
848 t_pFiffDirEntry->size = t_pInt32[k * 4 + 2];
849 t_pFiffDirEntry->pos = t_pInt32[k * 4 + 3];
850 p_ListFiffDir.append(t_pFiffDirEntry);
853 return p_ListFiffDir;
865 return Eigen::MatrixXi();
868 QVector<qint32> dims;
872 qWarning(
"Only two-dimensional matrices are supported at this time");
873 return Eigen::MatrixXi();
877 Eigen::MatrixXi p_Matrix(Eigen::Map<const Eigen::MatrixXi>(
reinterpret_cast<const int*
>(this->data()), dims[0], dims[1]));
887 return Eigen::MatrixXf();
890 qWarning(
"Error in FiffTag::toFloatMatrix(): Matrix is not dense!");
891 return Eigen::MatrixXf();
895 QVector<qint32> dims;
899 qWarning(
"Only two-dimensional matrices are supported at this time");
900 return Eigen::MatrixXf();
904 Eigen::MatrixXf p_Matrix(Eigen::Map<const Eigen::MatrixXf>(
reinterpret_cast<const float*
>(this->data()), dims[0], dims[1]));
FIFF channel descriptor record (FIFF_CH_INFO): per-channel logical/scanner numbers,...
Symbolic FIFF tag, block, value, unit and channel-type constants shared across FIFFLIB.
constexpr auto FIFFV_COORD_HEAD
constexpr auto FIFFV_COORD_DEVICE
constexpr auto FIFFV_COORD_UNKNOWN
constexpr auto FIFFV_REF_MEG_CH
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
FIFF tag-kind, block-kind and type-code numerical definitions, authoritative for FIFFLIB.
constexpr auto FIFFTS_MC_DENSE
constexpr auto FIFFT_JULIAN
constexpr auto FIFFT_CH_INFO_STRUCT
constexpr auto FIFFT_DIG_POINT_STRUCT
constexpr auto FIFFT_BYTE
constexpr auto FIFFT_UINT
constexpr auto FIFFT_ID_STRUCT
constexpr auto FIFFT_COORD_TRANS_STRUCT
constexpr auto FIFFT_DOUBLE
constexpr auto FIFFT_STRING
constexpr auto FIFFT_DAU_PACK16
constexpr auto FIFFT_USHORT
constexpr auto FIFFT_SHORT
constexpr auto FIFFT_FLOAT
constexpr auto FIFFT_DIR_ENTRY_STRUCT
Export/import macros and build-info accessors for the FIFFLIB shared library.
#define FIFFSHARED_EXPORT
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)
Coil-frame position record embedded inside FIFF_CH_INFO: coil location and 3x3 EX/EY/EZ orientation t...
Single entry of the FIFF tag directory: kind, type, byte size and absolute file position.
Single digitization point (FIFF_DIG_POINT) with kind (cardinal/HPI/EEG/extra), identifier and 3D coor...
128-bit FIFF identifier record (machine ID + creation time) used to stamp files, blocks and parent re...
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.
constexpr auto MATRIX_CODING_CCS
constexpr auto MATRIX_CODING_DENSE
constexpr auto MATRIX_CODING_RCS
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
static qint32 storageSize()
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
static qint32 storageSize()
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > trans
One digitizer point: kind (cardinal/HPI/EEG/extra), ident, 3D position in FIFFV_COORD_HEAD.
static qint32 storageSize()
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.
static qint32 storageSize()
static fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
QSharedPointer< FiffTag > SPtr
Eigen::MatrixXf toFloatMatrix() const
const qint32 * toJulian() const
FiffTag(FiffTag &&other)=default
std::unique_ptr< FiffTag > UPtr
FiffCoordTrans toCoordTrans() const
std::unique_ptr< const FiffTag > ConstUPtr
const quint8 * toByte() const
fiff_int_t getMatrixCoding() const
Eigen::SparseMatrix< double > toSparseFloatMatrix() const
Eigen::MatrixXi toIntMatrix() const
const quint16 * toUnsignedShort() const
FiffChInfo toChInfo() const
FiffDigPoint toDigPoint() const
const double * toDouble() const
const qint16 * toDauPack16() const
const float * toFloat() const
const qint16 * toShort() const
static void convert_tag_data(const FiffTag::UPtr &tag, int from_endian, int to_endian)
static void convert_matrix_to_file_data(const FiffTag::UPtr &tag)
FiffTag & operator=(FiffTag &&other)=default
fiff_int_t getType() const
static qint32 storageSize()
const quint32 * toUnsignedInt() const
FiffTag & operator=(const FiffTag &other)=default
static void convert_matrix_from_file_data(const FiffTag::UPtr &tag)
const qint32 * toInt() const
static void convert_ch_pos(FiffChPos *pos)
FiffTag(const FiffTag &p_FiffTag)=default
QSharedPointer< const FiffTag > ConstSPtr
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const
QList< QSharedPointer< FiffDirEntry > > toDirEntry() const