57 using namespace UTILSLIB;
58 using namespace FIFFLIB;
76 : QByteArray( p_pFiffTag->data(), p_pFiffTag->size())
77 , kind(p_pFiffTag->kind)
78 , type(p_pFiffTag->type)
79 , next(p_pFiffTag->next)
124 if(!this->
isMatrix() || this->data() == NULL)
133 qint32* t_pInt32 = (qint32*)this->data();
135 p_ndim = t_pInt32[(this->size()-4)/4];
138 for(
int i = p_ndim+1; i > 1; --i)
139 p_Dims.append(t_pInt32[(this->size()-(i*4))/4]);
141 for(
int i = p_ndim+2; i > 1; --i)
142 p_Dims.append(t_pInt32[(this->size()-(i*4))/4]);
145 printf(
"Error: Cannot handle other than dense or sparse matrices yet.\n");
170 QString t_qStringInfo;
177 t_qStringInfo =
"Matrix of type FIFFT_INT";
180 t_qStringInfo =
"Matrix of type FIFFT_JULIAN";
183 t_qStringInfo =
"Matrix of type FIFFT_FLOAT";
186 t_qStringInfo =
"Matrix of type FIFFT_DOUBLE";
188 case FIFFT_COMPLEX_FLOAT:
189 t_qStringInfo =
"Matrix of type FIFFT_COMPLEX_FLOAT";
191 case FIFFT_COMPLEX_DOUBLE:
192 t_qStringInfo =
"Matrix of type FIFFT_COMPLEX_DOUBLE";
195 t_qStringInfo =
"Matrix of unknown type";
206 t_qStringInfo =
"Simple type FIFFT_BYTE";
209 t_qStringInfo =
"Simple type FIFFT_SHORT";
212 t_qStringInfo =
"Simple type FIFFT_INT";
215 t_qStringInfo =
"Simple type FIFFT_USHORT";
218 t_qStringInfo =
"Simple type FIFFT_UINT";
221 t_qStringInfo =
"Simple type FIFFT_FLOAT";
224 t_qStringInfo =
"Simple type FIFFT_DOUBLE";
227 t_qStringInfo =
"Simple type FIFFT_STRING";
229 case FIFFT_DAU_PACK16:
230 t_qStringInfo =
"Simple type FIFFT_DAU_PACK16";
232 case FIFFT_COMPLEX_FLOAT:
233 t_qStringInfo =
"Simple type FIFFT_COMPLEX_FLOAT";
235 case FIFFT_COMPLEX_DOUBLE:
236 t_qStringInfo =
"Simple type FIFFT_COMPLEX_DOUBLE";
241 case FIFFT_ID_STRUCT:
242 t_qStringInfo =
"Structure FIFFT_ID_STRUCT";
244 case FIFFT_DIG_POINT_STRUCT:
245 t_qStringInfo =
"Structure FIFFT_DIG_POINT_STRUCT";
247 case FIFFT_COORD_TRANS_STRUCT:
248 t_qStringInfo =
"Structure FIFFT_COORD_TRANS_STRUCT";
250 case FIFFT_CH_INFO_STRUCT:
251 t_qStringInfo =
"Structure FIFFT_CH_INFO_STRUCT";
254 t_qStringInfo =
"Structure FIFFT_OLD_PACK";
256 case FIFFT_DIR_ENTRY_STRUCT:
257 t_qStringInfo =
"Structure FIFFT_DIR_ENTRY_STRUCT";
260 t_qStringInfo =
"Structure unknown";
263 return t_qStringInfo;
307 for (
k = 0;
k < 3;
k++) {
308 IOUtils::swap_floatp(&pos->
r0[
k]);
309 IOUtils::swap_floatp(&pos->
ex[
k]);
310 IOUtils::swap_floatp(&pos->
ey[
k]);
311 IOUtils::swap_floatp(&pos->
ez[
k]);
325 int *dimp,*data,
kind,np,nz;
328 unsigned int tsize = tag->size();
332 if (tag->data() == NULL)
334 if (tsize <
sizeof(fiff_int_t))
337 dimp = ((fiff_int_t *)((tag->data())+tag->size()-
sizeof(fiff_int_t)));
338 IOUtils::swap_intp(dimp);
341 if (tsize < (ndim+1)*
sizeof(fiff_int_t))
344 for (
k = 0, np = 1;
k < ndim;
k++) {
345 IOUtils::swap_intp(dimp+
k);
350 if (tsize < (ndim+2)*
sizeof(fiff_int_t))
354 dimp = dimp - ndim - 1;
355 for (
k = 0;
k < ndim+1;
k++)
356 IOUtils::swap_intp(dimp+
k);
359 np = nz + dimp[2] + 1;
361 np = nz + dimp[1] + 1;
367 for (data = (
int *)(tag->data())+nz,
k = 0;
k < np;
k++)
368 IOUtils::swap_intp(data+
k);
375 if (
kind == FIFFT_INT) {
376 for (data = (
int *)(tag->data()),
k = 0;
k < np;
k++)
377 IOUtils::swap_intp(data+
k);
379 else if (
kind == FIFFT_FLOAT) {
380 for (fdata = (
float *)(tag->data()),
k = 0;
k < np;
k++)
381 IOUtils::swap_floatp(fdata+
k);
383 else if (
kind == FIFFT_DOUBLE) {
384 for (ddata = (
double *)(tag->data()),
k = 0;
k < np;
k++)
385 IOUtils::swap_doublep(ddata+
k);
399 int *dimp,*data,
kind,np;
402 unsigned int tsize = tag->size();
406 if (tag->data() == NULL)
408 if (tsize <
sizeof(fiff_int_t))
411 dimp = ((fiff_int_t *)(((
char *)tag->data())+tag->size()-
sizeof(fiff_int_t)));
413 IOUtils::swap_intp(dimp);
416 if (tsize < (ndim+1)*
sizeof(fiff_int_t))
419 for (
k = 0, np = 1;
k < ndim;
k++) {
421 IOUtils::swap_intp(dimp+
k);
425 if (tsize < (ndim+2)*
sizeof(fiff_int_t))
429 dimp = dimp - ndim - 1;
431 np = dimp[0] + dimp[2] + 1;
433 np = dimp[0] + dimp[1] + 1;
436 for (
k = 0;
k < ndim+1;
k++)
437 IOUtils::swap_intp(dimp+
k);
443 if (
kind == FIFFT_INT) {
444 for (data = (
int *)(tag->data()),
k = 0;
k < np;
k++)
445 IOUtils::swap_intp(data+
k);
447 else if (
kind == FIFFT_FLOAT) {
448 for (fdata = (
float *)(tag->data()),
k = 0;
k < np;
k++)
449 IOUtils::swap_floatp(fdata+
k);
451 else if (
kind == FIFFT_DOUBLE) {
452 for (ddata = (
double *)(tag->data()),
k = 0;
k < np;
k++)
453 IOUtils::swap_doublep(ddata+
k);
455 else if (
kind == FIFFT_COMPLEX_FLOAT) {
456 for (fdata = (
float *)(tag->data()),
k = 0;
k < 2*np;
k++)
457 IOUtils::swap_floatp(fdata+
k);
459 else if (
kind == FIFFT_COMPLEX_DOUBLE) {
460 for (ddata = (
double *)(tag->data()),
k = 0;
k < 2*np;
k++)
461 IOUtils::swap_doublep(ddata+
k);
486 if (tag->data() == NULL || tag->size() == 0)
490 from_endian = NATIVE_ENDIAN;
492 to_endian = NATIVE_ENDIAN;
494 if (from_endian == to_endian)
498 if (from_endian == NATIVE_ENDIAN)
510 np = tag->size()/
sizeof(fiff_int_t);
511 for (ithis = (fiff_int_t *)tag->data(),
k = 0;
k < np;
k++, ithis++)
512 IOUtils::swap_intp(ithis);
517 np = tag->size()/
sizeof(fiff_long_t);
518 for (lthis = (fiff_long_t *)tag->data(),
k = 0;
k < np;
k++, lthis++)
519 IOUtils::swap_longp(lthis);
523 case FIFFT_DAU_PACK16 :
525 np = tag->size()/
sizeof(fiff_short_t);
526 for (sthis = (fiff_short_t *)tag->data(),
k = 0;
k < np;
k++, sthis++)
527 *sthis = IOUtils::swap_short(*sthis);
531 case FIFFT_COMPLEX_FLOAT :
532 np = tag->size()/
sizeof(fiff_float_t);
533 for (fthis = (fiff_float_t *)tag->data(),
k = 0;
k < np;
k++, fthis++)
534 IOUtils::swap_floatp(fthis);
538 case FIFFT_COMPLEX_DOUBLE :
539 np = tag->size()/
sizeof(fiff_double_t);
540 for (dthis = (fiff_double_t *)tag->data(),
k = 0;
k < np;
k++, dthis++)
541 IOUtils::swap_doublep(dthis);
544 case FIFFT_OLD_PACK :
545 fthis = (
float *)tag->data();
549 IOUtils::swap_floatp(fthis+0);
550 IOUtils::swap_floatp(fthis+1);
551 sthis = (
short *)(fthis+2);
552 np = (tag->size() - 2*
sizeof(float))/
sizeof(short);
553 for (
k = 0;
k < np;
k++,sthis++)
554 *sthis = IOUtils::swap_short(*sthis);
557 case FIFFT_DIR_ENTRY_STRUCT :
566 for (
k = 0;
k < np;
k++) {
568 ithis = (fiff_int_t*) offset;
569 ithis[0] = IOUtils::swap_int(ithis[0]);
570 ithis[1] = IOUtils::swap_int(ithis[1]);
571 ithis[2] = IOUtils::swap_int(ithis[2]);
572 ithis[3] = IOUtils::swap_int(ithis[3]);
576 case FIFFT_ID_STRUCT :
586 for (
k = 0;
k < np;
k++) {
588 ithis = (fiff_int_t*) offset;
589 ithis[0] = IOUtils::swap_int(ithis[0]);
590 ithis[1] = IOUtils::swap_int(ithis[1]);
591 ithis[2] = IOUtils::swap_int(ithis[2]);
592 ithis[3] = IOUtils::swap_int(ithis[3]);
593 ithis[4] = IOUtils::swap_int(ithis[4]);
597 case FIFFT_CH_INFO_STRUCT :
611 for (
k = 0;
k < np;
k++) {
613 ithis = (fiff_int_t*) offset;
614 fthis = (
float*) offset;
616 ithis[0] = IOUtils::swap_int(ithis[0]);
617 ithis[1] = IOUtils::swap_int(ithis[1]);
618 ithis[2] = IOUtils::swap_int(ithis[2]);
619 IOUtils::swap_floatp(&fthis[3]);
620 IOUtils::swap_floatp(&fthis[4]);
621 ithis[5] = IOUtils::swap_int(ithis[5]);
622 for (r = 0; r < 12; ++r)
623 IOUtils::swap_floatp(&fthis[6+r]);
624 ithis[18] = IOUtils::swap_int(ithis[18]);
625 ithis[19] = IOUtils::swap_int(ithis[19]);
630 case FIFFT_CH_POS_STRUCT :
636 for (
k = 0;
k < np; ++
k)
639 ithis = (fiff_int_t*) offset;
640 fthis = (
float*) offset;
642 ithis[0] = IOUtils::swap_int(ithis[0]);
643 for (r = 0; r < 12; r++)
644 IOUtils::swap_floatp(&fthis[1+r]);
649 case FIFFT_DIG_POINT_STRUCT :
660 for (
k = 0;
k < np;
k++) {
662 ithis = (fiff_int_t*) offset;
663 fthis = (
float*) offset;
665 ithis[0] = IOUtils::swap_int(ithis[0]);
666 ithis[1] = IOUtils::swap_int(ithis[1]);
668 for (r = 0; r < 3; ++r)
669 IOUtils::swap_floatp(&fthis[2+r]);
673 case FIFFT_COORD_TRANS_STRUCT :
690 for(
k = 0;
k < np; ++
k)
693 ithis = (fiff_int_t*)offset;
694 fthis = (
float*)offset;
696 ithis[0] = IOUtils::swap_int(ithis[0]);
697 ithis[1] = IOUtils::swap_int(ithis[1]);
699 for (r = 0; r < 24; ++r)
700 IOUtils::swap_floatp(&fthis[2+r]);
704 case FIFFT_DATA_REF_STRUCT :
706 for (drthis = (
fiffDataRef)tag->data(),
k = 0;
k < np;
k++, drthis++) {
707 drthis->
type = IOUtils::swap_int(drthis->
type);
709 drthis->
size = IOUtils::swap_long(drthis->
size);
725 return type & FIFFTS_FS_MASK;
732 return type & FIFFTS_BASE_MASK;
739 return type & FIFFTS_MC_MASK;