v2.0.0
Loading...
Searching...
No Matches
fiff_tag.cpp
Go to the documentation of this file.
1//=============================================================================================================
20
21//=============================================================================================================
22// INCLUDES
23//=============================================================================================================
24
25#include "fiff_tag.h"
26#include "fiff_byte_swap.h"
27#include "fiff_sparse_matrix.h"
28
29#include <algorithm>
30#include <complex>
31
32//=============================================================================================================
33// QT INCLUDES
34//=============================================================================================================
35
36#include <QTcpSocket>
37#include <QDebug>
38
39//=============================================================================================================
40// USED NAMESPACES
41//=============================================================================================================
42
43using namespace FIFFLIB;
44
45//=============================================================================================================
46// DEFINE MEMBER METHODS
47//=============================================================================================================
48
50: kind(0)
51, type(0)
52, next(0)
53//, m_pComplexFloatData(NULL)
54//, m_pComplexDoubleData(NULL)
55{
56}
57
58//=============================================================================================================
59
61{
62 return IS_MATRIX & this->type;
63}
64
65//=============================================================================================================
66
68{
69 if (this->getMatrixCoding() != 0)
70 return true;
71 else
72 return false;
73}
74
75//=============================================================================================================
76
77bool FiffTag::getMatrixDimensions(qint32& p_ndim, QVector<qint32>& p_Dims) const
78{
79 p_Dims.clear();
80 p_ndim = 0;
81 if (!this->isMatrix() || this->data() == nullptr || this->size() < 4)
82 return false;
83
84 //
85 // The dimensions trail the data: [nz,] dims..., ndim. A corrupt file must not make the readers
86 // index outside the tag, so the trailer has to fit and a dense matrix has to fit before it.
87 //
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];
91 const int coding = fiff_type_matrix_coding(this->type);
92 const bool sparse = coding == FIFFTS_MC_CCS || coding == FIFFTS_MC_RCS;
93 if (coding != FIFFTS_MC_DENSE && !sparse) {
94 qWarning("Cannot handle other than dense or sparse matrices yet.");
95 return false;
96 }
97 const qint32 nTrailer = ndim + (sparse ? 2 : 1);
98 if (ndim <= 0 || ndim > FIFFC_MATRIX_MAX_DIM || nTrailer > nInts)
99 return false;
100
101 QVector<qint32> dims;
102 qint64 nValues = 1;
103 for (qsizetype i = nInts - nTrailer; i < nInts - 1; ++i) {
104 if (t_pInt32[i] < 0)
105 return false;
106 dims.append(t_pInt32[i]);
107 nValues = std::min<qint64>(nValues * t_pInt32[i], this->size()); // capped: enough to compare, no overflow
108 }
109 if (!sparse) {
110 const int base = this->getType();
111 const qint64 valueSize = (base == FIFFT_DOUBLE || base == FIFFT_COMPLEX_FLOAT) ? 8 : (base == FIFFT_COMPLEX_DOUBLE ? 16 : 4);
112 if (nValues * valueSize > static_cast<qint64>(nInts - nTrailer) * 4)
113 return false;
114 }
115
116 p_ndim = ndim;
117 p_Dims = dims;
118 return true;
119}
120
121//=============================================================================================================
122
124{
125 if (this->isMatrix()) {
126 return DATA_TYPE & this->type;
127 } else {
128 return this->type;
129 }
130}
131
132//=============================================================================================================
133
134Eigen::SparseMatrix<double> FiffTag::toSparseFloatMatrix() const
135{
136 const FiffTag::UPtr copy = std::make_unique<FiffTag>(*this);
138 return mat ? Eigen::SparseMatrix<double>(mat->eigen().cast<double>()) : Eigen::SparseMatrix<double>();
139}
140
141//=============================================================================================================
142
143QString FiffTag::getInfo() const
144{
145 QString t_qStringInfo;
146
147 if (this->isMatrix()) {
148 switch (this->getType()) {
149 case FIFFT_INT:
150 t_qStringInfo = "Matrix of type FIFFT_INT";
151 break;
152 case FIFFT_JULIAN:
153 t_qStringInfo = "Matrix of type FIFFT_JULIAN";
154 break;
155 case FIFFT_FLOAT:
156 t_qStringInfo = "Matrix of type FIFFT_FLOAT";
157 break;
158 case FIFFT_DOUBLE:
159 t_qStringInfo = "Matrix of type FIFFT_DOUBLE";
160 break;
162 t_qStringInfo = "Matrix of type FIFFT_COMPLEX_FLOAT";
163 break;
165 t_qStringInfo = "Matrix of type FIFFT_COMPLEX_DOUBLE";
166 break;
167 default:
168 t_qStringInfo = "Matrix of unknown type";
169 }
170 } else {
171 switch (this->getType()) {
172 //
173 // Simple types
174 //
175 case FIFFT_BYTE:
176 t_qStringInfo = "Simple type FIFFT_BYTE";
177 break;
178 case FIFFT_SHORT:
179 t_qStringInfo = "Simple type FIFFT_SHORT";
180 break;
181 case FIFFT_INT:
182 t_qStringInfo = "Simple type FIFFT_INT";
183 break;
184 case FIFFT_USHORT:
185 t_qStringInfo = "Simple type FIFFT_USHORT";
186 break;
187 case FIFFT_UINT:
188 t_qStringInfo = "Simple type FIFFT_UINT";
189 break;
190 case FIFFT_JULIAN:
191 t_qStringInfo = "Simple type FIFFT_JULIAN";
192 break;
193 case FIFFT_FLOAT:
194 t_qStringInfo = "Simple type FIFFT_FLOAT";
195 break;
196 case FIFFT_DOUBLE:
197 t_qStringInfo = "Simple type FIFFT_DOUBLE";
198 break;
199 case FIFFT_STRING:
200 t_qStringInfo = "Simple type FIFFT_STRING";
201 break;
202 case FIFFT_DAU_PACK16:
203 t_qStringInfo = "Simple type FIFFT_DAU_PACK16";
204 break;
206 t_qStringInfo = "Simple type FIFFT_COMPLEX_FLOAT";
207 break;
209 t_qStringInfo = "Simple type FIFFT_COMPLEX_DOUBLE";
210 break;
211 //
212 // Structures
213 //
214 case FIFFT_ID_STRUCT:
215 t_qStringInfo = "Structure FIFFT_ID_STRUCT";
216 break;
218 t_qStringInfo = "Structure FIFFT_DIG_POINT_STRUCT";
219 break;
221 t_qStringInfo = "Structure FIFFT_COORD_TRANS_STRUCT";
222 break;
224 t_qStringInfo = "Structure FIFFT_CH_INFO_STRUCT";
225 break;
226 case FIFFT_OLD_PACK:
227 t_qStringInfo = "Structure FIFFT_OLD_PACK";
228 break;
230 t_qStringInfo = "Structure FIFFT_DIR_ENTRY_STRUCT";
231 break;
232 default:
233 t_qStringInfo = "Structure unknown";
234 }
235 }
236 return t_qStringInfo;
237}
238
239//=============================================================================================================
240
241/*---------------------------------------------------------------------------
242 *
243 * Motorola like Architectures
244 *
245 * Fif file bit and byte orderings are defined to be as in HP-UX.
246 *
247 *--------------------------------------------------------------------------*/
248
249//#ifdef BIG_ENDIAN_ARCH
250
251//void FiffTag::fiff_convert_tag_info(FiffTag*& tag)
252//{
253// return;
254//}
255
256//#endif
257
258//#ifdef INTEL_X86_ARCH
260// */
261
262//void FiffTag::fiff_convert_tag_info(FiffTag*& tag)
263
264//{
265// tag->kind = swap_int(tag->kind);
266// tag->type = swap_int(tag->type);
267// tag->size = swap_int(tag->size);
268// tag->next = swap_int(tag->next);
269// return;
270//}
271
272//#endif /* INTEL_X86_ARCH */
273
274//=============================================================================================================
275
277{
278 int k;
279 pos->coil_type = swap_int(pos->coil_type);
280 for (k = 0; k < 3; k++) {
281 swap_floatp(&pos->r0[k]);
282 swap_floatp(&pos->ex[k]);
283 swap_floatp(&pos->ey[k]);
284 swap_floatp(&pos->ez[k]);
285 }
286 return;
287}
288
289//=============================================================================================================
290
292/*
293 * Assumes that the input is in the non-native byte order and needs to be swapped to the other one
294 */
295{
296 int ndim;
297 int k;
298 int *dimp, *data, kind, np, nz;
299 float* fdata;
300 double* ddata;
301 unsigned int tsize = tag->size();
302
303 if (fiff_type_fundamental(tag->type) != FIFFTS_FS_MATRIX)
304 return;
305 if (tag->data() == nullptr)
306 return;
307 if (tsize < sizeof(fiff_int_t))
308 return;
309
310 dimp = (reinterpret_cast<fiff_int_t*>((tag->data()) + tag->size() - sizeof(fiff_int_t)));
311 swap_intp(dimp);
312 ndim = *dimp;
313 if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_DENSE) {
314 if (tsize < (ndim + 1) * sizeof(fiff_int_t))
315 return;
316 dimp = dimp - ndim;
317 for (k = 0, np = 1; k < ndim; k++) {
318 swap_intp(dimp + k);
319 np = np * dimp[k];
320 }
321 } else {
322 if (tsize < (ndim + 2) * sizeof(fiff_int_t))
323 return;
324 if (ndim > 2) /* Not quite sure what to do */
325 return;
326 dimp = dimp - ndim - 1;
327 for (k = 0; k < ndim + 1; k++)
328 swap_intp(dimp + k);
329 nz = dimp[0];
330 if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_CCS)
331 np = nz + dimp[2] + 1; /* nz + n + 1 */
332 else if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_RCS)
333 np = nz + dimp[1] + 1; /* nz + m + 1 */
334 else
335 return; /* Don't know what to do */
336 /*
337 * Take care of the indices
338 */
339 for (data = reinterpret_cast<int*>(tag->data()) + nz, k = 0; k < np; k++)
340 swap_intp(data + k);
341 np = nz;
342 }
343 /*
344 * Now convert data...
345 */
346 kind = fiff_type_base(tag->type);
347 if (kind == FIFFT_INT) {
348 for (data = reinterpret_cast<int*>(tag->data()), k = 0; k < np; k++)
349 swap_intp(data + k);
350 } else if (kind == FIFFT_FLOAT) {
351 for (fdata = reinterpret_cast<float*>(tag->data()), k = 0; k < np; k++)
352 swap_floatp(fdata + k);
353 } else if (kind == FIFFT_DOUBLE) {
354 for (ddata = reinterpret_cast<double*>(tag->data()), k = 0; k < np; k++)
355 swap_doublep(ddata + k);
356 } else if (kind == FIFFT_COMPLEX_FLOAT) {
357 for (fdata = reinterpret_cast<float*>(tag->data()), k = 0; k < 2 * np; k++)
358 swap_floatp(fdata + k);
359 } else if (kind == FIFFT_COMPLEX_DOUBLE) {
360 for (ddata = reinterpret_cast<double*>(tag->data()), k = 0; k < 2 * np; k++)
361 swap_doublep(ddata + k);
362 }
363 return;
364}
365
366//=============================================================================================================
367
369/*
370 * Assumes that the input is in the NATIVE_ENDIAN byte order and needs to be swapped to the other one
371 */
372{
373 int ndim;
374 int k;
375 int *dimp, *data, kind, np;
376 float* fdata;
377 double* ddata;
378 unsigned int tsize = tag->size();
379
380 if (fiff_type_fundamental(tag->type) != FIFFTS_FS_MATRIX)
381 return;
382 if (tag->data() == nullptr)
383 return;
384 if (tsize < sizeof(fiff_int_t))
385 return;
386
387 dimp = (reinterpret_cast<fiff_int_t*>((tag->data()) + tag->size() - sizeof(fiff_int_t)));
388 ndim = *dimp;
389 swap_intp(dimp);
390
391 if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_DENSE) {
392 if (tsize < (ndim + 1) * sizeof(fiff_int_t))
393 return;
394 dimp = dimp - ndim;
395 for (k = 0, np = 1; k < ndim; k++) {
396 np = np * dimp[k];
397 swap_intp(dimp + k);
398 }
399 } else {
400 if (tsize < (ndim + 2) * sizeof(fiff_int_t))
401 return;
402 if (ndim > 2) /* Not quite sure what to do */
403 return;
404 dimp = dimp - ndim - 1;
405 const int nz = dimp[0];
406 if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_CCS)
407 np = nz + dimp[2] + 1; /* nz + n + 1 */
408 else if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_RCS)
409 np = nz + dimp[1] + 1; /* nz + m + 1 */
410 else
411 return; /* Don't know what to do */
412 for (k = 0; k < ndim + 1; k++)
413 swap_intp(dimp + k);
414 for (data = reinterpret_cast<int*>(tag->data()) + nz, k = 0; k < np; k++)
415 swap_intp(data + k);
416 np = nz;
417 }
418 /*
419 * Now convert data...
420 */
421 kind = fiff_type_base(tag->type);
422 if (kind == FIFFT_INT) {
423 for (data = reinterpret_cast<int*>(tag->data()), k = 0; k < np; k++)
424 swap_intp(data + k);
425 } else if (kind == FIFFT_FLOAT) {
426 for (fdata = reinterpret_cast<float*>(tag->data()), k = 0; k < np; k++)
427 swap_floatp(fdata + k);
428 } else if (kind == FIFFT_DOUBLE) {
429 for (ddata = reinterpret_cast<double*>(tag->data()), k = 0; k < np; k++)
430 swap_doublep(ddata + k);
431 } else if (kind == FIFFT_COMPLEX_FLOAT) {
432 for (fdata = reinterpret_cast<float*>(tag->data()), k = 0; k < 2 * np; k++)
433 swap_floatp(fdata + k);
434 } else if (kind == FIFFT_COMPLEX_DOUBLE) {
435 for (ddata = reinterpret_cast<double*>(tag->data()), k = 0; k < 2 * np; k++)
436 swap_doublep(ddata + k);
437 }
438 return;
439}
440
441//=============================================================================================================
442//ToDo remove this function by swapping -> define little endian big endian, QByteArray
443void FiffTag::convert_tag_data(const FiffTag::UPtr& tag, int from_endian, int to_endian)
444{
445 // Element counts derived from tag->size(), which is a size type. A FIFF tag
446 // never holds more than INT_MAX elements, so narrowing is safe, but it has
447 // to be explicit: on Win64 size_t is 64-bit while int stays 32-bit.
448 int np;
449 int k, r; //,c;
450 char* offset;
451 fiff_int_t* ithis;
452 fiff_short_t* sthis;
453 fiff_long_t* lthis;
454 float* fthis;
455 double* dthis;
456 // fiffDirEntry dethis;
457 // fiffId idthis;
458 // fiffChInfoRec* chthis;//FiffChInfo* chthis;//ToDo adapt parsing to the new class
459 // fiffChPos cpthis;
460 // fiffCoordTrans ctthis;
461 // fiffDigPoint dpthis;
462 fiffDataRef drthis;
463
464 if (tag->data() == nullptr || tag->size() == 0)
465 return;
466
467 if (from_endian == FIFFV_NATIVE_ENDIAN)
468 from_endian = NATIVE_ENDIAN;
469 if (to_endian == FIFFV_NATIVE_ENDIAN)
470 to_endian = NATIVE_ENDIAN;
471
472 if (from_endian == to_endian)
473 return;
474
475 if (fiff_type_fundamental(tag->type) == FIFFTS_FS_MATRIX) {
476 if (from_endian == NATIVE_ENDIAN)
478 else
480 return;
481 }
482
483 switch (tag->type) {
484 case FIFFT_INT:
485 case FIFFT_UINT:
486 case FIFFT_JULIAN:
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++)
489 swap_intp(ithis);
490 break;
491
492 case FIFFT_LONG:
493 case FIFFT_ULONG:
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++)
496 swap_longp(lthis);
497 break;
498
499 case FIFFT_SHORT:
500 case FIFFT_DAU_PACK16:
501 case FIFFT_USHORT:
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++)
504 *sthis = swap_short(*sthis);
505 break;
506
507 case FIFFT_FLOAT:
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++)
511 swap_floatp(fthis);
512 break;
513
514 case FIFFT_DOUBLE:
516 np = static_cast<int>(tag->size() / sizeof(fiff_double_t));
517 for (dthis = reinterpret_cast<fiff_double_t*>(tag->data()), k = 0; k < np; k++, dthis++)
518 swap_doublep(dthis);
519 break;
520
521 case FIFFT_OLD_PACK:
522 fthis = reinterpret_cast<float*>(tag->data());
523 /*
524 * Offset and scale...
525 */
526 swap_floatp(fthis + 0);
527 swap_floatp(fthis + 1);
528 sthis = reinterpret_cast<short*>(fthis + 2);
529 np = (tag->size() - 2 * sizeof(float)) / sizeof(short);
530 for (k = 0; k < np; k++, sthis++)
531 *sthis = swap_short(*sthis);
532 break;
533
535 // np = tag->size/sizeof(fiffDirEntryRec);
536 // for (dethis = (fiffDirEntry)tag->data->data(), k = 0; k < np; k++, dethis++) {
537 // dethis->kind = swap_int(dethis->kind);
538 // dethis->type = swap_int(dethis->type);
539 // dethis->size = swap_int(dethis->size);
540 // dethis->pos = swap_int(dethis->pos);
541 // }
542 np = tag->size() / FiffDirEntry::storageSize();
543 for (k = 0; k < np; k++) {
544 offset = static_cast<char*>(tag->data()) + k * FiffDirEntry::storageSize();
545 ithis = reinterpret_cast<fiff_int_t*>(offset);
546 ithis[0] = swap_int(ithis[0]); //kind
547 ithis[1] = swap_int(ithis[1]); //type
548 ithis[2] = swap_int(ithis[2]); //size
549 ithis[3] = swap_int(ithis[3]); //pos
550 }
551 break;
552
553 case FIFFT_ID_STRUCT:
554 // np = tag->size/sizeof(fiffIdRec);
555 // for (idthis = (fiffId)tag->data->data(), k = 0; k < np; k++, idthis++) {
556 // idthis->version = swap_int(idthis->version);
557 // idthis->machid[0] = swap_int(idthis->machid[0]);
558 // idthis->machid[1] = swap_int(idthis->machid[1]);
559 // idthis->time.secs = swap_int(idthis->time.secs);
560 // idthis->time.usecs = swap_int(idthis->time.usecs);
561 // }
562 np = tag->size() / FiffId::storageSize();
563 for (k = 0; k < np; k++) {
564 offset = static_cast<char*>(tag->data()) + k * FiffId::storageSize();
565 ithis = reinterpret_cast<fiff_int_t*>(offset);
566 ithis[0] = swap_int(ithis[0]); //version
567 ithis[1] = swap_int(ithis[1]); //machid[0]
568 ithis[2] = swap_int(ithis[2]); //machid[1]
569 ithis[3] = swap_int(ithis[3]); //time.secs
570 ithis[4] = swap_int(ithis[4]); //time.usecs
571 }
572 break;
573
575 // np = tag->size/sizeof(fiffChInfoRec);
576 // for (chthis = (fiffChInfoRec*)tag->data->data(), k = 0; k < np; k++, chthis++) {
577 // chthis->scanNo = swap_int(chthis->scanNo);
578 // chthis->logNo = swap_int(chthis->logNo);
579 // chthis->kind = swap_int(chthis->kind);
580 // swap_floatp(&chthis->range);
581 // swap_floatp(&chthis->cal);
582 // chthis->unit = swap_int(chthis->unit);
583 // chthis->unit_mul = swap_int(chthis->unit_mul);
584 // convert_ch_pos(&(chthis->chpos));
585 // }
586
587 np = tag->size() / FiffChInfo::storageSize();
588 for (k = 0; k < np; k++) {
589 offset = static_cast<char*>(tag->data()) + k * FiffChInfo::storageSize();
590 ithis = reinterpret_cast<fiff_int_t*>(offset);
591 fthis = reinterpret_cast<float*>(offset);
592
593 ithis[0] = swap_int(ithis[0]); //scanno
594 ithis[1] = swap_int(ithis[1]); //logno
595 ithis[2] = swap_int(ithis[2]); //kind
596 swap_floatp(&fthis[3]); //range
597 swap_floatp(&fthis[4]); //cal
598 ithis[5] = swap_int(ithis[5]); //coil_type
599 for (r = 0; r < 12; ++r)
600 swap_floatp(&fthis[6 + r]); //loc
601 ithis[18] = swap_int(ithis[18]); //unit
602 ithis[19] = swap_int(ithis[19]); //unit_mul
603 }
604
605 break;
606
608 // np = tag->size/sizeof(fiffChPosRec);
609 // for (cpthis = (fiffChPos)tag->data->data(), k = 0; k < np; k++, cpthis++)
610 // convert_ch_pos(cpthis);
611
612 np = tag->size() / FiffChPos::storageSize();
613 for (k = 0; k < np; ++k) {
614 offset = static_cast<char*>(tag->data()) + k * FiffChPos::storageSize();
615 ithis = reinterpret_cast<fiff_int_t*>(offset);
616 fthis = reinterpret_cast<float*>(offset);
617
618 ithis[0] = swap_int(ithis[0]); //coil_type
619 for (r = 0; r < 12; r++)
620 swap_floatp(&fthis[1 + r]); //r0, ex, ey, ez
621 }
622
623 break;
624
626 // np = tag->size/sizeof(fiffDigPointRec);
627 // for (dpthis = (fiffDigPoint)tag->data->data(), k = 0; k < np; k++, dpthis++) {
628 // dpthis->kind = swap_int(dpthis->kind);
629 // dpthis->ident = swap_int(dpthis->ident);
630 // for (r = 0; r < 3; r++)
631 // swap_floatp(&dpthis->r[r]);
632 // }
633
634 np = tag->size() / FiffDigPoint::storageSize();
635
636 for (k = 0; k < np; k++) {
637 offset = tag->data() + k * FiffDigPoint::storageSize();
638 ithis = reinterpret_cast<fiff_int_t*>(offset);
639 fthis = reinterpret_cast<float*>(offset);
640
641 ithis[0] = swap_int(ithis[0]); //kind
642 ithis[1] = swap_int(ithis[1]); //ident
643
644 for (r = 0; r < 3; ++r)
645 swap_floatp(&fthis[2 + r]); //r
646 }
647 break;
648
650 // np = tag->size/sizeof(fiffCoordTransRec);
651 // for (ctthis = (fiffCoordTrans)tag->data->data(), k = 0; k < np; k++, ctthis++) {
652 // ctthis->from = swap_int(ctthis->from);
653 // ctthis->to = swap_int(ctthis->to);
654 // for (r = 0; r < 3; r++) {
655 // swap_floatp(&ctthis->move[r]);
656 // swap_floatp(&ctthis->invmove[r]);
657 // for (c = 0; c < 3; c++) {
658 // swap_floatp(&ctthis->rot[r][c]);
659 // swap_floatp(&ctthis->invrot[r][c]);
660 // }
661 // }
662 // }
663
664 np = tag->size() / FiffCoordTrans::storageSize();
665
666 for (k = 0; k < np; ++k) {
667 offset = tag->data() + k * FiffCoordTrans::storageSize();
668 ithis = reinterpret_cast<fiff_int_t*>(offset);
669 fthis = reinterpret_cast<float*>(offset);
670
671 ithis[0] = swap_int(ithis[0]);
672 ithis[1] = swap_int(ithis[1]);
673
674 for (r = 0; r < 24; ++r)
675 swap_floatp(&fthis[2 + r]);
676 }
677 break;
678
680 np = tag->size() / FiffDataRef::storageSize();
681 for (drthis = reinterpret_cast<fiffDataRef>(tag->data()), k = 0; k < np; k++, drthis++) {
682 drthis->type = swap_int(drthis->type);
683 drthis->endian = swap_int(drthis->endian);
684 drthis->size = swap_long(drthis->size);
685 drthis->offset = swap_long(drthis->offset);
686 }
687 break;
688
689 default:
690 break;
691 }
692 return;
693}
694
695//=============================================================================================================
696//fiff_type_spec
697
702
703//=============================================================================================================
704
709
710//=============================================================================================================
711
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.
#define NATIVE_ENDIAN
Definition fiff_tag.h:68
constexpr auto FIFFT_LONG
Definition fiff_file.h:231
constexpr auto FIFFT_ULONG
Definition fiff_file.h:228
constexpr auto FIFFTS_MC_DENSE
Definition fiff_file.h:259
constexpr auto FIFFT_JULIAN
Definition fiff_file.h:225
constexpr auto FIFFV_NATIVE_ENDIAN
Definition fiff_file.h:888
constexpr auto FIFFT_CH_INFO_STRUCT
Definition fiff_file.h:238
constexpr auto FIFFT_DIG_POINT_STRUCT
Definition fiff_file.h:241
constexpr auto FIFFTS_MC_RCS
Definition fiff_file.h:261
constexpr auto FIFFTS_FS_MATRIX
Definition fiff_file.h:257
constexpr auto FIFFT_CH_POS_STRUCT
Definition fiff_file.h:242
constexpr auto FIFFT_COMPLEX_DOUBLE
Definition fiff_file.h:236
constexpr auto FIFFT_BYTE
Definition fiff_file.h:220
constexpr auto FIFFT_COMPLEX_FLOAT
Definition fiff_file.h:235
constexpr auto FIFFT_UINT
Definition fiff_file.h:227
constexpr auto FIFFT_ID_STRUCT
Definition fiff_file.h:239
constexpr auto FIFFT_COORD_TRANS_STRUCT
Definition fiff_file.h:243
constexpr auto FIFFTS_MC_MASK
Definition fiff_file.h:254
constexpr auto FIFFT_DOUBLE
Definition fiff_file.h:224
constexpr auto FIFFT_STRING
Definition fiff_file.h:229
constexpr auto FIFFT_DAU_PACK16
Definition fiff_file.h:234
constexpr auto FIFFTS_MC_CCS
Definition fiff_file.h:260
constexpr auto FIFFT_DATA_REF_STRUCT
Definition fiff_file.h:246
constexpr auto FIFFC_MATRIX_MAX_DIM
Definition fiff_file.h:250
constexpr auto FIFFT_USHORT
Definition fiff_file.h:226
constexpr auto FIFFT_SHORT
Definition fiff_file.h:221
constexpr auto FIFFT_FLOAT
Definition fiff_file.h:223
constexpr auto FIFFT_DIR_ENTRY_STRUCT
Definition fiff_file.h:240
constexpr auto FIFFTS_FS_MASK
Definition fiff_file.h:252
constexpr auto FIFFT_INT
Definition fiff_file.h:222
constexpr auto FIFFT_OLD_PACK
Definition fiff_file.h:237
constexpr auto FIFFTS_BASE_MASK
Definition fiff_file.h:253
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)
double fiff_double_t
Definition fiff_types.h:91
qint32 swap_int(qint32 source)
qint32 fiff_int_t
Definition fiff_types.h:86
void swap_longp(qint64 *source)
constexpr auto DATA_TYPE
Definition fiff_tag.h:137
float fiff_float_t
Definition fiff_types.h:90
qint64 fiff_long_t
Definition fiff_types.h:88
qint64 swap_long(qint64 source)
void swap_floatp(float *source)
constexpr auto IS_MATRIX
Definition fiff_tag.h:133
void swap_intp(qint32 *source)
qint16 swap_short(qint16 source)
qint16 fiff_short_t
Definition fiff_types.h:84
static qint32 storageSize()
Channel coil-frame placement: origin r0 (m) and orthonormal axes ex / ey / ez in FIFFV_COORD_DEVICE.
Definition fiff_ch_pos.h:65
Eigen::Vector3f r0
fiff_int_t coil_type
static qint32 storageSize()
Eigen::Vector3f ey
Eigen::Vector3f ex
Eigen::Vector3f ez
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
Definition fiff_id.h:208
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)
Definition fiff_tag.cpp:712
fiff_int_t kind
Definition fiff_tag.h:530
std::unique_ptr< FiffTag > UPtr
Definition fiff_tag.h:165
fiff_int_t getMatrixCoding() const
Definition fiff_tag.cpp:60
Eigen::SparseMatrix< double > toSparseFloatMatrix() const
Definition fiff_tag.cpp:134
static fiff_int_t fiff_type_fundamental(fiff_int_t type)
Definition fiff_tag.cpp:698
static void convert_tag_data(const FiffTag::UPtr &tag, int from_endian, int to_endian)
Definition fiff_tag.cpp:443
static void convert_matrix_to_file_data(const FiffTag::UPtr &tag)
Definition fiff_tag.cpp:368
QString getInfo() const
Definition fiff_tag.cpp:143
bool isMatrix() const
Definition fiff_tag.cpp:67
fiff_int_t getType() const
Definition fiff_tag.cpp:123
static fiff_int_t fiff_type_base(fiff_int_t type)
Definition fiff_tag.cpp:705
fiff_int_t type
Definition fiff_tag.h:532
static void convert_matrix_from_file_data(const FiffTag::UPtr &tag)
Definition fiff_tag.cpp:291
fiff_int_t next
Definition fiff_tag.h:534
static void convert_ch_pos(FiffChPos *pos)
Definition fiff_tag.cpp:276
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const
Definition fiff_tag.cpp:77