v2.0.0
Loading...
Searching...
No Matches
channeldatamodel.h
Go to the documentation of this file.
1//=============================================================================================================
22
23#ifndef CHANNELDATAMODEL_H
24#define CHANNELDATAMODEL_H
25
26//=============================================================================================================
27// INCLUDES
28//=============================================================================================================
29
30#include "../../disp_global.h"
31
32//=============================================================================================================
33// QT INCLUDES
34//=============================================================================================================
35
36#include <QObject>
37#include <QColor>
38#include <QMap>
39#include <QVector>
40#include <QReadWriteLock>
41#include <QSharedPointer>
42
43//=============================================================================================================
44// EIGEN INCLUDES
45//=============================================================================================================
46
47#include <Eigen/Core>
48
49//=============================================================================================================
50// FORWARD DECLARATIONS
51//=============================================================================================================
52
53namespace FIFFLIB
54{
55class FiffInfo;
56}
57
58//=============================================================================================================
59// DEFINE NAMESPACE DISPLIB
60//=============================================================================================================
61
62namespace DISPLIB
63{
64
65//=============================================================================================================
69enum class DetrendMode
70{
71 None = 0,
72 Mean = 1,
73 Linear = 2
74};
75
76//=============================================================================================================
81{
82 QString name;
83 QString typeLabel;
84 QColor color;
86 bool bad;
87 bool isVirtualChannel = false;
88};
89
90//=============================================================================================================
101{
102 Q_OBJECT
103
104public:
105 typedef QSharedPointer<ChannelDataModel> SPtr;
106 typedef QSharedPointer<const ChannelDataModel> ConstSPtr;
107
108 explicit ChannelDataModel(QObject* parent = nullptr);
109
110 //=========================================================================================================
116 void init(QSharedPointer<FIFFLIB::FiffInfo> pFiffInfo);
117
118 //=========================================================================================================
126 void setData(const Eigen::MatrixXd& data, int firstSample = 0);
127
128 //=========================================================================================================
135 void appendData(const Eigen::MatrixXd& data);
136
137 //=========================================================================================================
144 void setScaleMap(const QMap<qint32, float>& scaleMap);
145
146 //=============================================================================================================
152 void setScaleMapFromStrings(const QMap<QString, double>& scaleMap);
153
154 //=============================================================================================================
160 void clearData();
161
162 //=========================================================================================================
168 void setVirtualChannels(const QVector<ChannelDisplayInfo>& virtualChannels);
169
170 //=========================================================================================================
177 void setSignalColor(const QColor& color);
178
179 //=========================================================================================================
187 void setMaxStoredSamples(int n);
188
189 //=========================================================================================================
196 void setChannelBad(int channelIdx, bool bad);
197
198 //=========================================================================================================
205 void setRemoveDC(bool remove);
206 bool removeDC() const
207 {
208 return m_detrendMode != DetrendMode::None;
209 }
210
211 void setDetrendMode(DetrendMode mode);
213 {
214 return m_detrendMode;
215 }
216
217 // ── Accessors (all thread-safe read) ──────────────────────────────
218
219 int channelCount() const;
220 int firstSample() const;
221 int totalSamples() const;
225 float sfreq() const;
226
227 //=========================================================================================================
234 ChannelDisplayInfo channelInfo(int channelIdx) const;
235
236 //=========================================================================================================
247 float channelRms(int channelIdx, int firstSample, int lastSample) const;
248
249 //=========================================================================================================
266 QVector<float> decimatedVertices(int channelIdx,
267 int firstSample,
268 int lastSample,
269 int pixelWidth,
270 int& vboFirstSample) const;
271
272 //=========================================================================================================
281 float sampleValueAt(int channelIdx, int sample) const;
282
283signals:
284 //=========================================================================================================
289
290 //=========================================================================================================
295
296private:
297 void rebuildDisplayInfo();
298 float amplitudeMaxForChannel(int ch) const;
299 QColor colorForChannel(int ch) const;
300 QString typeLabelForChannel(int ch) const;
301
302 mutable QReadWriteLock m_lock;
303
304 QSharedPointer<FIFFLIB::FiffInfo> m_pFiffInfo;
305 QVector<QVector<float>> m_channelData; // [ch][sample]
306 int m_firstSample = 0;
307 int m_maxStoredSamples = 0; // 0 = unlimited
308
309 QMap<qint32, float> m_scaleMap;
310 QColor m_signalColor{Qt::darkGreen};
311
312 QVector<ChannelDisplayInfo> m_virtualDisplayInfo;
313 QVector<ChannelDisplayInfo> m_displayInfo; // pre-computed, rebuild on meta change
314 DetrendMode m_detrendMode = DetrendMode::None;
315};
316
317} // namespace DISPLIB
318
319#endif // CHANNELDATAMODEL_H
Export macros and build-info hooks for the DISPLIB shared library.
#define DISPSHARED_EXPORT
Definition disp_global.h:38
FIFF file I/O, in-memory data structures and high-level readers/writers.
2-D display widgets and visualisation helpers (charts, topography, colour maps).
DetrendMode
Channel display metadata (read-only from the renderer's perspective).
Channel display metadata (read-only from the renderer's perspective).
void appendData(const Eigen::MatrixXd &data)
DetrendMode detrendMode() const
void setScaleMap(const QMap< qint32, float > &scaleMap)
void setScaleMapFromStrings(const QMap< QString, double > &scaleMap)
void setVirtualChannels(const QVector< ChannelDisplayInfo > &virtualChannels)
void setChannelBad(int channelIdx, bool bad)
void init(QSharedPointer< FIFFLIB::FiffInfo > pFiffInfo)
void setSignalColor(const QColor &color)
void setData(const Eigen::MatrixXd &data, int firstSample=0)
ChannelDataModel(QObject *parent=nullptr)
QSharedPointer< ChannelDataModel > SPtr
QSharedPointer< const ChannelDataModel > ConstSPtr
Full FIFF measurement info: per-channel descriptors, sampling and filter setup, projectors,...
Definition fiff_info.h:90