MNE-CPP  beta 1.0
fiff_stream.h
Go to the documentation of this file.
1 //=============================================================================================================
36 #ifndef FIFF_STREAM_H
37 #define FIFF_STREAM_H
38 
39 //*************************************************************************************************************
40 //=============================================================================================================
41 // INCLUDES
42 //=============================================================================================================
43 
44 #include "fiff_global.h"
45 #include "fiff_types.h"
46 #include "fiff_id.h"
47 #include "fiff_coord_trans.h"
48 #include "fiff_ch_info.h"
49 #include "fiff_dig_point.h"
50 #include "fiff_cov.h"
51 #include "fiff_dir_tree.h"
52 
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // Eigen INCLUDES
57 //=============================================================================================================
58 
59 #include <Eigen/Core>
60 #include <Eigen/SparseCore>
61 
62 
63 //*************************************************************************************************************
64 //=============================================================================================================
65 // STL INCLUDES
66 //=============================================================================================================
67 
68 #include <iostream>
69 #include <stdio.h>
70 #include <stdlib.h>
71 #include <time.h>
72 
73 
74 //*************************************************************************************************************
75 //=============================================================================================================
76 // Qt INCLUDES
77 //=============================================================================================================
78 
79 #include <QByteArray>
80 #include <QDataStream>
81 #include <QFile>
82 #include <QIODevice>
83 #include <QList>
84 #include <QSharedPointer>
85 #include <QString>
86 #include <QStringList>
87 
88 
89 //*************************************************************************************************************
90 //=============================================================================================================
91 // DEFINE NAMESPACE FIFFLIB
92 //=============================================================================================================
93 
94 namespace FIFFLIB
95 {
96 
97 //*************************************************************************************************************
98 //=============================================================================================================
99 // Forward Declarations
100 //=============================================================================================================
101 
102 class FiffStream;
103 class FiffTag;
104 class FiffCtfComp;
105 class FiffRawData;
106 class FiffInfo;
107 class FiffInfoBase;
108 class FiffCov;
109 
110 
111 static FiffId defaultFiffId;
112 
113 
114 //*************************************************************************************************************
115 //=============================================================================================================
116 // USED NAMESPACES
117 //=============================================================================================================
118 
119 using namespace Eigen;
120 
121 
122 //=============================================================================================================
129 class FIFFSHARED_EXPORT FiffStream : public QDataStream
130 {
131 public:
132  typedef QSharedPointer<FiffStream> SPtr;
133  typedef QSharedPointer<const FiffStream> ConstSPtr;
135  //=========================================================================================================
141  explicit FiffStream(QIODevice *p_pIODevice);
142 
143  //=========================================================================================================
150  explicit FiffStream(QByteArray * a, QIODevice::OpenMode mode);
151 
152  //=========================================================================================================
156  ~FiffStream();
157 
158  //=========================================================================================================
166  void end_block(fiff_int_t kind);
167 
168  //=========================================================================================================
175  void end_file();
176 
177  //=========================================================================================================
184  void finish_writing_raw();
185 
186  //=========================================================================================================
197  bool get_evoked_entries(const QList<FiffDirTree> &evoked_node, QStringList &comments, QList<fiff_int_t> &aspect_kinds, QString &t);
198 
199  //=========================================================================================================
205 // using QFile::open;
206 
207  //=========================================================================================================
220  bool open(FiffDirTree& p_Tree, QList<FiffDirEntry>& p_Dir);
221 
222  //=========================================================================================================
236  QStringList read_bad_channels(const FiffDirTree& p_Node);
237 
238  //=========================================================================================================
252  bool read_cov(const FiffDirTree& p_Node, fiff_int_t cov_kind, FiffCov& p_covData);
253 
254  //=========================================================================================================
267  QList<FiffCtfComp> read_ctf_comp(const FiffDirTree& p_Node, const QList<FiffChInfo>& p_Chs);
268 
269  //=========================================================================================================
284  bool read_meas_info(const FiffDirTree& p_Node, FiffInfo& p_Info, FiffDirTree& p_NodeInfo);
285 
286  //=========================================================================================================
297  bool read_meas_info_base(const FiffDirTree& p_Node, FiffInfoBase& p_InfoForward);
298 
299  //=========================================================================================================
313  bool read_named_matrix(const FiffDirTree& p_Node, fiff_int_t matkind, FiffNamedMatrix& mat);
314 
315  //=========================================================================================================
329  QList<FiffProj> read_proj(const FiffDirTree& p_Node);
330 
331  //=========================================================================================================
345  static bool setup_read_raw(QIODevice &p_IODevice, FiffRawData& data, bool allow_maxshield = false);
346 
347  //=========================================================================================================
359  static QStringList split_name_list(QString p_sNameList);
360 
361  //=========================================================================================================
373  void start_block(fiff_int_t kind);
374 
375  //=========================================================================================================
387  static FiffStream::SPtr start_file(QIODevice& p_IODevice);
388 
389  //=========================================================================================================
404  static FiffStream::SPtr start_writing_raw(QIODevice &p_IODevice, const FiffInfo& info, RowVectorXd& cals, MatrixXi sel = defaultMatrixXi);
405 
406  //=========================================================================================================
412  QString streamName();
413 
414  //=========================================================================================================
426  void write_ch_info(FiffChInfo* ch);
427 
428  //=========================================================================================================
438  void write_coord_trans(const FiffCoordTrans &trans);
439 
440  //=========================================================================================================
448  void write_cov(const FiffCov &p_FiffCov);
449 
450  //=========================================================================================================
460  void write_ctf_comp(const QList<FiffCtfComp>& comps);
461 
462  //=========================================================================================================
472  void write_dig_point(const FiffDigPoint& dig);
473 
474  //=========================================================================================================
486  void write_double(fiff_int_t kind, const double* data, fiff_int_t nel = 1);
487 
488  //=========================================================================================================
502  void write_id(fiff_int_t kind, const FiffId& id = defaultFiffId);
503 
504  //=========================================================================================================
510  void write_info_base(const FiffInfoBase & p_FiffInfoBase);
511 
512  //=========================================================================================================
524  void write_int(fiff_int_t kind, const fiff_int_t* data, fiff_int_t nel = 1);
525 
526  //=========================================================================================================
537  void write_int_matrix(fiff_int_t kind, const MatrixXi& mat);
538 
539  //=========================================================================================================
551  void write_float(fiff_int_t kind, const float* data, fiff_int_t nel = 1);
552 
553  //=========================================================================================================
564  void write_float_matrix(fiff_int_t kind, const MatrixXf& mat);
565 
566  //=========================================================================================================
577  void write_float_sparse_ccs(fiff_int_t kind, const SparseMatrix<float>& mat);
578 
579  //=========================================================================================================
590  void write_float_sparse_rcs(fiff_int_t kind, const SparseMatrix<float>& mat);
591 
592  //=========================================================================================================
603  void write_name_list(fiff_int_t kind, const QStringList& data);
604 
605  //=========================================================================================================
616  void write_named_matrix(fiff_int_t kind, const FiffNamedMatrix& mat);
617 
618  //=========================================================================================================
628  void write_proj(const QList<FiffProj>& projs);
629 
630  //=========================================================================================================
643  bool write_raw_buffer(const MatrixXd& buf, const RowVectorXd& cals);
644 
645  //=========================================================================================================
658  bool write_raw_buffer(const MatrixXd& buf, const SparseMatrix<double>& mult);
659 
660  //=========================================================================================================
671  bool write_raw_buffer(const MatrixXd& buf);
672 
673  //=========================================================================================================
684  void write_string(fiff_int_t kind, const QString& data);
685 
686  //=========================================================================================================
693  void write_rt_command(fiff_int_t command, const QString& data);
694 };
695 
696 } // NAMESPACE
697 
698 #endif // FIFF_STREAM_H
FIFF measurement file information.
Definition: fiff_info.h:96
Old fiff_type declarations - replace them.
Digitization point description.
FiffDirTree class declaration, which provides fiff dir tree processing methods.
Universially unique identifier.
Definition: fiff_id.h:78
QSharedPointer< FiffStream > SPtr
Definition: fiff_stream.h:132
FIFF raw measurement data.
Definition: fiff_raw_data.h:94
FiffChInfo class declaration.
#define FIFFSHARED_EXPORT
Definition: fiff_global.h:58
Directory tree structure.
Definition: fiff_dir_tree.h:80
Channel info descriptor.
Definition: fiff_ch_info.h:87
Fiff library export/import macros.
covariance data
Definition: fiff_cov.h:94
Definition: fiff.h:98
FiffId class declaration.
QSharedPointer< const FiffStream > ConstSPtr
Definition: fiff_stream.h:133
Coordinate transformation description.
FiffDigPoint class declaration.
light measurement info
FIFF File I/O routines.
Definition: fiff_stream.h:129
FiffCoordTrans class declaration.
FiffCov class declaration.