v2.0.0
Loading...
Searching...
No Matches
bids_brain_vision_reader.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef BIDS_BRAIN_VISION_READER_H
36#define BIDS_BRAIN_VISION_READER_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
43
44//=============================================================================================================
45// QT INCLUDES
46//=============================================================================================================
47
48#include <QDateTime>
49#include <QVector>
50#include <QFile>
51#include <QMap>
52
53//=============================================================================================================
54// DEFINE NAMESPACE BIDSLIB
55//=============================================================================================================
56
57namespace BIDSLIB
58{
59
60//=============================================================================================================
65{
66 QString type;
67 QString description;
68 long position{0};
69 long duration{0};
70 int channel{0};
71 QDateTime date;
72};
73
74//=============================================================================================================
79{
81 QString name;
82 QString reference;
83 float resolution{1.0f};
84 QString unit;
85
87};
88
89//=============================================================================================================
98
99//=============================================================================================================
107
108//=============================================================================================================
118{
119public:
120 //=========================================================================================================
125
126 ~BrainVisionReader() override;
127
128 // AbstractFormatReader interface
129 bool open(const QString& sFilePath) override;
130 FIFFLIB::FiffInfo getInfo() const override;
131 Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override;
132 long getSampleCount() const override;
133 float getFrequency() const override;
134 int getChannelCount() const override;
135 FIFFLIB::FiffRawData toFiffRawData() const override;
136 QString formatName() const override;
137 bool supportsExtension(const QString& sExtension) const override;
138
139 //=========================================================================================================
143 QVector<BrainVisionMarker> getMarkers() const;
144
145 //=========================================================================================================
149 QVector<BrainVisionChannelInfo> getChannelInfos() const;
150
151 // Unit to scaling factor (relative to V)
152 static float unitScale(const QString& sUnit);
153
154private:
155 bool parseHeader(const QString& sVhdrPath);
156 bool parseMarkers(const QString& sVmrkPath);
157 void computeSampleCount();
158
159 QString m_sVhdrPath;
160 QString m_sDataPath;
161 QString m_sMarkerPath;
162
163 // Header fields
164 float m_fSFreq{0.0f};
165 int m_iNumChannels{0};
168 long m_lSampleCount{0};
169
170 QVector<BrainVisionChannelInfo> m_vChannels;
171 QVector<BrainVisionMarker> m_vMarkers;
172
173 mutable QFile m_dataFile;
174 bool m_bIsOpen{false};
175};
176
177} // namespace BIDSLIB
178
179#endif // BIDS_BRAIN_VISION_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.
BVOrientation
Data orientation enumeration.
BVBinaryFormat
Binary format enumeration for BrainVision data files.
Marker entry from the .vmrk file.
Channel info from the .vhdr header.
FIFFLIB::FiffChInfo toFiffChInfo() const
FIFFLIB::FiffRawData toFiffRawData() const override
Convert the entire dataset to a FiffRawData structure.
long getSampleCount() const override
Return total number of samples across the recording.
Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override
Read a segment of raw data.
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.
bool supportsExtension(const QString &sExtension) const override
Check whether this reader can handle the given file extension.
QVector< BrainVisionChannelInfo > getChannelInfos() const
Return all channel infos.
float getFrequency() const override
Return the sampling frequency in Hz.
FIFFLIB::FiffInfo getInfo() const override
Return measurement metadata as FiffInfo.
bool open(const QString &sFilePath) override
Open and parse the file header. Must be called before reading data.
static float unitScale(const QString &sUnit)
QVector< BrainVisionMarker > getMarkers() const
Return all parsed markers from the .vmrk file.
Channel info descriptor.
FIFF measurement file information.
Definition fiff_info.h:86
FIFF raw measurement data.