MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
fiff_tag.h
Go to the documentation of this file.
1//=============================================================================================================
37#ifndef FIFF_TAG_H
38#define FIFF_TAG_H
39
40//=============================================================================================================
41// DEFINES
42//=============================================================================================================
43
44/* NOTE:
45 The architecture is now deduced from the operating system, which is
46 a bit stupid way, since the same operating system can me run on various
47 architectures. This may need revision later on. */
48
49#if defined(DARWIN)
50
51#if defined(__LITTLE_ENDIAN__)
52#define INTEL_X86_ARCH
53#else
54#define BIG_ENDIAN_ARCH
55#endif
56
57#else
58
59#if defined(__hpux) || defined(__Lynx__) || defined(__sun)
60#define BIG_ENDIAN_ARCH
61#else
62#if defined(__linux) || defined(WIN32) || defined(__APPLE__)
63#define INTEL_X86_ARCH
64#endif
65
66#endif
67#endif
68
69#define NATIVE_ENDIAN FIFFV_LITTLE_ENDIAN
70
71#ifdef INTEL_X86_ARCH
72#define NATIVE_ENDIAN FIFFV_LITTLE_ENDIAN
73#endif
74
75#ifdef BIG_ENDIAN_ARCH
76#define NATIVE_ENDIAN FIFFV_BIG_ENDIAN
77#endif
78
79//=============================================================================================================
80// INCLUDES
81//=============================================================================================================
82
83#include "fiff_global.h"
84#include "fiff_constants.h"
85#include "fiff_file.h"
86#include "fiff_types.h"
87#include "fiff_id.h"
88#include "fiff_coord_trans.h"
89#include "fiff_ch_info.h"
90#include "fiff_ch_pos.h"
91#include "fiff_dir_entry.h"
92#include "fiff_tag.h"
93#include "fiff_dig_point.h"
94
95#include <iostream>
96
97//=============================================================================================================
98// EIGEN INCLUDES
99//=============================================================================================================
100
101#include <Eigen/Core>
102#include <Eigen/SparseCore>
103
104//=============================================================================================================
105// QT INCLUDES
106//=============================================================================================================
107
108#include <QDebug>
109#include <QByteArray>
110#include <QList>
111#include <QSharedPointer>
112#include <QVector>
113
114//=============================================================================================================
115// DEFINE NAMESPACE FIFFLIB
116//=============================================================================================================
117
118namespace FIFFLIB
119{
120
121class FiffStream;
122class FiffDirNode;
123
124//=============================================================================================================
125// FORWARD DECLARATIONS
126//=============================================================================================================
127//
128// The magic hexadecimal values
129//
130#define IS_MATRIX 0xFFFF0000
131#define MATRIX_CODING_DENSE 0x00004000
132#define MATRIX_CODING_CCS 0x00004010
133#define MATRIX_CODING_RCS 0x00004020
134#define DATA_TYPE 0x0000FFFF
136//const fiff_int_t IS_MATRIX = 4294901760; /**< Is Matrix encoding. ffff0000. */
137//const fiff_int_t MATRIX_CODING_DENSE = 16384; /**< MATRIX_CODING_DENSE encoding. 4000. */
138//const fiff_int_t MATRIX_CODING_CCS = 16400; /**< MATRIX_CODING_CCS encoding. 4010. */
139//const fiff_int_t MATRIX_CODING_RCS = 16416; /**< MATRIX_CODING_RCS encoding. 4020. */
140//const fiff_int_t DATA_TYPE = 65535; /**< DATA_TYPE encoding. ffff. */
141
142//=============================================================================================================
148class FIFFSHARED_EXPORT FiffTag : public QByteArray
149{
150
151public:
152 typedef QSharedPointer<FiffTag> SPtr;
153 typedef QSharedPointer<const FiffTag> ConstSPtr;
155 //=========================================================================================================
159 FiffTag();
160
161 //=========================================================================================================
165 FiffTag(const FiffTag* p_pFiffTag);
166
167 //=========================================================================================================
171 virtual ~FiffTag();
172
173 //=========================================================================================================
179 fiff_int_t getMatrixCoding() const;
180
181 //=========================================================================================================
187 bool isMatrix() const;
188
189 //=========================================================================================================
199 bool getMatrixDimensions(qint32& p_ndim, QVector<qint32>& p_Dims) const;
200
201 //=========================================================================================================
207 fiff_int_t getType() const;
208
209 //=========================================================================================================
215 QString getInfo() const;
216
217 //
218 // Simple types
219 //
220 //=========================================================================================================
227 inline quint8* toByte() const;
228
229 //=========================================================================================================
236 inline quint16* toUnsignedShort() const;
237
238 //=========================================================================================================
245 inline qint16* toShort() const;
246
247 //=========================================================================================================
254 inline quint32* toUnsignedInt() const;
255
256 //=========================================================================================================
263 inline qint32* toInt() const;
264
265 //=========================================================================================================
272 inline qint32* toJulian() const;
273
274 //=========================================================================================================
281 inline float* toFloat() const;
282
283 //=========================================================================================================
290 inline double* toDouble() const;
291
292 //=========================================================================================================
298 inline QString toString() const;
299
300 //=========================================================================================================
307 inline qint16* toDauPack16() const;
308
309 //=========================================================================================================
316// inline std::complex<float>* toComplexFloat();
317
318 //=========================================================================================================
325// inline std::complex<double>* toComplexDouble();
326
327 //
328 // Structures
329 //
330 //=========================================================================================================
336 inline FiffId toFiffID() const;
337
338 //=========================================================================================================
344 inline FiffDigPoint toDigPoint() const;
345
346 //=========================================================================================================
352 inline FiffCoordTrans toCoordTrans() const;
353
354 //=========================================================================================================
360 inline FiffChInfo toChInfo() const;
361
362// //=========================================================================================================
363// /**
364// * to fiff OLD PACK
365// */
366// inline fiff_coord_trans_t toCoordTrans() const;
367
368 //=========================================================================================================
374 inline QList< QSharedPointer<FiffDirEntry> > toDirEntry() const;
375
376 //
377 // MATRIX
378 //
379 //=========================================================================================================
385 inline Eigen::MatrixXi toIntMatrix() const;
386
387 //=========================================================================================================
395 inline Eigen::MatrixXf toFloatMatrix() const;
396
397 //=========================================================================================================
405 inline Eigen::SparseMatrix<double> toSparseFloatMatrix() const;
406
407 //
408 //from fiff_combat.c
409 //
410
411 //=========================================================================================================
417 static void convert_ch_pos(FiffChPos* pos);
418
419 //TODO: Check if this is of interest
420// static void fiff_convert_tag_info(FiffTag*& tag);
421
422 /*
423 * Data type conversions for the little endian systems.
424 */
433 //TODO: Check if this is of interest
434// void fiff_convert_tag_data(fiffTag tag, int from_endian, int to_endian)
435
436 //=========================================================================================================
443
444 //=========================================================================================================
450 static void convert_matrix_to_file_data(FiffTag::SPtr tag);
451
452 //
453 // Data type conversions for the little endian systems.
454 //
455 //=========================================================================================================
469 static void convert_tag_data(FiffTag::SPtr tag, int from_endian, int to_endian);
470
471 //
472 // from fiff_type_spec.c
473 //
474 //=========================================================================================================
480 static fiff_int_t fiff_type_fundamental(fiff_int_t type);
481
482 //=========================================================================================================
488 static fiff_int_t fiff_type_base(fiff_int_t type);
489
490 //=========================================================================================================
496 static fiff_int_t fiff_type_matrix_coding(fiff_int_t type);
497
498public:
499 fiff_int_t kind;
501 fiff_int_t type;
503// fiff_int_t size; /**< Size of the data.
504// * The size is given in bytes and defines the
505// * total size of the data. */
506 fiff_int_t next;
510// QByteArray* data; /**< Pointer to the data.
511// * This point to the data read or to be written. */
512private:
513// std::complex<float>* m_pComplexFloatData;
514
515// std::complex<double>* m_pComplexDoubleData;
516
517// ### OLD STRUCT ###
518//typedef struct _fiffTagRec {
519// fiff_int_t kind; /**< Tag number.
520// * This defines the meaning of the item */
521// fiff_int_t type; /**< Data type.
522// * This defines the reperentation of the data. */
523// fiff_int_t size; /**< Size of the data.
524// * The size is given in bytes and defines the
525// * total size of the data. */
526// fiff_int_t next; /**< Pointer to the next object.
527// * Zero if the object follows
528// * sequentially in file.
529// * Negative at the end of file */
530// fiff_data_t *data; /**< Pointer to the data.
531// * This point to the data read or to be written. */
532//} *fiffTag,fiffTagRec; /**< FIFF data tag. */
533};
534
535//=============================================================================================================
536// INLINE DEFINITIONS
537//=============================================================================================================
538
539//=============================================================================================================
540// Simple types
541//=============================================================================================================
542
543inline quint8* FiffTag::toByte() const
544{
545 if(this->isMatrix() || this->getType() != FIFFT_BYTE)
546 return NULL;
547 else
548 return (quint8*)this->data();
549}
550
551//=============================================================================================================
552
553inline quint16* FiffTag::toUnsignedShort() const
554{
555 if(this->isMatrix() || this->getType() != FIFFT_USHORT)
556 return NULL;
557 else
558 return (quint16*)this->data();
559}
560
561//=============================================================================================================
562
563inline qint16* FiffTag::toShort() const
564{
565 if(this->isMatrix() || this->getType() != FIFFT_SHORT)
566 return NULL;
567 else
568 return (qint16*)this->data();
569}
570
571//=============================================================================================================
572
573inline quint32* FiffTag::toUnsignedInt() const
574{
575 if(this->isMatrix() || this->getType() != FIFFT_UINT)
576 return NULL;
577 else
578 return (quint32*)this->data();
579}
580
581//=============================================================================================================
582
583inline qint32* FiffTag::toInt() const
584{
585 if(this->isMatrix() || this->getType() != FIFFT_INT) {
586 printf("Expected an integer tag : %d (found data type %d instead)\n",this->kind,this->getType());
587 return NULL;
588 }
589 else
590 return (qint32*)this->data();
591}
592
593//=============================================================================================================
594
595inline qint32* FiffTag::toJulian() const
596{
597 if(this->isMatrix() || this->getType() != FIFFT_JULIAN) {
598 printf("Expected a julian tag : %d (found data type %d instead)\n",this->kind,this->getType());
599 return NULL;
600 }
601 else
602 return (qint32*)this->data();
603}
604
605//=============================================================================================================
606
607inline float* FiffTag::toFloat() const
608{
609 if(this->isMatrix() || this->getType() != FIFFT_FLOAT)
610 return NULL;
611 else
612 return (float*)this->data();
613}
614
615//=============================================================================================================
616
617inline double* FiffTag::toDouble() const
618{
619 if(this->isMatrix() || this->getType() != FIFFT_DOUBLE)
620 return NULL;
621 else
622 return (double*)this->data();
623}
624
625//=============================================================================================================
626
627inline QString FiffTag::toString() const
628{
629 if(this->isMatrix() || this->getType() != FIFFT_STRING)
630 return NULL;
631 else
632 return *this;
633}
634
635//=============================================================================================================
636
637inline qint16* FiffTag::toDauPack16() const
638{
639 if(this->isMatrix() || this->getType() != FIFFT_DAU_PACK16)
640 return NULL;
641 else
642 return (qint16*)this->data();
643}
644
645//=============================================================================================================
646
647//inline std::complex<float>* FiffTag::toComplexFloat()
648//{
649// if(this->isMatrix() || this->getType() != FIFFT_COMPLEX_FLOAT)
650// return NULL;
651// else if(this->m_pComplexFloatData == NULL)
652// {
653// float* t_pFloat = (float*)this->data();
654// qDebug() << "ToDo toComplexFloat";
655// //ToDo check this for arrays which contains more than one value
656// this->m_pComplexFloatData = new std::complex<float>(t_pFloat[0],t_pFloat[1]);
657// }
658// return m_pComplexFloatData;
659//}
660
661//=============================================================================================================
662
663//inline std::complex<double>* FiffTag::toComplexDouble()
664//{
665// if(this->isMatrix() || this->getType() != FIFFT_COMPLEX_DOUBLE)
666// return NULL;
667// else if(this->m_pComplexDoubleData == NULL)
668// {
669// double* t_pDouble = (double*)this->data();
670// qDebug() << "ToDo toComplexDouble";
671// //ToDo check this for arrays which contains more than one value
672// this->m_pComplexDoubleData = new std::complex<double>(t_pDouble[0],t_pDouble[1]);
673// }
674// return m_pComplexDoubleData;
675//}
676
677//=============================================================================================================
678// Structures
679//=============================================================================================================
680
682{
683 FiffId p_fiffID;
684 if(this->isMatrix() || this->getType() != FIFFT_ID_STRUCT || this->data() == NULL)
685 return p_fiffID;
686 else
687 {
688 const qint32* t_pInt32 = (qint32*)this->data();
689
690 p_fiffID.version = t_pInt32[0];
691 p_fiffID.machid[0] = t_pInt32[1];
692 p_fiffID.machid[1] = t_pInt32[2];
693 p_fiffID.time.secs = t_pInt32[3];
694 p_fiffID.time.usecs = t_pInt32[4];
695
696 return p_fiffID;
697 }
698}
699
700//=============================================================================================================
701
703{
704
705 FiffDigPoint t_fiffDigPoint;
706 if(this->isMatrix() || this->getType() != FIFFT_DIG_POINT_STRUCT || this->data() == NULL)
707 return t_fiffDigPoint;
708 else
709 {
710 qint32* t_pInt32 = (qint32*)this->data();
711// memcpy (&t_fiffDigPoint,this->data,this->size);
712
713 t_fiffDigPoint.kind = t_pInt32[0];
714 t_fiffDigPoint.ident = t_pInt32[1];
715
716 float* t_pFloat = (float*)this->data();
717 t_fiffDigPoint.r[0] = t_pFloat[2];
718 t_fiffDigPoint.r[1] = t_pFloat[3];
719 t_fiffDigPoint.r[2] = t_pFloat[4];
720 t_fiffDigPoint.coord_frame = 0;
721
722 return t_fiffDigPoint;
723 }
724}
725
726//=============================================================================================================
727
729{
730
731 FiffCoordTrans p_FiffCoordTrans;
732 if(this->isMatrix() || this->getType() != FIFFT_COORD_TRANS_STRUCT || this->data() == NULL)
733 return p_FiffCoordTrans;
734 else
735 {
736 qint32* t_pInt32 = (qint32*)this->data();
737 p_FiffCoordTrans.from = t_pInt32[0];
738 p_FiffCoordTrans.to = t_pInt32[1];
739
740 p_FiffCoordTrans.trans.setIdentity(4,4);
741 float* t_pFloat = (float*)this->data();
742 int count = 0;
743 int r, c;
744 for (r = 0; r < 3; ++r) {
745 p_FiffCoordTrans.trans(r,3) = t_pFloat[11+r];
746 for (c = 0; c < 3; ++c) {
747 p_FiffCoordTrans.trans(r,c) = t_pFloat[2+count];
748 ++count;
749 }
750 }
751
752 p_FiffCoordTrans.invtrans.setIdentity(4,4);
753 count = 0;
754 for (r = 0; r < 3; ++r) {
755 p_FiffCoordTrans.invtrans(r,3) = t_pFloat[23+r];
756 for (c = 0; c < 3; ++c) {
757 p_FiffCoordTrans.invtrans(r,c) = t_pFloat[14+count];
758 ++count;
759 }
760 }
761
762 return p_FiffCoordTrans;
763 }
764}
765
766//=========================================================================================================
771{
772 FiffChInfo p_FiffChInfo;
773
774 if(this->isMatrix() || this->getType() != FIFFT_CH_INFO_STRUCT || this->data() == NULL)
775 return p_FiffChInfo;
776 else
777 {
778 qint32* t_pInt32 = (qint32*)this->data();
779 p_FiffChInfo.scanNo = t_pInt32[0];
780 p_FiffChInfo.logNo = t_pInt32[1];
781 p_FiffChInfo.kind = t_pInt32[2];
782 float* t_pFloat = (float*)this->data();
783 p_FiffChInfo.range = t_pFloat[3];
784 p_FiffChInfo.cal = t_pFloat[4];
785 p_FiffChInfo.chpos.coil_type = t_pInt32[5];
786
787 //
788 // Read the coil coordinate system definition
789 //
790 qint32 r;
791 // r0
792 for (r = 0; r < 3; ++r)
793 p_FiffChInfo.chpos.r0[r] = t_pFloat[6+r];
794 // ex
795 for (r = 0; r < 3; ++r)
796 p_FiffChInfo.chpos.ex[r] = t_pFloat[6+3+r];
797 // ey
798 for (r = 0; r < 3; ++r)
799 p_FiffChInfo.chpos.ey[r] = t_pFloat[6+6+r];
800 // ez
801 for (r = 0; r < 3; ++r)
802 p_FiffChInfo.chpos.ez[r] = t_pFloat[6+9+r];
803
804 p_FiffChInfo.coord_frame = FIFFV_COORD_UNKNOWN;
805
806 //
807 // Convert loc into a more useful format
808 //
809 if (p_FiffChInfo.kind == FIFFV_MEG_CH || p_FiffChInfo.kind == FIFFV_REF_MEG_CH)
810 {
811 p_FiffChInfo.coil_trans.setIdentity(4,4);
812 // r0
813 for (r = 0; r < 3; ++r)
814 p_FiffChInfo.coil_trans(r,3) = p_FiffChInfo.chpos.r0[r];
815 // ex
816 for (r = 0; r < 3; ++r)
817 p_FiffChInfo.coil_trans(r,0) = p_FiffChInfo.chpos.ex[r];
818 // ey
819 for (r = 0; r < 3; ++r)
820 p_FiffChInfo.coil_trans(r,1) = p_FiffChInfo.chpos.ey[r];
821 // ez
822 for (r = 0; r < 3; ++r)
823 p_FiffChInfo.coil_trans(r,2) = p_FiffChInfo.chpos.ez[r];
824
825 p_FiffChInfo.coord_frame = FIFFV_COORD_DEVICE;
826 }
827 else if (p_FiffChInfo.kind == FIFFV_EEG_CH)
828 {
829 if (p_FiffChInfo.chpos.ex.norm() > 0) {
830 p_FiffChInfo.eeg_loc.block(0,0,3,1) = p_FiffChInfo.chpos.r0.block(0,0,3,1);
831 p_FiffChInfo.eeg_loc.block(0,1,3,1) = p_FiffChInfo.chpos.ex.block(0,0,3,1);
832 }
833 else {
834 p_FiffChInfo.eeg_loc.block(0,0,3,1) = p_FiffChInfo.chpos.r0.block(0,0,3,1);
835 }
836 p_FiffChInfo.coord_frame = FIFFV_COORD_HEAD;
837 }
838 //
839 // Unit and exponent
840 //
841 p_FiffChInfo.unit = t_pInt32[18];
842 p_FiffChInfo.unit_mul = t_pInt32[19];
843
844 //
845 // Handle the channel name
846 //
847 char* orig = (char*)this->data();
848 p_FiffChInfo.ch_name = QString::fromUtf8(orig + 80).replace(" ","");
849
850 return p_FiffChInfo;
851 }
852}
853
854// //=========================================================================================================
855// /**
856// * to fiff OLD PACK
857// */
858// inline fiff_coord_trans_t toCoordTrans() const
859// {
860
861// }
862
863//=============================================================================================================
864
865inline QList< QSharedPointer<FiffDirEntry> > FiffTag::toDirEntry() const
866{
867// tag.data = struct('kind',{},'type',{},'size',{},'pos',{});
868 QList< QSharedPointer<FiffDirEntry> > p_ListFiffDir;
869 if(this->isMatrix() || this->getType() != FIFFT_DIR_ENTRY_STRUCT || this->data() == NULL)
870 return p_ListFiffDir;
871 else
872 {
873 QSharedPointer<FiffDirEntry> t_pFiffDirEntry;
874 qint32* t_pInt32 = (qint32*)this->data();
875 for (int k = 0; k < this->size()/16; ++k)
876 {
877 t_pFiffDirEntry = QSharedPointer<FiffDirEntry>(new FiffDirEntry);
878 t_pFiffDirEntry->kind = t_pInt32[k*4];//fread(fid,1,'int32');
879 t_pFiffDirEntry->type = t_pInt32[k*4+1];//fread(fid,1,'uint32');
880 t_pFiffDirEntry->size = t_pInt32[k*4+2];//fread(fid,1,'int32');
881 t_pFiffDirEntry->pos = t_pInt32[k*4+3];//fread(fid,1,'int32');
882 p_ListFiffDir.append(t_pFiffDirEntry);
883 }
884 }
885 return p_ListFiffDir;
886}
887
888//=============================================================================================================
889// MATRIX
890//=============================================================================================================
891
892//=============================================================================================================
893
894inline Eigen::MatrixXi FiffTag::toIntMatrix() const
895{
896 if(!this->isMatrix() || this->getType() != FIFFT_INT || this->data() == NULL)
897 return Eigen::MatrixXi();
898
899 qint32 ndim;
900 QVector<qint32> dims;
901 this->getMatrixDimensions(ndim, dims);
902
903 if (ndim != 2)
904 {
905 printf("Only two-dimensional matrices are supported at this time");
906 return Eigen::MatrixXi();
907 }
908
909 //MatrixXd p_Matrix = Map<MatrixXd>( (float*)this->data,p_dims[0], p_dims[1]);
910 // --> Use copy constructor instead --> slower performance but higher memory management reliability
911 Eigen::MatrixXi p_Matrix(Eigen::Map<Eigen::MatrixXi>( (int*)this->data(),dims[0], dims[1]));
912
913 return p_Matrix;
914}
915
916//=============================================================================================================
917
918inline Eigen::MatrixXf FiffTag::toFloatMatrix() const
919{
920 if(!this->isMatrix() || this->getType() != FIFFT_FLOAT || this->data() == NULL)
921 return Eigen::MatrixXf();//NULL;
922
923 if (fiff_type_matrix_coding(this->type) != FIFFTS_MC_DENSE)
924 {
925 printf("Error in FiffTag::toFloatMatrix(): Matrix is not dense!\n");
926 return Eigen::MatrixXf();//NULL;
927 }
928
929 qint32 ndim;
930 QVector<qint32> dims;
931 this->getMatrixDimensions(ndim, dims);
932
933 if (ndim != 2)
934 {
935 printf("Only two-dimensional matrices are supported at this time");
936 return Eigen::MatrixXf();//NULL;
937 }
938
939 // --> Use copy constructor instead --> slower performance but higher memory management reliability
940 Eigen::MatrixXf p_Matrix((Eigen::Map<Eigen::MatrixXf>( (float*)this->data(),dims[0], dims[1])));
941
942 return p_Matrix;
943}
944
945//=============================================================================================================
946
947inline Eigen::SparseMatrix<double> FiffTag::toSparseFloatMatrix() const
948{
949 if(!this->isMatrix() || this->getType() != FIFFT_FLOAT || this->data() == NULL)
950 return Eigen::SparseMatrix<double>();//NULL;
951
952 if (fiff_type_matrix_coding(this->type) != FIFFTS_MC_CCS && fiff_type_matrix_coding(this->type) != FIFFTS_MC_RCS)
953 {
954 printf("Error in FiffTag::toSparseFloatMatrix(): Matrix is not sparse!\n");
955 return Eigen::SparseMatrix<double>();//NULL;
956 }
957
958 qint32 ndim;
959 QVector<qint32> dims;
960 this->getMatrixDimensions(ndim, dims);
961
962 if (ndim != 2)
963 {
964 printf("Only two-dimensional matrices are supported at this time");
965 return Eigen::SparseMatrix<double>();//NULL;
966 }
967
968 qint32 nnz = dims[0];
969 qint32 nrow = dims[1];
970 qint32 ncol = dims[2];
971
972 typedef Eigen::Triplet<double> T;
973 std::vector<T> tripletList;
974 tripletList.reserve(nnz);
975
976 float *t_pFloat = (float*)this->data();
977 int *t_pInt = (int*)this->data();
978 qint32 offset1 = nnz;
979 qint32 offset2 = 2*nnz;
980 if (fiff_type_matrix_coding(this->type) == FIFFTS_MC_CCS)
981 {
982 //
983 // CCS
984 //
985 qWarning("Warning in FiffTag::toSparseFloatMatrix(): CCS has to be debugged - never done before.");
986 qint32 p = 0;
987 for(qint32 j = 0; j < ncol; ++j)
988 {
989 while( p < t_pInt[offset2+j+1])
990 {
991// tripletList[p] = T(tripletList[p].row(), j, tripletList[p].value());
992 tripletList.push_back(T(t_pInt[offset1+p], j, (double)(t_pFloat[p])));
993 ++p;
994 }
995 }
996 }
997 else
998 {
999 //
1000 // RCS
1001 //
1002 qint32 p = 0;
1003 for(qint32 j = 0; j < nrow; ++j)
1004 {
1005 while( p < t_pInt[offset2+j+1])
1006 {
1007// tripletList[p] = T(j, tripletList[p].col(), tripletList[p].value());
1008 tripletList.push_back(T(j, t_pInt[offset1+p], (double)(t_pFloat[p])));
1009 ++p;
1010 }
1011 }
1012 }
1013
1014// std::cout << "Size: " << tripletList.size() << std::endl;
1015// qint32 offsetTest = tripletList.size() - 10;
1016// for(qint32 i = 0; i < 10; ++i)
1017// std::cout << std::endl << tripletList[offsetTest + i].row() << " " << tripletList[offsetTest + i].col() << " " << tripletList[offsetTest + i].value();
1018
1019 Eigen::SparseMatrix<double> p_Matrix(nrow, ncol);
1020 p_Matrix.setFromTriplets(tripletList.begin(), tripletList.end());
1021
1022 return p_Matrix;
1023}
1024} // NAMESPACE
1025
1026#endif // FIFF_TAG_H
FiffChPos class declaration.
FiffTag class declaration, which provides fiff tag I/O and processing methods.
Fiff library export/import macros.
#define FIFFSHARED_EXPORT
Definition fiff_global.h:56
Fiff constants.
#define FIFFV_REF_MEG_CH
FiffDirEntry class declaration.
FiffChInfo class declaration.
FiffId class declaration.
int k
Definition fiff_tag.cpp:324
Header file describing the numerical values used in fif files.
#define FIFFT_JULIAN
Definition fiff_file.h:234
Definitions for describing the objects in a FIFF file.
FiffCoordTrans class declaration.
FiffDigPoint class declaration.
Channel info descriptor.
Eigen::Matrix< float, 3, 2, Eigen::DontAlign > eeg_loc
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > coil_trans
Measurement channel position and coil type.
Definition fiff_ch_pos.h:67
Eigen::Vector3f r0
fiff_int_t coil_type
Eigen::Vector3f ey
Eigen::Vector3f ex
Eigen::Vector3f ez
Coordinate transformation description.
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > trans
Eigen::Matrix< float, 4, 4, Eigen::DontAlign > invtrans
Digitization point description.
Directory entry description.
Universially unique identifier.
Definition fiff_id.h:68
fiff_int_t machid[2]
Definition fiff_id.h:153
fiffTimeRec time
Definition fiff_id.h:154
fiff_int_t version
Definition fiff_id.h:152
FIFF data tag.
Definition fiff_tag.h:149
static fiff_int_t fiff_type_matrix_coding(fiff_int_t type)
Definition fiff_tag.cpp:737
QString toString() const
Definition fiff_tag.h:627
qint16 * toShort() const
Definition fiff_tag.h:563
Eigen::MatrixXf toFloatMatrix() const
Definition fiff_tag.h:918
quint32 * toUnsignedInt() const
Definition fiff_tag.h:573
fiff_int_t kind
Definition fiff_tag.h:499
FiffCoordTrans toCoordTrans() const
Definition fiff_tag.h:728
qint32 * toJulian() const
Definition fiff_tag.h:595
Eigen::MatrixXi toIntMatrix() const
Definition fiff_tag.h:894
quint16 * toUnsignedShort() const
Definition fiff_tag.h:553
FiffChInfo toChInfo() const
Definition fiff_tag.h:770
qint16 * toDauPack16() const
Definition fiff_tag.h:637
FiffDigPoint toDigPoint() const
Definition fiff_tag.h:702
qint32 * toInt() const
Definition fiff_tag.h:583
QSharedPointer< FiffTag > SPtr
Definition fiff_tag.h:152
quint8 * toByte() const
Definition fiff_tag.h:543
double * toDouble() const
Definition fiff_tag.h:617
bool isMatrix() const
Definition fiff_tag.cpp:111
static void convert_matrix_from_file_data(FiffTag::SPtr tag)
fiff_int_t getType() const
Definition fiff_tag.cpp:154
Eigen::SparseMatrix< double > toSparseFloatMatrix() const
Definition fiff_tag.h:947
FiffId toFiffID() const
Definition fiff_tag.h:681
fiff_int_t type
Definition fiff_tag.h:501
QSharedPointer< const FiffTag > ConstSPtr
Definition fiff_tag.h:153
static void convert_ch_pos(FiffChPos *pos)
float * toFloat() const
Definition fiff_tag.h:607
fiff_int_t next
Definition fiff_tag.h:506
bool getMatrixDimensions(qint32 &p_ndim, QVector< qint32 > &p_Dims) const
Definition fiff_tag.cpp:121
QList< QSharedPointer< FiffDirEntry > > toDirEntry() const
Definition fiff_tag.h:865