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//=============================================================================================================
67{
68 QString type;
69 QString description;
70 long position{0};
71 long duration{0};
72 int channel{0};
73 QDateTime date;
74};
75
76//=============================================================================================================
83{
85 QString name;
86 QString reference;
87 float resolution{1.0f};
88 QString unit;
89
91};
92
93//=============================================================================================================
103
104//=============================================================================================================
113
114//=============================================================================================================
126{
127public:
128 //=========================================================================================================
133
134 ~BrainVisionReader() override;
135
136 // AbstractFormatReader interface
137 bool open(const QString& sFilePath) override;
138 FIFFLIB::FiffInfo getInfo() const override;
139 Eigen::MatrixXf readRawSegment(int iStartSampleIdx, int iEndSampleIdx) const override;
140 long getSampleCount() const override;
141 float getFrequency() const override;
142 int getChannelCount() const override;
143 FIFFLIB::FiffRawData toFiffRawData() const override;
144 QString formatName() const override;
145 bool supportsExtension(const QString& sExtension) const override;
146
147 //=========================================================================================================
153 QVector<BrainVisionMarker> getMarkers() const;
154
155 //=========================================================================================================
161 QVector<BrainVisionChannelInfo> getChannelInfos() const;
162
163 // Unit to scaling factor into SI (V for voltages, S for siemens); unknown units scale by 1, like mne
164 static float unitScale(const QString& sUnit);
165
166 // Whether the unit is a voltage (V, mV, µV, uV, nV); other channels are typed misc, like mne
167 static bool isVoltageUnit(const QString& sUnit);
168
169private:
170 bool parseHeader(const QString& sVhdrPath);
171 bool parseMarkers(const QString& sVmrkPath);
172 void computeSampleCount();
173
174 QString m_sVhdrPath;
175 QString m_sDataPath;
176 QString m_sMarkerPath;
177
178 // Header fields
179 float m_fSFreq{0.0f};
180 int m_iNumChannels{0};
183 long m_lSampleCount{0};
184
185 QVector<BrainVisionChannelInfo> m_vChannels;
186 QVector<BrainVisionMarker> m_vMarkers;
187
188 mutable QFile m_dataFile;
189 bool m_bIsOpen{false};
190};
191
192} // namespace BIDSLIB
193
194#endif // BIDS_BRAIN_VISION_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.
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.
static bool isVoltageUnit(const QString &sUnit)
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.
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.