v2.0.0
Loading...
Searching...
No Matches
bids_edf_reader.h
Go to the documentation of this file.
1//=============================================================================================================
37
38#ifndef BIDS_EDF_READER_H
39#define BIDS_EDF_READER_H
40
41//=============================================================================================================
42// INCLUDES
43//=============================================================================================================
44
46
47//=============================================================================================================
48// QT INCLUDES
49//=============================================================================================================
50
51#include <QDateTime>
52#include <QVector>
53#include <QFile>
54
55//=============================================================================================================
56// DEFINE NAMESPACE BIDSLIB
57//=============================================================================================================
58
59namespace BIDSLIB
60{
61
62//=============================================================================================================
67{
69 QString label;
72 QString prefiltering;
73 float physicalMin{0.0f};
74 float physicalMax{0.0f};
75 long digitalMin{0};
76 long digitalMax{0};
78 long sampleCount{0};
79 float frequency{0.0f};
80 bool isMeasurement{false};
81
82 FIFFLIB::FiffChInfo toFiffChInfo() const;
83};
84
85//=============================================================================================================
94{
95public:
96 //=========================================================================================================
101 explicit EDFReader(float fScaleFactor = 1e6);
102
103 ~EDFReader() override;
104
105 // AbstractFormatReader interface
106 bool open(const QString& sFilePath) override;
107 FIFFLIB::FiffInfo getInfo() const override;
108 Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override;
109 long getSampleCount() const override;
110 float getFrequency() const override;
111 int getChannelCount() const override;
112 FIFFLIB::FiffRawData toFiffRawData() const override;
113 QString formatName() const override;
114 bool supportsExtension(const QString& sExtension) const override;
115
116 //=========================================================================================================
120 QVector<EDFChannelInfo> getAllChannelInfos() const;
121
122 //=========================================================================================================
126 QVector<EDFChannelInfo> getMeasurementChannelInfos() const;
127
128private:
129 // EDF header field byte lengths
130 enum EDFHeaderFieldLengths {
131 EDF_VERSION = 8,
132 LOCAL_PATIENT_INFO = 80,
133 LOCAL_RECORD_INFO = 80,
134 STARTDATE = 8,
135 STARTTIME = 8,
136 NUM_BYTES_HEADER = 8,
137 HEADER_RESERVED = 44,
138 NUM_DATA_RECORDS = 8,
139 DURATION_DATA_RECS = 8,
140 NUM_SIGNALS = 4,
141 SIG_LABEL = 16,
142 SIG_TRANSDUCER = 80,
143 SIG_PHYS_DIM = 8,
144 SIG_PHYS_MIN = 8,
145 SIG_PHYS_MAX = 8,
146 SIG_DIG_MIN = 8,
147 SIG_DIG_MAX = 8,
148 SIG_PREFILTERING = 80,
149 SIG_NUM_SAMPLES = 8,
150 SIG_RESERVED = 32,
151 };
152
153 void parseHeader(QIODevice* pDev);
154
155 float m_fScaleFactor;
156 QString m_sFilePath;
157
158 // Header data
159 QString m_sVersionNo;
160 QString m_sPatientId;
161 QString m_sRecordingId;
162 QDateTime m_startDateTime;
163 int m_iNumBytesInHeader{0};
164 int m_iNumDataRecords{0};
165 float m_fDataRecordsDuration{0.0f};
166 int m_iNumChannels{0};
167 int m_iNumBytesPerDataRecord{0};
168
169 QVector<EDFChannelInfo> m_vAllChannels;
170 QVector<EDFChannelInfo> m_vMeasChannels;
171
172 mutable QFile m_file;
173 bool m_bIsOpen{false};
174};
175
176} // namespace BIDSLIB
177
178#endif // BIDS_EDF_READER_H
Contains the declaration of the AbstractFormatReader class.
#define BIDSSHARED_EXPORT
Definition bids_global.h:55
BIDS dataset reading, writing, path construction, and sidecar metadata handling for iEEG/EEG/MEG.
Channel-level metadata from the EDF header.
FIFFLIB::FiffInfo getInfo() const override
Return measurement metadata as FiffInfo.
EDFReader(float fScaleFactor=1e6)
EDFReader Default constructor.
Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override
Read a segment of raw data.
bool open(const QString &sFilePath) override
Open and parse the file header. Must be called before reading data.
bool supportsExtension(const QString &sExtension) const override
Check whether this reader can handle the given file extension.
QVector< EDFChannelInfo > getAllChannelInfos() const
Return all channel infos (measurement + extra).
float getFrequency() const override
Return the sampling frequency in Hz.
FIFFLIB::FiffRawData toFiffRawData() const override
Convert the entire dataset to a FiffRawData structure.
QVector< EDFChannelInfo > getMeasurementChannelInfos() const
Return measurement channel infos only.
long getSampleCount() const override
Return total number of samples across the recording.
QString formatName() const override
Return a descriptive name for the format (e.g. "EDF", "BrainVision").
int getChannelCount() const override
Return the number of measurement channels.
Channel info descriptor.
FIFF measurement file information.
Definition fiff_info.h:86
FIFF raw measurement data.