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//=============================================================================================================
63{
65 QString label;
68 QString prefiltering;
69 float physicalMin{0.0f};
70 float physicalMax{0.0f};
71 long digitalMin{0};
72 long digitalMax{0};
74 long sampleCount{0};
75 float frequency{0.0f};
76 bool isMeasurement{false};
77
78 FIFFLIB::FiffChInfo toFiffChInfo() const;
79};
80
81//=============================================================================================================
90{
91public:
92 //=========================================================================================================
97 explicit EDFReader(float fScaleFactor = 1e6);
98
99 ~EDFReader() override;
100
101 // AbstractFormatReader interface
102 bool open(const QString& sFilePath) override;
103 FIFFLIB::FiffInfo getInfo() const override;
104 Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override;
105 long getSampleCount() const override;
106 float getFrequency() const override;
107 int getChannelCount() const override;
108 FIFFLIB::FiffRawData toFiffRawData() const override;
109 QString formatName() const override;
110 bool supportsExtension(const QString& sExtension) const override;
111
112 //=========================================================================================================
116 QVector<EDFChannelInfo> getAllChannelInfos() const;
117
118 //=========================================================================================================
122 QVector<EDFChannelInfo> getMeasurementChannelInfos() const;
123
124private:
125 // EDF header field byte lengths
126 enum EDFHeaderFieldLengths {
127 EDF_VERSION = 8,
128 LOCAL_PATIENT_INFO = 80,
129 LOCAL_RECORD_INFO = 80,
130 STARTDATE = 8,
131 STARTTIME = 8,
132 NUM_BYTES_HEADER = 8,
133 HEADER_RESERVED = 44,
134 NUM_DATA_RECORDS = 8,
135 DURATION_DATA_RECS = 8,
136 NUM_SIGNALS = 4,
137 SIG_LABEL = 16,
138 SIG_TRANSDUCER = 80,
139 SIG_PHYS_DIM = 8,
140 SIG_PHYS_MIN = 8,
141 SIG_PHYS_MAX = 8,
142 SIG_DIG_MIN = 8,
143 SIG_DIG_MAX = 8,
144 SIG_PREFILTERING = 80,
145 SIG_NUM_SAMPLES = 8,
146 SIG_RESERVED = 32,
147 };
148
149 void parseHeader(QIODevice* pDev);
150
151 float m_fScaleFactor;
152 QString m_sFilePath;
153
154 // Header data
155 QString m_sVersionNo;
156 QString m_sPatientId;
157 QString m_sRecordingId;
158 QDateTime m_startDateTime;
159 int m_iNumBytesInHeader{0};
160 int m_iNumDataRecords{0};
161 float m_fDataRecordsDuration{0.0f};
162 int m_iNumChannels{0};
163 int m_iNumBytesPerDataRecord{0};
164
165 QVector<EDFChannelInfo> m_vAllChannels;
166 QVector<EDFChannelInfo> m_vMeasChannels;
167
168 mutable QFile m_file;
169 bool m_bIsOpen{false};
170};
171
172} // namespace BIDSLIB
173
174#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.
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.
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:88