v2.0.0
Loading...
Searching...
No Matches
bids_edf_reader.h
Go to the documentation of this file.
1//=============================================================================================================
33
34#ifndef BIDS_EDF_READER_H
35#define BIDS_EDF_READER_H
36
37//=============================================================================================================
38// INCLUDES
39//=============================================================================================================
40
42
43//=============================================================================================================
44// QT INCLUDES
45//=============================================================================================================
46
47#include <QDateTime>
48#include <QVector>
49#include <QFile>
50
51//=============================================================================================================
52// DEFINE NAMESPACE BIDSLIB
53//=============================================================================================================
54
55namespace BIDSLIB
56{
57
58//=============================================================================================================
65{
67 QString label;
70 QString prefiltering;
71 float physicalMin{0.0f};
72 float physicalMax{0.0f};
73 long digitalMin{0};
74 long digitalMax{0};
76 long sampleCount{0};
77 float frequency{0.0f};
78 bool isMeasurement{false};
79
80 FIFFLIB::FiffChInfo toFiffChInfo() const;
81
83 float toSi() const;
84};
85
86//=============================================================================================================
97{
98public:
99 //=========================================================================================================
103 EDFReader();
104
105 ~EDFReader() override;
106
107 // AbstractFormatReader interface
108 bool open(const QString& sFilePath) override;
109 FIFFLIB::FiffInfo getInfo() const override;
110 Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override;
111 long getSampleCount() const override;
112 float getFrequency() const override;
113 int getChannelCount() const override;
114 FIFFLIB::FiffRawData toFiffRawData() const override;
115 QString formatName() const override;
116 bool supportsExtension(const QString& sExtension) const override;
117
118 //=========================================================================================================
124 QVector<EDFChannelInfo> getAllChannelInfos() const;
125
126 //=========================================================================================================
132 QVector<EDFChannelInfo> getMeasurementChannelInfos() const;
133
134private:
135 // EDF header field byte lengths
136 enum EDFHeaderFieldLengths
137 {
138 EDF_VERSION = 8,
139 LOCAL_PATIENT_INFO = 80,
140 LOCAL_RECORD_INFO = 80,
141 STARTDATE = 8,
142 STARTTIME = 8,
143 NUM_BYTES_HEADER = 8,
144 HEADER_RESERVED = 44,
145 NUM_DATA_RECORDS = 8,
146 DURATION_DATA_RECS = 8,
147 NUM_SIGNALS = 4,
148 SIG_LABEL = 16,
149 SIG_TRANSDUCER = 80,
150 SIG_PHYS_DIM = 8,
151 SIG_PHYS_MIN = 8,
152 SIG_PHYS_MAX = 8,
153 SIG_DIG_MIN = 8,
154 SIG_DIG_MAX = 8,
155 SIG_PREFILTERING = 80,
156 SIG_NUM_SAMPLES = 8,
157 SIG_RESERVED = 32,
158 };
159
160 void parseHeader(QIODevice* pDev);
161
162 QString m_sFilePath;
163
164 // Header data
165 QString m_sVersionNo;
166 QString m_sPatientId;
167 QString m_sRecordingId;
168 QDateTime m_startDateTime;
169 int m_iNumBytesInHeader{0};
170 int m_iNumDataRecords{0};
171 float m_fDataRecordsDuration{0.0f};
172 int m_iNumChannels{0};
173 int m_iNumBytesPerDataRecord{0};
174
175 QVector<EDFChannelInfo> m_vAllChannels;
176 QVector<EDFChannelInfo> m_vMeasChannels;
177
178 mutable QFile m_file;
179 bool m_bIsOpen{false};
180 int m_iBytesPerSample{2}; // 3 for BDF
181};
182
183} // namespace BIDSLIB
184
185#endif // BIDS_EDF_READER_H
Strategy interface for format-specific raw-data readers (BrainVision, EDF, …) consumed by BIDSLIB::Bi...
#define BIDSSHARED_EXPORT
Definition bids_global.h:43
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.
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.
EDFReader()
EDFReader Default constructor.
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.
Per-channel FIFF descriptor: identifiers, kind, calibration, coil type, channel-frame coil position a...
Full FIFF measurement info: per-channel descriptors, sampling and filter setup, projectors,...
Definition fiff_info.h:90
Continuous FIFF raw recording: FiffInfo plus a random-access directory of FIFF_DATA_BUFFER tags.