81 if (!this->
isMatrix() || this->data() ==
nullptr || this->size() < 4)
88 const qint32* t_pInt32 =
reinterpret_cast<const qint32*
>(this->data());
89 const qsizetype nInts = this->size() / 4;
90 const qint32 ndim = t_pInt32[nInts - 1];
94 qWarning(
"Cannot handle other than dense or sparse matrices yet.");
97 const qint32 nTrailer = ndim + (sparse ? 2 : 1);
101 QVector<qint32> dims;
103 for (qsizetype i = nInts - nTrailer; i < nInts - 1; ++i) {
106 dims.append(t_pInt32[i]);
107 nValues = std::min<qint64>(nValues * t_pInt32[i], this->size());
110 const int base = this->
getType();
112 if (nValues * valueSize >
static_cast<qint64
>(nInts - nTrailer) * 4)
138 return mat ? Eigen::SparseMatrix<double>(mat->eigen().cast<
double>()) : Eigen::SparseMatrix<double>();
145 QString t_qStringInfo;
150 t_qStringInfo =
"Matrix of type FIFFT_INT";
153 t_qStringInfo =
"Matrix of type FIFFT_JULIAN";
156 t_qStringInfo =
"Matrix of type FIFFT_FLOAT";
159 t_qStringInfo =
"Matrix of type FIFFT_DOUBLE";
162 t_qStringInfo =
"Matrix of type FIFFT_COMPLEX_FLOAT";
165 t_qStringInfo =
"Matrix of type FIFFT_COMPLEX_DOUBLE";
168 t_qStringInfo =
"Matrix of unknown type";
176 t_qStringInfo =
"Simple type FIFFT_BYTE";
179 t_qStringInfo =
"Simple type FIFFT_SHORT";
182 t_qStringInfo =
"Simple type FIFFT_INT";
185 t_qStringInfo =
"Simple type FIFFT_USHORT";
188 t_qStringInfo =
"Simple type FIFFT_UINT";
191 t_qStringInfo =
"Simple type FIFFT_JULIAN";
194 t_qStringInfo =
"Simple type FIFFT_FLOAT";
197 t_qStringInfo =
"Simple type FIFFT_DOUBLE";
200 t_qStringInfo =
"Simple type FIFFT_STRING";
203 t_qStringInfo =
"Simple type FIFFT_DAU_PACK16";
206 t_qStringInfo =
"Simple type FIFFT_COMPLEX_FLOAT";
209 t_qStringInfo =
"Simple type FIFFT_COMPLEX_DOUBLE";
215 t_qStringInfo =
"Structure FIFFT_ID_STRUCT";
218 t_qStringInfo =
"Structure FIFFT_DIG_POINT_STRUCT";
221 t_qStringInfo =
"Structure FIFFT_COORD_TRANS_STRUCT";
224 t_qStringInfo =
"Structure FIFFT_CH_INFO_STRUCT";
227 t_qStringInfo =
"Structure FIFFT_OLD_PACK";
230 t_qStringInfo =
"Structure FIFFT_DIR_ENTRY_STRUCT";
233 t_qStringInfo =
"Structure unknown";
236 return t_qStringInfo;
280 for (k = 0; k < 3; k++) {
298 int *dimp, *data,
kind, np, nz;
301 unsigned int tsize = tag->size();
305 if (tag->data() ==
nullptr)
317 for (k = 0, np = 1; k < ndim; k++) {
326 dimp = dimp - ndim - 1;
327 for (k = 0; k < ndim + 1; k++)
331 np = nz + dimp[2] + 1;
333 np = nz + dimp[1] + 1;
339 for (data =
reinterpret_cast<int*
>(tag->data()) + nz, k = 0; k < np; k++)
348 for (data =
reinterpret_cast<int*
>(tag->data()), k = 0; k < np; k++)
351 for (fdata =
reinterpret_cast<float*
>(tag->data()), k = 0; k < np; k++)
354 for (ddata =
reinterpret_cast<double*
>(tag->data()), k = 0; k < np; k++)
357 for (fdata =
reinterpret_cast<float*
>(tag->data()), k = 0; k < 2 * np; k++)
360 for (ddata =
reinterpret_cast<double*
>(tag->data()), k = 0; k < 2 * np; k++)
375 int *dimp, *data,
kind, np;
378 unsigned int tsize = tag->size();
382 if (tag->data() ==
nullptr)
395 for (k = 0, np = 1; k < ndim; k++) {
404 dimp = dimp - ndim - 1;
405 const int nz = dimp[0];
407 np = nz + dimp[2] + 1;
409 np = nz + dimp[1] + 1;
412 for (k = 0; k < ndim + 1; k++)
414 for (data =
reinterpret_cast<int*
>(tag->data()) + nz, k = 0; k < np; k++)
423 for (data =
reinterpret_cast<int*
>(tag->data()), k = 0; k < np; k++)
426 for (fdata =
reinterpret_cast<float*
>(tag->data()), k = 0; k < np; k++)
429 for (ddata =
reinterpret_cast<double*
>(tag->data()), k = 0; k < np; k++)
432 for (fdata =
reinterpret_cast<float*
>(tag->data()), k = 0; k < 2 * np; k++)
435 for (ddata =
reinterpret_cast<double*
>(tag->data()), k = 0; k < 2 * np; k++)
464 if (tag->data() ==
nullptr || tag->size() == 0)
472 if (from_endian == to_endian)
487 np =
static_cast<int>(tag->size() /
sizeof(
fiff_int_t));
488 for (ithis =
reinterpret_cast<fiff_int_t*
>(tag->data()), k = 0; k < np; k++, ithis++)
494 np =
static_cast<int>(tag->size() /
sizeof(
fiff_long_t));
495 for (lthis =
reinterpret_cast<fiff_long_t*
>(tag->data()), k = 0; k < np; k++, lthis++)
502 np =
static_cast<int>(tag->size() /
sizeof(
fiff_short_t));
503 for (sthis =
reinterpret_cast<fiff_short_t*
>(tag->data()), k = 0; k < np; k++, sthis++)
509 np =
static_cast<int>(tag->size() /
sizeof(
fiff_float_t));
510 for (fthis =
reinterpret_cast<fiff_float_t*
>(tag->data()), k = 0; k < np; k++, fthis++)
517 for (dthis =
reinterpret_cast<fiff_double_t*
>(tag->data()), k = 0; k < np; k++, dthis++)
522 fthis =
reinterpret_cast<float*
>(tag->data());
528 sthis =
reinterpret_cast<short*
>(fthis + 2);
529 np = (tag->size() - 2 *
sizeof(
float)) /
sizeof(short);
530 for (k = 0; k < np; k++, sthis++)
543 for (k = 0; k < np; k++) {
545 ithis =
reinterpret_cast<fiff_int_t*
>(offset);
563 for (k = 0; k < np; k++) {
565 ithis =
reinterpret_cast<fiff_int_t*
>(offset);
588 for (k = 0; k < np; k++) {
590 ithis =
reinterpret_cast<fiff_int_t*
>(offset);
591 fthis =
reinterpret_cast<float*
>(offset);
599 for (r = 0; r < 12; ++r)
613 for (k = 0; k < np; ++k) {
615 ithis =
reinterpret_cast<fiff_int_t*
>(offset);
616 fthis =
reinterpret_cast<float*
>(offset);
619 for (r = 0; r < 12; r++)
636 for (k = 0; k < np; k++) {
638 ithis =
reinterpret_cast<fiff_int_t*
>(offset);
639 fthis =
reinterpret_cast<float*
>(offset);
644 for (r = 0; r < 3; ++r)
666 for (k = 0; k < np; ++k) {
668 ithis =
reinterpret_cast<fiff_int_t*
>(offset);
669 fthis =
reinterpret_cast<float*
>(offset);
674 for (r = 0; r < 24; ++r)
681 for (drthis =
reinterpret_cast<fiffDataRef>(tag->data()), k = 0; k < np; k++, drthis++) {
Endianness swap helpers for the FIFF binary tag I/O layer (FIFF is always written big-endian on disk)...
FIFF tag: the 16-byte tag header (kind, type, size, next) plus its decoded payload.
constexpr auto FIFFT_LONG
constexpr auto FIFFT_ULONG
constexpr auto FIFFTS_MC_DENSE
constexpr auto FIFFT_JULIAN
constexpr auto FIFFV_NATIVE_ENDIAN
constexpr auto FIFFT_CH_INFO_STRUCT
constexpr auto FIFFT_DIG_POINT_STRUCT
constexpr auto FIFFTS_MC_RCS
constexpr auto FIFFTS_FS_MATRIX
constexpr auto FIFFT_CH_POS_STRUCT
constexpr auto FIFFT_COMPLEX_DOUBLE
constexpr auto FIFFT_BYTE
constexpr auto FIFFT_COMPLEX_FLOAT
constexpr auto FIFFT_UINT
constexpr auto FIFFT_ID_STRUCT
constexpr auto FIFFT_COORD_TRANS_STRUCT
constexpr auto FIFFTS_MC_MASK
constexpr auto FIFFT_DOUBLE
constexpr auto FIFFT_STRING
constexpr auto FIFFT_DAU_PACK16
constexpr auto FIFFTS_MC_CCS
constexpr auto FIFFT_DATA_REF_STRUCT
constexpr auto FIFFC_MATRIX_MAX_DIM
constexpr auto FIFFT_USHORT
constexpr auto FIFFT_SHORT
constexpr auto FIFFT_FLOAT
constexpr auto FIFFT_DIR_ENTRY_STRUCT
constexpr auto FIFFTS_FS_MASK
constexpr auto FIFFT_OLD_PACK
constexpr auto FIFFTS_BASE_MASK
FIFF sparse matrix: column / row-compressed sparse storage backed by Eigen::SparseMatrix.
FIFF file I/O, in-memory data structures and high-level readers/writers.
FiffDataRef * fiffDataRef
Backward-compatible pointer typedef for the old fiffDataRef pointer.
void swap_doublep(double *source)
qint32 swap_int(qint32 source)
void swap_longp(qint64 *source)
qint64 swap_long(qint64 source)
void swap_floatp(float *source)
void swap_intp(qint32 *source)
qint16 swap_short(qint16 source)
static qint32 storageSize()
Channel coil-frame placement: origin r0 (m) and orthonormal axes ex / ey / ez in FIFFV_COORD_DEVICE.
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
static FiffSparseMatrix::UPtr fiff_get_float_sparse_matrix(const FIFFLIB::FiffTag::UPtr &tag)
std::unique_ptr< FiffSparseMatrix > UPtr
static fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
std::unique_ptr< FiffTag > UPtr
fiff_int_t getMatrixCoding() const
Eigen::SparseMatrix< double > toSparseFloatMatrix() const
static fiff_int_t fiff_type_fundamental(fiff_int_t type)
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)
fiff_int_t getType() const
static fiff_int_t fiff_type_base(fiff_int_t type)
static void convert_matrix_from_file_data(const FiffTag::UPtr &tag)
static void convert_ch_pos(FiffChPos *pos)
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const