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 class FiffInfo;
55}
56
57//=============================================================================================================
58// DEFINE NAMESPACE DISPLIB
59//=============================================================================================================
60
61namespace DISPLIB
62{
63
64//=============================================================================================================
68enum class DetrendMode {
69 None = 0,
70 Mean = 1,
71 Linear = 2
72};
73
74//=============================================================================================================
79 QString name;
80 QString typeLabel;
81 QColor color;
83 bool bad;
84 bool isVirtualChannel = false;
85};
86
87//=============================================================================================================
97class DISPSHARED_EXPORT ChannelDataModel : public QObject
98{
99 Q_OBJECT
100
101public:
102 typedef QSharedPointer<ChannelDataModel> SPtr;
103 typedef QSharedPointer<const ChannelDataModel> ConstSPtr;
104
105 explicit ChannelDataModel(QObject *parent = nullptr);
106
107 //=========================================================================================================
113 void init(QSharedPointer<FIFFLIB::FiffInfo> pFiffInfo);
114
115 //=========================================================================================================
123 void setData(const Eigen::MatrixXd &data, int firstSample = 0);
124
125 //=========================================================================================================
132 void appendData(const Eigen::MatrixXd &data);
133
134 //=========================================================================================================
141 //=========================================================================================================
147 void clearData();
148
149 void setScaleMap(const QMap<qint32, float> &scaleMap);
150 void setScaleMapFromStrings(const QMap<QString, double> &scaleMap);
151
152 //=========================================================================================================
158 void setVirtualChannels(const QVector<ChannelDisplayInfo> &virtualChannels);
159
160 //=========================================================================================================
167 void setSignalColor(const QColor &color);
168
169 //=========================================================================================================
177 void setMaxStoredSamples(int n);
178
179 //=========================================================================================================
186 void setChannelBad(int channelIdx, bool bad);
187
188 //=========================================================================================================
195 void setRemoveDC(bool remove);
196 bool removeDC() const { return m_detrendMode != DetrendMode::None; }
197
198 void setDetrendMode(DetrendMode mode);
199 DetrendMode detrendMode() const { return m_detrendMode; }
200
201 // ── Accessors (all thread-safe read) ──────────────────────────────
202
203 int channelCount() const;
204 int firstSample() const;
205 int totalSamples() const;
206 float sfreq() const;
207
208 //=========================================================================================================
215 ChannelDisplayInfo channelInfo(int channelIdx) const;
216
217 //=========================================================================================================
228 float channelRms(int channelIdx, int firstSample, int lastSample) const;
229
230 //=========================================================================================================
247 QVector<float> decimatedVertices(int channelIdx,
248 int firstSample,
249 int lastSample,
250 int pixelWidth,
251 int &vboFirstSample) const;
252
253 //=========================================================================================================
262 float sampleValueAt(int channelIdx, int sample) const;
263
264signals:
265 //=========================================================================================================
270
271 //=========================================================================================================
276
277private:
278 void rebuildDisplayInfo();
279 float amplitudeMaxForChannel(int ch) const;
280 QColor colorForChannel(int ch) const;
281 QString typeLabelForChannel(int ch) const;
282
283 mutable QReadWriteLock m_lock;
284
285 QSharedPointer<FIFFLIB::FiffInfo> m_pFiffInfo;
286 QVector<QVector<float>> m_channelData; // [ch][sample]
287 int m_firstSample = 0;
288 int m_maxStoredSamples = 0; // 0 = unlimited
289
290 QMap<qint32, float> m_scaleMap;
291 QColor m_signalColor { Qt::darkGreen };
292
293 QVector<ChannelDisplayInfo> m_virtualDisplayInfo;
294 QVector<ChannelDisplayInfo> m_displayInfo; // pre-computed, rebuild on meta change
295 DetrendMode m_detrendMode = DetrendMode::None;
296};
297
298} // namespace DISPLIB
299
300#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:88