MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
fiff_stream.h
Go to the documentation of this file.
1//=============================================================================================================
37#ifndef FIFF_STREAM_H
38#define FIFF_STREAM_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "fiff_global.h"
45#include "fiff_types.h"
46#include "fiff_id.h"
47
48#include "fiff_dir_node.h"
49#include "fiff_dir_entry.h"
50
51//=============================================================================================================
52// EIGEN INCLUDES
53//=============================================================================================================
54
55#include <Eigen/Core>
56#include <Eigen/SparseCore>
57
58//=============================================================================================================
59// QT INCLUDES
60//=============================================================================================================
61
62#include <QByteArray>
63#include <QDataStream>
64#include <QIODevice>
65#include <QList>
66#include <QSharedPointer>
67#include <QString>
68#include <QStringList>
69
70//=============================================================================================================
71// DEFINE NAMESPACE FIFFLIB
72//=============================================================================================================
73
74namespace FIFFLIB
75{
76
77//=============================================================================================================
78// FORWARD DECLARATIONS
79//=============================================================================================================
80
81class FiffStream;
82class FiffTag;
83class FiffCtfComp;
84class FiffRawData;
85class FiffInfo;
86class FiffInfoBase;
87class FiffCov;
88class FiffProj;
89class FiffNamedMatrix;
90class FiffDigPoint;
91class FiffChInfo;
92class FiffChPos;
93class FiffCoordTrans;
94class FiffDigitizerData;
95
96//=============================================================================================================
104class FIFFSHARED_EXPORT FiffStream : public QDataStream
105{
106public:
107 typedef QSharedPointer<FiffStream> SPtr;
108 typedef QSharedPointer<const FiffStream> ConstSPtr;
110 //=========================================================================================================
116 explicit FiffStream(QIODevice *p_pIODevice);
117
118 //=========================================================================================================
125 explicit FiffStream(QByteArray * a, QIODevice::OpenMode mode);
126
127 //=========================================================================================================
133 QString streamName();
134
135 //=========================================================================================================
141 FiffId id() const;
142
143 //=========================================================================================================
150 QList<FiffDirEntry::SPtr>& dir();
151
152 //=========================================================================================================
159 const QList<FiffDirEntry::SPtr>& dir() const;
160
161 //=========================================================================================================
167 int nent() const;
168
169 //=========================================================================================================
176 const FiffDirNode::SPtr& dirtree() const;
177
178 //=========================================================================================================
189 fiff_long_t end_block(fiff_int_t kind, fiff_int_t next = FIFFV_NEXT_SEQ);
190
191 //=========================================================================================================
196 void end_file();
197
198 //=========================================================================================================
205 void finish_writing_raw();
206
207 //=========================================================================================================
218 bool get_evoked_entries(const QList<FiffDirNode::SPtr> &evoked_node, QStringList &comments, QList<fiff_int_t> &aspect_kinds, QString &t);
219
220 //=========================================================================================================
226// using QFile::open;
227
228 //=========================================================================================================
237 bool open(QIODevice::OpenModeFlag mode = QIODevice::ReadOnly);
238
239 //=========================================================================================================
247 bool close();
248
249 //=========================================================================================================
258 FiffDirNode::SPtr make_subtree(QList<FiffDirEntry::SPtr>& dentry);
259
260 //=========================================================================================================
274 QStringList read_bad_channels(const FiffDirNode::SPtr& p_Node);
275
276 //=========================================================================================================
290 bool read_cov(const FiffDirNode::SPtr& p_Node, fiff_int_t cov_kind, FiffCov& p_covData);
291
292 //=========================================================================================================
305 QList<FiffCtfComp> read_ctf_comp(const FiffDirNode::SPtr& p_Node, const QList<FiffChInfo>& p_Chs);
306
307 //=========================================================================================================
320 bool read_digitizer_data(const FiffDirNode::SPtr& p_Node, FiffDigitizerData& p_digData);
321
322 //=========================================================================================================
337 bool read_meas_info(const FiffDirNode::SPtr& p_Node, FiffInfo& p_Info, FiffDirNode::SPtr& p_NodeInfo);
338
339 //=========================================================================================================
350 bool read_meas_info_base(const FiffDirNode::SPtr& p_Node, FiffInfoBase& p_InfoForward);
351
352 //=========================================================================================================
366 bool read_named_matrix(const FiffDirNode::SPtr& p_Node, fiff_int_t matkind, FiffNamedMatrix& mat);
367
368 //=========================================================================================================
377 QList<FiffProj> read_proj(const FiffDirNode::SPtr& p_Node);
378
379 //=========================================================================================================
390 bool read_tag_data(QSharedPointer<FiffTag>& p_pTag, fiff_long_t pos = -1);
391
392 //=========================================================================================================
403 fiff_long_t read_tag_info(QSharedPointer<FiffTag>& p_pTag, bool p_bDoSkip = true);
404
405 //=========================================================================================================
414 bool read_rt_tag(QSharedPointer<FiffTag>& p_pTag);
415
416 //=========================================================================================================
427 bool read_tag(QSharedPointer<FiffTag>& p_pTag,
428 fiff_long_t pos = -1);
429
430 //=========================================================================================================
444 static bool setup_read_raw(QIODevice &p_IODevice,
445 FiffRawData& data,
446 bool allow_maxshield = true,
447 bool is_littleEndian = false);
448
449 //=========================================================================================================
461 static QStringList split_name_list(QString p_sNameList);
462
463 //=========================================================================================================
472 fiff_long_t start_block(fiff_int_t kind);
473
474 //=========================================================================================================
483 static FiffStream::SPtr start_file(QIODevice& p_IODevice);
484
485 //=========================================================================================================
494 static FiffStream::SPtr open_update(QIODevice& p_IODevice);
495
496 //=========================================================================================================
512 static FiffStream::SPtr start_writing_raw(QIODevice &p_IODevice,
513 const FiffInfo& info,
514 Eigen::RowVectorXd& cals,
515 Eigen::MatrixXi sel = defaultMatrixXi,
516 bool bResetRange = true);
517
518 //=========================================================================================================
529 fiff_long_t write_tag(const QSharedPointer<FiffTag>& p_pTag, fiff_long_t pos = -1);
530
531 //=========================================================================================================
542 fiff_long_t write_ch_info(const FiffChInfo& ch);
543
544 //=========================================================================================================
552 fiff_long_t write_ch_pos(const FiffChPos& chpos);
553
554 //=========================================================================================================
563 fiff_long_t write_coord_trans(const FiffCoordTrans &trans);
564
565 //=========================================================================================================
575 fiff_long_t write_cov(const FiffCov &p_FiffCov);
576
577 //=========================================================================================================
589 fiff_long_t write_ctf_comp(const QList<FiffCtfComp>& comps);
590
591 //=========================================================================================================
603 fiff_long_t write_dig_point(const FiffDigPoint& dig);
604
605 //=========================================================================================================
616 fiff_long_t write_dir_pointer(fiff_int_t dirpos, fiff_long_t pos = -1, fiff_int_t next = FIFFV_NEXT_SEQ);
617
618 //=========================================================================================================
628 fiff_long_t write_dir_entries(const QList<FiffDirEntry::SPtr>& dir, fiff_long_t pos = -1);
629
630 //=========================================================================================================
641 fiff_long_t write_double(fiff_int_t kind, const double* data, fiff_int_t nel = 1);
642
643 //=========================================================================================================
654 fiff_long_t write_id(fiff_int_t kind, const FiffId& id = FiffId::getDefault());
655
656 //=========================================================================================================
664 fiff_long_t write_info_base(const FiffInfoBase & p_FiffInfoBase);
665
666 //=========================================================================================================
678 fiff_long_t write_int(fiff_int_t kind, const fiff_int_t* data, fiff_int_t nel = 1, fiff_int_t next = FIFFV_NEXT_SEQ);
679
680 //=========================================================================================================
693 fiff_long_t write_int_matrix(fiff_int_t kind, const Eigen::MatrixXi& mat);
694
695 //=========================================================================================================
706 fiff_long_t write_float(fiff_int_t kind, const float* data, fiff_int_t nel = 1);
707
708 //=========================================================================================================
718 fiff_long_t write_float_matrix(fiff_int_t kind, const Eigen::MatrixXf& mat);
719
720 //=========================================================================================================
733 fiff_long_t write_float_sparse_ccs(fiff_int_t kind, const Eigen::SparseMatrix<float>& mat);
734
735 //=========================================================================================================
748 fiff_long_t write_float_sparse_rcs(fiff_int_t kind, const Eigen::SparseMatrix<float>& mat);
749
750 //=========================================================================================================
763 fiff_long_t write_name_list(fiff_int_t kind, const QStringList& data);
764
765 //=========================================================================================================
778 fiff_long_t write_named_matrix(fiff_int_t kind, const FiffNamedMatrix& mat);
779
780 //=========================================================================================================
792 fiff_long_t write_proj(const QList<FiffProj>& projs);
793
794 //=========================================================================================================
807 bool write_raw_buffer(const Eigen::MatrixXd& buf, const Eigen::RowVectorXd& cals);
808
809 //=========================================================================================================
822 bool write_raw_buffer(const Eigen::MatrixXd& buf, const Eigen::SparseMatrix<double>& mult);
823
824 //=========================================================================================================
835 bool write_raw_buffer(const Eigen::MatrixXd& buf);
836
837 //=========================================================================================================
847 fiff_long_t write_string(fiff_int_t kind, const QString& data);
848
849 //=========================================================================================================
856 void write_rt_command(fiff_int_t command, const QString& data);
857
858private:
859 //=========================================================================================================
868 bool check_beginning(QSharedPointer<FiffTag>& p_pTag);
869
870 //=========================================================================================================
879 QList<FiffDirEntry::SPtr> make_dir(bool *ok=Q_NULLPTR);
880
881private:
882
883// char *file_name; /**< Name of the file. */ -> Use streamName() instead
884// FILE *fd; /**< The normal file descriptor. */ -> file descitpion is part of the stream: stream->device()
885 FiffId m_id;
886 QList<FiffDirEntry::SPtr> m_dir;
887// int nent; /**< How many entries?. */ -> Use nent() instead
888 FiffDirNode::SPtr m_dirtree;
889// char *ext_file_name; /**< Name of the file holding the external data. */
890// FILE *ext_fd; /**< The file descriptor of the above file if open . */
891
892// ### OLD STRUCT ###
893// /** FIFF file handle returned by fiff_open(). */
894//typedef struct _fiffFileRec {
895// char *file_name; /**< Name of the file. */ -> part of the Parent class of the QIODevice, wrapped by streamName function
896// FILE *fd; /**< The normal file descriptor. */
897// fiffId id; /**< The file identifier. */
898// fiffDirEntry dir; /**< This is the directory.
899// * If no directory exists, fiff_open
900// * automatically scans the file to create one. */
901// int nent; /**< How many entries?. */
902// fiffDirNode dirtree; /**< Directory compiled into a tree. */
903// char *ext_file_name; /**< Name of the file holding the external data. */
904// FILE *ext_fd; /**< The file descriptor of the above file if open . */
905//} *fiffFile,fiffFileRec; /**< FIFF file handle. fiff_open() returns this. */
906};
907} // NAMESPACE
908
909#endif // FIFF_STREAM_H
Fiff library export/import macros.
#define FIFFSHARED_EXPORT
Definition fiff_global.h:56
FiffDirEntry class declaration.
FiffDirNode class declaration, which provides fiff dir tree processing methods.
FiffId class declaration.
Definitions for describing the objects in a FIFF file.
Digitization points container and description.
Channel info descriptor.
Measurement channel position and coil type.
Definition fiff_ch_pos.h:67
Coordinate transformation description.
covariance data
Definition fiff_cov.h:78
Digitization point description.
QSharedPointer< FiffDirNode > SPtr
Universially unique identifier.
Definition fiff_id.h:68
FIFF measurement file information.
Definition fiff_info.h:85
light measurement info
FIFF raw measurement data.
FIFF File I/O routines.
bool write_raw_buffer(const Eigen::MatrixXd &buf, const Eigen::RowVectorXd &cals)
QSharedPointer< const FiffStream > ConstSPtr
bool write_raw_buffer(const Eigen::MatrixXd &buf, const Eigen::SparseMatrix< double > &mult)
bool write_raw_buffer(const Eigen::MatrixXd &buf)
QSharedPointer< FiffStream > SPtr