69 : m_pComplexFloatData(NULL)
70 , m_pComplexDoubleData(NULL)
78 : QByteArray(p_pFiffTag->data(), p_pFiffTag->size())
79 , kind(p_pFiffTag->kind)
80 , type(p_pFiffTag->type)
81 , next(p_pFiffTag->next)
83 if(p_pFiffTag->m_pComplexFloatData)
86 m_pComplexFloatData = NULL;
88 if(p_pFiffTag->m_pComplexDoubleData)
91 m_pComplexDoubleData = NULL;
100 if(this->m_pComplexFloatData)
101 delete this->m_pComplexFloatData;
102 if(this->m_pComplexDoubleData)
103 delete this->m_pComplexDoubleData;
113 p_pStream->device()->seek(pos);
122 if (p_pTag->size() > 0)
124 p_pStream->readRawData(p_pTag->data(), p_pTag->size());
128 if (p_pTag->next != FIFFV_NEXT_SEQ)
129 p_pStream->device()->seek(p_pTag->next);
149 *p_pStream >> p_pTag->kind;
150 *p_pStream >> p_pTag->type;
153 p_pTag->resize(size);
154 *p_pStream >> p_pTag->next;
160 QTcpSocket* t_qTcpSocket = qobject_cast<QTcpSocket*>(p_pStream->device());
163 p_pStream->skipRawData(p_pTag->size());
167 if (p_pTag->next == FIFFV_NEXT_SEQ)
169 p_pStream->device()->seek(p_pStream->device()->pos()+p_pTag->size());
171 else if (p_pTag->next > 0)
173 p_pStream->device()->seek(p_pTag->next);
186 while(p_pStream->device()->bytesAvailable() < 16)
187 p_pStream->device()->waitForReadyRead(10);
192 while(p_pStream->device()->bytesAvailable() < p_pTag->size())
193 p_pStream->device()->waitForReadyRead(10);
208 p_pStream->device()->seek(pos);
216 *p_pStream >> p_pTag->kind;
217 *p_pStream >> p_pTag->type;
220 p_pTag->resize(size);
221 *p_pStream >> p_pTag->next;
228 if (p_pTag->size() > 0)
230 p_pStream->readRawData(p_pTag->data(), p_pTag->size());
234 if (p_pTag->next != FIFFV_NEXT_SEQ)
235 p_pStream->device()->seek(p_pTag->next);
245 return IS_MATRIX & this->
type;
265 if(!this->
isMatrix() || this->data() == NULL)
274 qint32* t_pInt32 = (qint32*)this->data();
276 p_ndim = t_pInt32[(this->size()-4)/4];
279 for(
int i = p_ndim+1; i > 1; --i)
280 p_Dims.append(t_pInt32[(this->size()-(i*4))/4]);
282 for(
int i = p_ndim+2; i > 1; --i)
283 p_Dims.append(t_pInt32[(this->size()-(i*4))/4]);
286 printf(
"Error: Cannot handle other than dense or sparse matrices yet.\n");
300 return DATA_TYPE & this->
type;
313 QString t_qStringInfo;
320 t_qStringInfo =
"Matrix of type FIFFT_INT";
323 t_qStringInfo =
"Matrix of type FIFFT_JULIAN";
326 t_qStringInfo =
"Matrix of type FIFFT_FLOAT";
329 t_qStringInfo =
"Matrix of type FIFFT_DOUBLE";
331 case FIFFT_COMPLEX_FLOAT:
332 t_qStringInfo =
"Matrix of type FIFFT_COMPLEX_FLOAT";
334 case FIFFT_COMPLEX_DOUBLE:
335 t_qStringInfo =
"Matrix of type FIFFT_COMPLEX_DOUBLE";
338 t_qStringInfo =
"Matrix of unknown type";
349 t_qStringInfo =
"Simple type FIFFT_BYTE";
352 t_qStringInfo =
"Simple type FIFFT_SHORT";
355 t_qStringInfo =
"Simple type FIFFT_INT";
358 t_qStringInfo =
"Simple type FIFFT_USHORT";
361 t_qStringInfo =
"Simple type FIFFT_UINT";
364 t_qStringInfo =
"Simple type FIFFT_FLOAT";
367 t_qStringInfo =
"Simple type FIFFT_DOUBLE";
370 t_qStringInfo =
"Simple type FIFFT_STRING";
372 case FIFFT_DAU_PACK16:
373 t_qStringInfo =
"Simple type FIFFT_DAU_PACK16";
375 case FIFFT_COMPLEX_FLOAT:
376 t_qStringInfo =
"Simple type FIFFT_COMPLEX_FLOAT";
378 case FIFFT_COMPLEX_DOUBLE:
379 t_qStringInfo =
"Simple type FIFFT_COMPLEX_DOUBLE";
384 case FIFFT_ID_STRUCT:
385 t_qStringInfo =
"Structure FIFFT_ID_STRUCT";
387 case FIFFT_DIG_POINT_STRUCT:
388 t_qStringInfo =
"Structure FIFFT_DIG_POINT_STRUCT";
390 case FIFFT_COORD_TRANS_STRUCT:
391 t_qStringInfo =
"Structure FIFFT_COORD_TRANS_STRUCT";
393 case FIFFT_CH_INFO_STRUCT:
394 t_qStringInfo =
"Structure FIFFT_CH_INFO_STRUCT";
397 t_qStringInfo =
"Structure FIFFT_OLD_PACK";
399 case FIFFT_DIR_ENTRY_STRUCT:
400 t_qStringInfo =
"Structure FIFFT_DIR_ENTRY_STRUCT";
403 t_qStringInfo =
"Structure unknown";
406 return t_qStringInfo;
453 for (k = 0; k < 3; k++) {
454 IOUtils::swap_floatp(&pos->
r0[k]);
455 IOUtils::swap_floatp(&pos->
ex[k]);
456 IOUtils::swap_floatp(&pos->
ey[k]);
457 IOUtils::swap_floatp(&pos->
ez[k]);
472 int *dimp,*data,
kind,np,nz;
475 unsigned int tsize = tag->size();
479 if (tag->data() == NULL)
481 if (tsize <
sizeof(fiff_int_t))
484 dimp = ((fiff_int_t *)((tag->data())+tag->size()-
sizeof(fiff_int_t)));
485 IOUtils::swap_intp(dimp);
488 if (tsize < (ndim+1)*
sizeof(fiff_int_t))
491 for (k = 0, np = 1; k < ndim; k++) {
492 IOUtils::swap_intp(dimp+k);
497 if (tsize < (ndim+2)*
sizeof(fiff_int_t))
501 dimp = dimp - ndim - 1;
502 for (k = 0; k < ndim+1; k++)
503 IOUtils::swap_intp(dimp+k);
506 np = nz + dimp[2] + 1;
508 np = nz + dimp[1] + 1;
514 for (data = (
int *)(tag->data())+nz, k = 0; k < np; k++)
515 IOUtils::swap_intp(data+k);
522 if (kind == FIFFT_INT) {
523 for (data = (
int *)(tag->data()), k = 0; k < np; k++)
524 IOUtils::swap_intp(data+k);
526 else if (kind == FIFFT_FLOAT) {
527 for (fdata = (
float *)(tag->data()), k = 0; k < np; k++)
528 IOUtils::swap_floatp(fdata+k);
530 else if (kind == FIFFT_DOUBLE) {
531 for (ddata = (
double *)(tag->data()), k = 0; k < np; k++)
532 IOUtils::swap_doublep(ddata+k);
547 int *dimp,*data,
kind,np;
550 unsigned int tsize = tag->size();
554 if (tag->data() == NULL)
556 if (tsize <
sizeof(fiff_int_t))
559 dimp = ((fiff_int_t *)(((
char *)tag->data())+tag->size()-
sizeof(fiff_int_t)));
561 IOUtils::swap_intp(dimp);
564 if (tsize < (ndim+1)*
sizeof(fiff_int_t))
567 for (k = 0, np = 1; k < ndim; k++) {
569 IOUtils::swap_intp(dimp+k);
573 if (tsize < (ndim+2)*
sizeof(fiff_int_t))
577 dimp = dimp - ndim - 1;
579 np = dimp[0] + dimp[2] + 1;
581 np = dimp[0] + dimp[1] + 1;
584 for (k = 0; k < ndim+1; k++)
585 IOUtils::swap_intp(dimp+k);
591 if (kind == FIFFT_INT) {
592 for (data = (
int *)(tag->data()), k = 0; k < np; k++)
593 IOUtils::swap_intp(data+k);
595 else if (kind == FIFFT_FLOAT) {
596 for (fdata = (
float *)(tag->data()), k = 0; k < np; k++)
597 IOUtils::swap_floatp(fdata+k);
599 else if (kind == FIFFT_DOUBLE) {
600 for (ddata = (
double *)(tag->data()), k = 0; k < np; k++)
601 IOUtils::swap_doublep(ddata+k);
603 else if (kind == FIFFT_COMPLEX_FLOAT) {
604 for (fdata = (
float *)(tag->data()), k = 0; k < 2*np; k++)
605 IOUtils::swap_floatp(fdata+k);
607 else if (kind == FIFFT_COMPLEX_DOUBLE) {
608 for (ddata = (
double *)(tag->data()), k = 0; k < 2*np; k++)
609 IOUtils::swap_doublep(ddata+k);
635 if (tag->data() == NULL || tag->size() == 0)
638 if (from_endian == FIFFV_NATIVE_ENDIAN)
639 from_endian = NATIVE_ENDIAN;
640 if (to_endian == FIFFV_NATIVE_ENDIAN)
641 to_endian = NATIVE_ENDIAN;
643 if (from_endian == to_endian)
647 if (from_endian == NATIVE_ENDIAN)
659 np = tag->size()/
sizeof(fiff_int_t);
660 for (ithis = (fiff_int_t *)tag->data(), k = 0; k < np; k++, ithis++)
661 IOUtils::swap_intp(ithis);
666 np = tag->size()/
sizeof(fiff_long_t);
667 for (lthis = (fiff_long_t *)tag->data(), k = 0; k < np; k++, lthis++)
668 IOUtils::swap_longp(lthis);
672 case FIFFT_DAU_PACK16 :
674 np = tag->size()/
sizeof(fiff_short_t);
675 for (sthis = (fiff_short_t *)tag->data(), k = 0; k < np; k++, sthis++)
676 *sthis = IOUtils::swap_short(*sthis);
680 case FIFFT_COMPLEX_FLOAT :
681 np = tag->size()/
sizeof(fiff_float_t);
682 for (fthis = (fiff_float_t *)tag->data(), k = 0; k < np; k++, fthis++)
683 IOUtils::swap_floatp(fthis);
687 case FIFFT_COMPLEX_DOUBLE :
688 np = tag->size()/
sizeof(fiff_double_t);
689 for (dthis = (fiff_double_t *)tag->data(), k = 0; k < np; k++, dthis++)
690 IOUtils::swap_doublep(dthis);
693 case FIFFT_OLD_PACK :
694 fthis = (
float *)tag->data();
698 IOUtils::swap_floatp(fthis+0);
699 IOUtils::swap_floatp(fthis+1);
700 sthis = (
short *)(fthis+2);
701 np = (tag->size() - 2*
sizeof(float))/
sizeof(short);
702 for (k = 0; k < np; k++,sthis++)
703 *sthis = IOUtils::swap_short(*sthis);
706 case FIFFT_DIR_ENTRY_STRUCT :
715 for (k = 0; k < np; k++) {
717 ithis = (fiff_int_t*) offset;
718 ithis[0] = IOUtils::swap_int(ithis[0]);
719 ithis[1] = IOUtils::swap_int(ithis[1]);
720 ithis[2] = IOUtils::swap_int(ithis[2]);
721 ithis[3] = IOUtils::swap_int(ithis[3]);
725 case FIFFT_ID_STRUCT :
735 for (k = 0; k < np; k++) {
737 ithis = (fiff_int_t*) offset;
738 ithis[0] = IOUtils::swap_int(ithis[0]);
739 ithis[1] = IOUtils::swap_int(ithis[1]);
740 ithis[2] = IOUtils::swap_int(ithis[2]);
741 ithis[3] = IOUtils::swap_int(ithis[3]);
742 ithis[4] = IOUtils::swap_int(ithis[4]);
746 case FIFFT_CH_INFO_STRUCT :
760 for (k = 0; k < np; k++) {
762 ithis = (fiff_int_t*) offset;
763 fthis = (
float*) offset;
765 ithis[0] = IOUtils::swap_int(ithis[0]);
766 ithis[1] = IOUtils::swap_int(ithis[1]);
767 ithis[2] = IOUtils::swap_int(ithis[2]);
768 IOUtils::swap_floatp(&fthis[3]);
769 IOUtils::swap_floatp(&fthis[4]);
770 ithis[5] = IOUtils::swap_int(ithis[5]);
771 for (r = 0; r < 12; ++r)
772 IOUtils::swap_floatp(&fthis[6+r]);
773 ithis[18] = IOUtils::swap_int(ithis[18]);
774 ithis[19] = IOUtils::swap_int(ithis[19]);
779 case FIFFT_CH_POS_STRUCT :
785 for (k = 0; k < np; ++k)
788 ithis = (fiff_int_t*) offset;
789 fthis = (
float*) offset;
791 ithis[0] = IOUtils::swap_int(ithis[0]);
792 for (r = 0; r < 12; r++)
793 IOUtils::swap_floatp(&fthis[1+r]);
798 case FIFFT_DIG_POINT_STRUCT :
809 for (k = 0; k < np; k++) {
811 ithis = (fiff_int_t*) offset;
812 fthis = (
float*) offset;
814 ithis[0] = IOUtils::swap_int(ithis[0]);
815 ithis[1] = IOUtils::swap_int(ithis[1]);
817 for (r = 0; r < 3; ++r)
818 IOUtils::swap_floatp(&fthis[2+r]);
822 case FIFFT_COORD_TRANS_STRUCT :
839 for( k = 0; k < np; ++k)
842 ithis = (fiff_int_t*)offset;
843 fthis = (
float*)offset;
845 ithis[0] = IOUtils::swap_int(ithis[0]);
846 ithis[1] = IOUtils::swap_int(ithis[1]);
848 for (r = 0; r < 24; ++r)
849 IOUtils::swap_floatp(&fthis[2+r]);
853 case FIFFT_DATA_REF_STRUCT :
855 for (drthis = (
fiffDataRef)tag->data(), k = 0; k < np; k++, drthis++) {
856 drthis->
type = IOUtils::swap_int(drthis->
type);
858 drthis->
size = IOUtils::swap_long(drthis->
size);
874 return type & FIFFTS_FS_MASK;
882 return type & FIFFTS_BASE_MASK;
890 return type & FIFFTS_MC_MASK;
std::complex< float > * toComplexFloat()
static fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
static bool read_tag_data(FiffStream *p_pStream, FiffTag::SPtr &p_pTag, qint64 pos=-1)
static bool read_tag_info(FiffStream *p_pStream, FiffTag::SPtr &p_pTag, bool p_bDoSkip=true)
fiff_int_t getMatrixCoding() const
static qint32 storageSize()
static void convert_matrix_to_file_data(FiffTag::SPtr tag)
QSharedPointer< FiffTag > SPtr
fiff_int_t getType() const
static bool read_tag(FiffStream *p_pStream, FiffTag::SPtr &p_pTag, qint64 pos=-1)
static fiff_int_t fiff_type_fundamental(fiff_int_t type)
static void convert_tag_data(FiffTag::SPtr tag, int from_endian, int to_endian)
static qint32 storageSize()
static qint32 storageSize()
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const
static void convert_matrix_from_file_data(FiffTag::SPtr tag)
static qint32 storageSize()
static qint32 storageSize()
static qint32 storageSize()
static void convert_ch_pos(FiffChPos *pos)
static bool read_rt_tag(FiffStream *p_pStream, FiffTag::SPtr &p_pTag)
static fiff_int_t fiff_type_base(fiff_int_t type)
FiffTag class declaration, which provides fiff tag I/O and processing methods.
std::complex< double > * toComplexDouble()
IOUtils class declaration.