MNE-CPP  0.1.9
A Framework for Electrophysiology
fiff_tag.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "fiff_tag.h"
42 #include <utils/ioutils.h>
43 
44 #include <complex>
45 #include <iostream>
46 
47 //=============================================================================================================
48 // QT INCLUDES
49 //=============================================================================================================
50 
51 #include <QTcpSocket>
52 
53 //=============================================================================================================
54 // USED NAMESPACES
55 //=============================================================================================================
56 
57 using namespace UTILSLIB;
58 using namespace FIFFLIB;
59 
60 //=============================================================================================================
61 // DEFINE MEMBER METHODS
62 //=============================================================================================================
63 
64 FiffTag::FiffTag()
65 : kind(0)
66 , type(0)
67 , next(0)
68 //, m_pComplexFloatData(NULL)
69 //, m_pComplexDoubleData(NULL)
70 {
71 }
72 
73 //=============================================================================================================
74 
75 FiffTag::FiffTag(const FiffTag* p_pFiffTag)
76 : QByteArray( p_pFiffTag->data(), p_pFiffTag->size())
77 , kind(p_pFiffTag->kind)
78 , type(p_pFiffTag->type)
79 , next(p_pFiffTag->next)
80 {
81 // if(p_pFiffTag->m_pComplexFloatData)
82 // this->toComplexFloat();
83 // else
84 // m_pComplexFloatData = NULL;
85 
86 // if(p_pFiffTag->m_pComplexDoubleData)
87 // this->toComplexDouble();
88 // else
89 // m_pComplexDoubleData = NULL;
90 }
91 
92 //=============================================================================================================
93 
95 {
96 // if(this->m_pComplexFloatData)
97 // delete this->m_pComplexFloatData;
98 // if(this->m_pComplexDoubleData)
99 // delete this->m_pComplexDoubleData;
100 }
101 
102 //=============================================================================================================
103 
104 fiff_int_t FiffTag::getMatrixCoding() const
105 {
106  return IS_MATRIX & this->type;
107 }
108 
109 //=============================================================================================================
110 
111 bool FiffTag::isMatrix() const
112 {
113  if (this->getMatrixCoding() != 0)
114  return true;
115  else
116  return false;
117 }
118 
119 //=============================================================================================================
120 
121 bool FiffTag::getMatrixDimensions(qint32& p_ndim, QVector<qint32>& p_Dims) const
122 {
123  p_Dims.clear();
124  if(!this->isMatrix() || this->data() == NULL)
125  {
126  p_ndim = 0;
127  return false;
128  }
129 
130  //
131  // Find dimensions and return to the beginning of tag data
132  //
133  qint32* t_pInt32 = (qint32*)this->data();
134 
135  p_ndim = t_pInt32[(this->size()-4)/4];
136 
137  if (fiff_type_matrix_coding(this->type) == FIFFTS_MC_DENSE)
138  for(int i = p_ndim+1; i > 1; --i)
139  p_Dims.append(t_pInt32[(this->size()-(i*4))/4]);
140  else if(fiff_type_matrix_coding(this->type) == FIFFTS_MC_CCS || fiff_type_matrix_coding(this->type) == FIFFTS_MC_RCS)
141  for(int i = p_ndim+2; i > 1; --i)
142  p_Dims.append(t_pInt32[(this->size()-(i*4))/4]);
143  else
144  {
145  printf("Error: Cannot handle other than dense or sparse matrices yet.\n");//ToDo Throw
146  return false;
147  }
148 
149  return true;
150 }
151 
152 //=============================================================================================================
153 
154 fiff_int_t FiffTag::getType() const
155 {
156  if (this->isMatrix())
157  {
158  return DATA_TYPE & this->type;
159  }
160  else
161  {
162  return this->type;
163  }
164 }
165 
166 //=============================================================================================================
167 
168 QString FiffTag::getInfo() const
169 {
170  QString t_qStringInfo;
171 
172  if (this->isMatrix())
173  {
174  switch(this->getType())
175  {
176  case FIFFT_INT:
177  t_qStringInfo = "Matrix of type FIFFT_INT";
178  break;
179  case FIFFT_JULIAN:
180  t_qStringInfo = "Matrix of type FIFFT_JULIAN";
181  break;
182  case FIFFT_FLOAT:
183  t_qStringInfo = "Matrix of type FIFFT_FLOAT";
184  break;
185  case FIFFT_DOUBLE:
186  t_qStringInfo = "Matrix of type FIFFT_DOUBLE";
187  break;
188  case FIFFT_COMPLEX_FLOAT:
189  t_qStringInfo = "Matrix of type FIFFT_COMPLEX_FLOAT";
190  break;
191  case FIFFT_COMPLEX_DOUBLE:
192  t_qStringInfo = "Matrix of type FIFFT_COMPLEX_DOUBLE";
193  break;
194  default:
195  t_qStringInfo = "Matrix of unknown type";
196  }
197  }
198  else
199  {
200  switch(this->getType())
201  {
202  //
203  // Simple types
204  //
205  case FIFFT_BYTE:
206  t_qStringInfo = "Simple type FIFFT_BYTE";
207  break;
208  case FIFFT_SHORT:
209  t_qStringInfo = "Simple type FIFFT_SHORT";
210  break;
211  case FIFFT_INT:
212  t_qStringInfo = "Simple type FIFFT_INT";
213  break;
214  case FIFFT_USHORT:
215  t_qStringInfo = "Simple type FIFFT_USHORT";
216  break;
217  case FIFFT_UINT:
218  t_qStringInfo = "Simple type FIFFT_UINT";
219  break;
220  case FIFFT_FLOAT:
221  t_qStringInfo = "Simple type FIFFT_FLOAT";
222  break;
223  case FIFFT_DOUBLE:
224  t_qStringInfo = "Simple type FIFFT_DOUBLE";
225  break;
226  case FIFFT_STRING:
227  t_qStringInfo = "Simple type FIFFT_STRING";
228  break;
229  case FIFFT_DAU_PACK16:
230  t_qStringInfo = "Simple type FIFFT_DAU_PACK16";
231  break;
232  case FIFFT_COMPLEX_FLOAT:
233  t_qStringInfo = "Simple type FIFFT_COMPLEX_FLOAT";
234  break;
235  case FIFFT_COMPLEX_DOUBLE:
236  t_qStringInfo = "Simple type FIFFT_COMPLEX_DOUBLE";
237  break;
238  //
239  // Structures
240  //
241  case FIFFT_ID_STRUCT:
242  t_qStringInfo = "Structure FIFFT_ID_STRUCT";
243  break;
244  case FIFFT_DIG_POINT_STRUCT:
245  t_qStringInfo = "Structure FIFFT_DIG_POINT_STRUCT";
246  break;
247  case FIFFT_COORD_TRANS_STRUCT:
248  t_qStringInfo = "Structure FIFFT_COORD_TRANS_STRUCT";
249  break;
250  case FIFFT_CH_INFO_STRUCT:
251  t_qStringInfo = "Structure FIFFT_CH_INFO_STRUCT";
252  break;
253  case FIFFT_OLD_PACK:
254  t_qStringInfo = "Structure FIFFT_OLD_PACK";
255  break;
256  case FIFFT_DIR_ENTRY_STRUCT:
257  t_qStringInfo = "Structure FIFFT_DIR_ENTRY_STRUCT";
258  break;
259  default:
260  t_qStringInfo = "Structure unknown";
261  }
262  }
263  return t_qStringInfo;
264 }
265 
266 //=============================================================================================================
267 
268 /*---------------------------------------------------------------------------
269  *
270  * Motorola like Architectures
271  *
272  * Fif file bit and byte orderings are defined to be as in HP-UX.
273  *
274  *--------------------------------------------------------------------------*/
275 
276 //#ifdef BIG_ENDIAN_ARCH
277 
278 //void FiffTag::fiff_convert_tag_info(FiffTag*& tag)
279 //{
280 // return;
281 //}
282 
283 //#endif
284 
285 //#ifdef INTEL_X86_ARCH
287 // */
288 
289 //void FiffTag::fiff_convert_tag_info(FiffTag*& tag)
290 
291 //{
292 // tag->kind = swap_int(tag->kind);
293 // tag->type = swap_int(tag->type);
294 // tag->size = swap_int(tag->size);
295 // tag->next = swap_int(tag->next);
296 // return;
297 //}
298 
299 //#endif /* INTEL_X86_ARCH */
300 
301 //=============================================================================================================
302 
304 {
305  int k;
306  pos->coil_type = IOUtils::swap_int(pos->coil_type);
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]);
312  }
313  return;
314 }
315 
316 //=============================================================================================================
317 
319 /*
320  * Assumes that the input is in the non-native byte order and needs to be swapped to the other one
321  */
322 {
323  int ndim;
324  int k;
325  int *dimp,*data,kind,np,nz;
326  float *fdata;
327  double *ddata;
328  unsigned int tsize = tag->size();
329 
330  if (fiff_type_fundamental(tag->type) != FIFFTS_FS_MATRIX)
331  return;
332  if (tag->data() == NULL)
333  return;
334  if (tsize < sizeof(fiff_int_t))
335  return;
336 
337  dimp = ((fiff_int_t *)((tag->data())+tag->size()-sizeof(fiff_int_t)));
338  IOUtils::swap_intp(dimp);
339  ndim = *dimp;
340  if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_DENSE) {
341  if (tsize < (ndim+1)*sizeof(fiff_int_t))
342  return;
343  dimp = dimp - ndim;
344  for (k = 0, np = 1; k < ndim; k++) {
345  IOUtils::swap_intp(dimp+k);
346  np = np*dimp[k];
347  }
348  }
349  else {
350  if (tsize < (ndim+2)*sizeof(fiff_int_t))
351  return;
352  if (ndim > 2) /* Not quite sure what to do */
353  return;
354  dimp = dimp - ndim - 1;
355  for (k = 0; k < ndim+1; k++)
356  IOUtils::swap_intp(dimp+k);
357  nz = dimp[0];
358  if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_CCS)
359  np = nz + dimp[2] + 1; /* nz + n + 1 */
360  else if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_RCS)
361  np = nz + dimp[1] + 1; /* nz + m + 1 */
362  else
363  return; /* Don't know what to do */
364  /*
365  * Take care of the indices
366  */
367  for (data = (int *)(tag->data())+nz, k = 0; k < np; k++)
368  IOUtils::swap_intp(data+k);
369  np = nz;
370  }
371  /*
372  * Now convert data...
373  */
374  kind = fiff_type_base(tag->type);
375  if (kind == FIFFT_INT) {
376  for (data = (int *)(tag->data()), k = 0; k < np; k++)
377  IOUtils::swap_intp(data+k);
378  }
379  else if (kind == FIFFT_FLOAT) {
380  for (fdata = (float *)(tag->data()), k = 0; k < np; k++)
381  IOUtils::swap_floatp(fdata+k);
382  }
383  else if (kind == FIFFT_DOUBLE) {
384  for (ddata = (double *)(tag->data()), k = 0; k < np; k++)
385  IOUtils::swap_doublep(ddata+k);
386  }
387  return;
388 }
389 
390 //=============================================================================================================
391 
393 /*
394  * Assumes that the input is in the NATIVE_ENDIAN byte order and needs to be swapped to the other one
395  */
396 {
397  int ndim;
398  int k;
399  int *dimp,*data,kind,np;
400  float *fdata;
401  double *ddata;
402  unsigned int tsize = tag->size();
403 
404  if (fiff_type_fundamental(tag->type) != FIFFTS_FS_MATRIX)
405  return;
406  if (tag->data() == NULL)
407  return;
408  if (tsize < sizeof(fiff_int_t))
409  return;
410 
411  dimp = ((fiff_int_t *)(((char *)tag->data())+tag->size()-sizeof(fiff_int_t)));
412  ndim = *dimp;
413  IOUtils::swap_intp(dimp);
414 
415  if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_DENSE) {
416  if (tsize < (ndim+1)*sizeof(fiff_int_t))
417  return;
418  dimp = dimp - ndim;
419  for (k = 0, np = 1; k < ndim; k++) {
420  np = np*dimp[k];
421  IOUtils::swap_intp(dimp+k);
422  }
423  }
424  else {
425  if (tsize < (ndim+2)*sizeof(fiff_int_t))
426  return;
427  if (ndim > 2) /* Not quite sure what to do */
428  return;
429  dimp = dimp - ndim - 1;
430  if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_CCS)
431  np = dimp[0] + dimp[2] + 1; /* nz + n + 1 */
432  else if (fiff_type_matrix_coding(tag->type) == FIFFTS_MC_RCS)
433  np = dimp[0] + dimp[1] + 1; /* nz + m + 1 */
434  else
435  return; /* Don't know what to do */
436  for (k = 0; k < ndim+1; k++)
437  IOUtils::swap_intp(dimp+k);
438  }
439  /*
440  * Now convert data...
441  */
442  kind = fiff_type_base(tag->type);
443  if (kind == FIFFT_INT) {
444  for (data = (int *)(tag->data()), k = 0; k < np; k++)
445  IOUtils::swap_intp(data+k);
446  }
447  else if (kind == FIFFT_FLOAT) {
448  for (fdata = (float *)(tag->data()), k = 0; k < np; k++)
449  IOUtils::swap_floatp(fdata+k);
450  }
451  else if (kind == FIFFT_DOUBLE) {
452  for (ddata = (double *)(tag->data()), k = 0; k < np; k++)
453  IOUtils::swap_doublep(ddata+k);
454  }
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);
458  }
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);
462  }
463  return;
464 }
465 
466 //=============================================================================================================
467 //ToDo remove this function by swapping -> define little endian big endian, QByteArray
468 void FiffTag::convert_tag_data(FiffTag::SPtr tag, int from_endian, int to_endian)
469 {
470  int np;
471  int k,r;//,c;
472  char *offset;
473  fiff_int_t *ithis;
474  fiff_short_t *sthis;
475  fiff_long_t *lthis;
476  float *fthis;
477  double *dthis;
478 // fiffDirEntry dethis;
479 // fiffId idthis;
480 // fiffChInfoRec* chthis;//FiffChInfo* chthis;//ToDo adapt parsing to the new class
481 // fiffChPos cpthis;
482 // fiffCoordTrans ctthis;
483 // fiffDigPoint dpthis;
484  fiffDataRef drthis;
485 
486  if (tag->data() == NULL || tag->size() == 0)
487  return;
488 
489  if (from_endian == FIFFV_NATIVE_ENDIAN)
490  from_endian = NATIVE_ENDIAN;
491  if (to_endian == FIFFV_NATIVE_ENDIAN)
492  to_endian = NATIVE_ENDIAN;
493 
494  if (from_endian == to_endian)
495  return;
496 
497  if (fiff_type_fundamental(tag->type) == FIFFTS_FS_MATRIX) {
498  if (from_endian == NATIVE_ENDIAN)
500  else
502  return;
503  }
504 
505  switch (tag->type) {
506 
507  case FIFFT_INT :
508  case FIFFT_UINT :
509  case FIFFT_JULIAN :
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);
513  break;
514 
515  case FIFFT_LONG :
516  case FIFFT_ULONG :
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);
520  break;
521 
522  case FIFFT_SHORT :
523  case FIFFT_DAU_PACK16 :
524  case FIFFT_USHORT :
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);
528  break;
529 
530  case FIFFT_FLOAT :
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);
535  break;
536 
537  case FIFFT_DOUBLE :
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);
542  break;
543 
544  case FIFFT_OLD_PACK :
545  fthis = (float *)tag->data();
546  /*
547  * Offset and scale...
548  */
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);
555  break;
556 
557  case FIFFT_DIR_ENTRY_STRUCT :
558 // np = tag->size/sizeof(fiffDirEntryRec);
559 // for (dethis = (fiffDirEntry)tag->data->data(), k = 0; k < np; k++, dethis++) {
560 // dethis->kind = swap_int(dethis->kind);
561 // dethis->type = swap_int(dethis->type);
562 // dethis->size = swap_int(dethis->size);
563 // dethis->pos = swap_int(dethis->pos);
564 // }
565  np = tag->size()/FiffDirEntry::storageSize();
566  for (k = 0; k < np; k++) {
567  offset = (char*)tag->data() + k*FiffDirEntry::storageSize();
568  ithis = (fiff_int_t*) offset;
569  ithis[0] = IOUtils::swap_int(ithis[0]);//kind
570  ithis[1] = IOUtils::swap_int(ithis[1]);//type
571  ithis[2] = IOUtils::swap_int(ithis[2]);//size
572  ithis[3] = IOUtils::swap_int(ithis[3]);//pos
573  }
574  break;
575 
576  case FIFFT_ID_STRUCT :
577 // np = tag->size/sizeof(fiffIdRec);
578 // for (idthis = (fiffId)tag->data->data(), k = 0; k < np; k++, idthis++) {
579 // idthis->version = swap_int(idthis->version);
580 // idthis->machid[0] = swap_int(idthis->machid[0]);
581 // idthis->machid[1] = swap_int(idthis->machid[1]);
582 // idthis->time.secs = swap_int(idthis->time.secs);
583 // idthis->time.usecs = swap_int(idthis->time.usecs);
584 // }
585  np = tag->size()/FiffId::storageSize();
586  for (k = 0; k < np; k++) {
587  offset = (char*)tag->data() + k*FiffId::storageSize();
588  ithis = (fiff_int_t*) offset;
589  ithis[0] = IOUtils::swap_int(ithis[0]);//version
590  ithis[1] = IOUtils::swap_int(ithis[1]);//machid[0]
591  ithis[2] = IOUtils::swap_int(ithis[2]);//machid[1]
592  ithis[3] = IOUtils::swap_int(ithis[3]);//time.secs
593  ithis[4] = IOUtils::swap_int(ithis[4]);//time.usecs
594  }
595  break;
596 
597  case FIFFT_CH_INFO_STRUCT :
598 // np = tag->size/sizeof(fiffChInfoRec);
599 // for (chthis = (fiffChInfoRec*)tag->data->data(), k = 0; k < np; k++, chthis++) {
600 // chthis->scanNo = swap_int(chthis->scanNo);
601 // chthis->logNo = swap_int(chthis->logNo);
602 // chthis->kind = swap_int(chthis->kind);
603 // swap_floatp(&chthis->range);
604 // swap_floatp(&chthis->cal);
605 // chthis->unit = swap_int(chthis->unit);
606 // chthis->unit_mul = swap_int(chthis->unit_mul);
607 // convert_ch_pos(&(chthis->chpos));
608 // }
609 
610  np = tag->size()/FiffChInfo::storageSize();
611  for (k = 0; k < np; k++) {
612  offset = (char*)tag->data() + k*FiffChInfo::storageSize();
613  ithis = (fiff_int_t*) offset;
614  fthis = (float*) offset;
615 
616  ithis[0] = IOUtils::swap_int(ithis[0]); //scanno
617  ithis[1] = IOUtils::swap_int(ithis[1]); //logno
618  ithis[2] = IOUtils::swap_int(ithis[2]); //kind
619  IOUtils::swap_floatp(&fthis[3]); //range
620  IOUtils::swap_floatp(&fthis[4]); //cal
621  ithis[5] = IOUtils::swap_int(ithis[5]); //coil_type
622  for (r = 0; r < 12; ++r)
623  IOUtils::swap_floatp(&fthis[6+r]); //loc
624  ithis[18] = IOUtils::swap_int(ithis[18]);//unit
625  ithis[19] = IOUtils::swap_int(ithis[19]);//unit_mul
626  }
627 
628  break;
629 
630  case FIFFT_CH_POS_STRUCT :
631 // np = tag->size/sizeof(fiffChPosRec);
632 // for (cpthis = (fiffChPos)tag->data->data(), k = 0; k < np; k++, cpthis++)
633 // convert_ch_pos(cpthis);
634 
635  np = tag->size()/FiffChPos::storageSize();
636  for (k = 0; k < np; ++k)
637  {
638  offset = (char*)tag->data() + k*FiffChPos::storageSize();
639  ithis = (fiff_int_t*) offset;
640  fthis = (float*) offset;
641 
642  ithis[0] = IOUtils::swap_int(ithis[0]); //coil_type
643  for (r = 0; r < 12; r++)
644  IOUtils::swap_floatp(&fthis[1+r]); //r0, ex, ey, ez
645  }
646 
647  break;
648 
649  case FIFFT_DIG_POINT_STRUCT :
650 // np = tag->size/sizeof(fiffDigPointRec);
651 // for (dpthis = (fiffDigPoint)tag->data->data(), k = 0; k < np; k++, dpthis++) {
652 // dpthis->kind = swap_int(dpthis->kind);
653 // dpthis->ident = swap_int(dpthis->ident);
654 // for (r = 0; r < 3; r++)
655 // swap_floatp(&dpthis->r[r]);
656 // }
657 
658  np = tag->size()/FiffDigPoint::storageSize();
659 
660  for (k = 0; k < np; k++) {
661  offset = tag->data() + k*FiffDigPoint::storageSize();
662  ithis = (fiff_int_t*) offset;
663  fthis = (float*) offset;
664 
665  ithis[0] = IOUtils::swap_int(ithis[0]);//kind
666  ithis[1] = IOUtils::swap_int(ithis[1]);//ident
667 
668  for (r = 0; r < 3; ++r)
669  IOUtils::swap_floatp(&fthis[2+r]); //r
670  }
671  break;
672 
673  case FIFFT_COORD_TRANS_STRUCT :
674 // np = tag->size/sizeof(fiffCoordTransRec);
675 // for (ctthis = (fiffCoordTrans)tag->data->data(), k = 0; k < np; k++, ctthis++) {
676 // ctthis->from = swap_int(ctthis->from);
677 // ctthis->to = swap_int(ctthis->to);
678 // for (r = 0; r < 3; r++) {
679 // swap_floatp(&ctthis->move[r]);
680 // swap_floatp(&ctthis->invmove[r]);
681 // for (c = 0; c < 3; c++) {
682 // swap_floatp(&ctthis->rot[r][c]);
683 // swap_floatp(&ctthis->invrot[r][c]);
684 // }
685 // }
686 // }
687 
688  np = tag->size()/FiffCoordTrans::storageSize();
689 
690  for( k = 0; k < np; ++k)
691  {
692  offset = tag->data() + k*FiffCoordTrans::storageSize();
693  ithis = (fiff_int_t*)offset;
694  fthis = (float*)offset;
695 
696  ithis[0] = IOUtils::swap_int(ithis[0]);
697  ithis[1] = IOUtils::swap_int(ithis[1]);
698 
699  for (r = 0; r < 24; ++r)
700  IOUtils::swap_floatp(&fthis[2+r]);
701  }
702  break;
703 
704  case FIFFT_DATA_REF_STRUCT :
705  np = tag->size()/sizeof(fiffDataRefRec);
706  for (drthis = (fiffDataRef)tag->data(), k = 0; k < np; k++, drthis++) {
707  drthis->type = IOUtils::swap_int(drthis->type);
708  drthis->endian = IOUtils::swap_int(drthis->endian);
709  drthis->size = IOUtils::swap_long(drthis->size);
710  drthis->offset = IOUtils::swap_long(drthis->offset);
711  }
712  break;
713 
714  default :
715  break;
716  }
717  return;
718 }
719 
720 //=============================================================================================================
721 //fiff_type_spec
722 
723 fiff_int_t FiffTag::fiff_type_fundamental(fiff_int_t type)
724 {
725  return type & FIFFTS_FS_MASK;
726 }
727 
728 //=============================================================================================================
729 
730 fiff_int_t FiffTag::fiff_type_base(fiff_int_t type)
731 {
732  return type & FIFFTS_BASE_MASK;
733 }
734 
735 //=============================================================================================================
736 
737 fiff_int_t FiffTag::fiff_type_matrix_coding(fiff_int_t type)
738 {
739  return type & FIFFTS_MC_MASK;
740 }
IS_MATRIX
#define IS_MATRIX
Definition: fiff_tag.h:130
FIFFLIB::_fiff_data_ref::offset
fiff_long_t offset
Definition: fiff_types_mne-c.h:571
FIFFLIB::FiffId::storageSize
static qint32 storageSize()
Definition: fiff_id.h:182
FIFFLIB::_fiff_data_ref::type
fiff_int_t type
Definition: fiff_types_mne-c.h:568
FIFFLIB::FiffChPos::ex
Eigen::Vector3f ex
Definition: fiff_ch_pos.h:113
FIFFLIB::FiffTag::FiffTag
FiffTag()
Definition: fiff_tag.cpp:64
FIFFLIB::FiffTag::convert_tag_data
static void convert_tag_data(FiffTag::SPtr tag, int from_endian, int to_endian)
Definition: fiff_tag.cpp:468
FIFFLIB::FiffTag::convert_matrix_from_file_data
static void convert_matrix_from_file_data(FiffTag::SPtr tag)
fiff_tag.h
FiffTag class declaration, which provides fiff tag I/O and processing methods.
FIFFT_JULIAN
#define FIFFT_JULIAN
Definition: fiff_file.h:234
FIFFLIB::FiffTag::fiff_type_fundamental
static fiff_int_t fiff_type_fundamental(fiff_int_t type)
Definition: fiff_tag.cpp:723
FIFFLIB::FiffTag::getMatrixDimensions
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const
Definition: fiff_tag.cpp:121
FIFFLIB::FiffTag::convert_ch_pos
static void convert_ch_pos(FiffChPos *pos)
FIFFLIB::FiffChPos::r0
Eigen::Vector3f r0
Definition: fiff_ch_pos.h:112
FIFFLIB::FiffTag::~FiffTag
virtual ~FiffTag()
Definition: fiff_tag.cpp:94
FIFFV_NATIVE_ENDIAN
#define FIFFV_NATIVE_ENDIAN
Definition: fiff_file.h:897
k
int k
Definition: fiff_tag.cpp:322
FIFFLIB::FiffChPos::storageSize
static qint32 storageSize()
Definition: fiff_ch_pos.h:134
FIFFLIB::FiffChPos
Measurement channel position and coil type.
Definition: fiff_ch_pos.h:66
FIFFLIB::FiffChInfo::storageSize
static qint32 storageSize()
Definition: fiff_ch_info.h:155
FIFFLIB::FiffDigPoint::storageSize
static qint32 storageSize()
Definition: fiff_dig_point.h:105
FIFFLIB::FiffChPos::coil_type
fiff_int_t coil_type
Definition: fiff_ch_pos.h:111
FIFFLIB::FiffTag
FIFF data tag.
Definition: fiff_tag.h:148
FIFFLIB::FiffTag::getInfo
QString getInfo() const
Definition: fiff_tag.cpp:168
FIFFLIB::FiffCoordTrans::storageSize
static qint32 storageSize()
Definition: fiff_coord_trans.h:318
FIFFLIB::_fiff_data_ref::size
fiff_long_t size
Definition: fiff_types_mne-c.h:570
FIFFLIB::FiffTag::type
fiff_int_t type
Definition: fiff_tag.h:501
FIFFLIB::FiffChPos::ey
Eigen::Vector3f ey
Definition: fiff_ch_pos.h:114
FIFFLIB::FiffTag::SPtr
QSharedPointer< FiffTag > SPtr
Definition: fiff_tag.h:152
FIFFLIB::FiffTag::kind
fiff_int_t kind
Definition: fiff_tag.h:499
FIFFLIB::FiffTag::getType
fiff_int_t getType() const
Definition: fiff_tag.cpp:154
FIFFLIB::_fiff_data_ref
Definition: fiff_types_mne-c.h:567
FIFFLIB::FiffDirEntry::storageSize
static qint32 storageSize()
Definition: fiff_dir_entry.h:125
DATA_TYPE
#define DATA_TYPE
Definition: fiff_tag.h:134
FIFFLIB::FiffTag::fiff_type_matrix_coding
static fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
Definition: fiff_tag.cpp:737
FIFFLIB::FiffTag::isMatrix
bool isMatrix() const
Definition: fiff_tag.cpp:111
ioutils.h
IOUtils class declaration.
FIFFLIB::FiffTag::fiff_type_base
static fiff_int_t fiff_type_base(fiff_int_t type)
Definition: fiff_tag.cpp:730
FIFFLIB::_fiff_data_ref::endian
fiff_int_t endian
Definition: fiff_types_mne-c.h:569
FIFFLIB::FiffChPos::ez
Eigen::Vector3f ez
Definition: fiff_ch_pos.h:115
FIFFLIB::FiffTag::getMatrixCoding
fiff_int_t getMatrixCoding() const
Definition: fiff_tag.cpp:104
FIFFLIB::FiffTag::convert_matrix_to_file_data
static void convert_matrix_to_file_data(FiffTag::SPtr tag)
Definition: fiff_tag.cpp:392