v2.0.0
Loading...
Searching...
No Matches
channeldatamodel.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef CHANNELDATAMODEL_H
36#define CHANNELDATAMODEL_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "../../disp_global.h"
43
44//=============================================================================================================
45// QT INCLUDES
46//=============================================================================================================
47
48#include <QObject>
49#include <QColor>
50#include <QMap>
51#include <QVector>
52#include <QReadWriteLock>
53#include <QSharedPointer>
54
55//=============================================================================================================
56// EIGEN INCLUDES
57//=============================================================================================================
58
59#include <Eigen/Core>
60
61//=============================================================================================================
62// FORWARD DECLARATIONS
63//=============================================================================================================
64
65namespace FIFFLIB {
66 class FiffInfo;
67}
68
69//=============================================================================================================
70// DEFINE NAMESPACE DISPLIB
71//=============================================================================================================
72
73namespace DISPLIB
74{
75
76//=============================================================================================================
80enum class DetrendMode {
81 None = 0,
82 Mean = 1,
83 Linear = 2
84};
85
86//=============================================================================================================
91 QString name;
92 QString typeLabel;
93 QColor color;
95 bool bad;
96 bool isVirtualChannel = false;
97};
98
99//=============================================================================================================
109{
110 Q_OBJECT
111
112public:
113 typedef QSharedPointer<ChannelDataModel> SPtr;
114 typedef QSharedPointer<const ChannelDataModel> ConstSPtr;
115
116 explicit ChannelDataModel(QObject *parent = nullptr);
117
118 //=========================================================================================================
124 void init(QSharedPointer<FIFFLIB::FiffInfo> pFiffInfo);
125
126 //=========================================================================================================
134 void setData(const Eigen::MatrixXd &data, int firstSample = 0);
135
136 //=========================================================================================================
143 void appendData(const Eigen::MatrixXd &data);
144
145 //=========================================================================================================
152 //=========================================================================================================
158 void clearData();
159
160 void setScaleMap(const QMap<qint32, float> &scaleMap);
161 void setScaleMapFromStrings(const QMap<QString, double> &scaleMap);
162
163 //=========================================================================================================
169 void setVirtualChannels(const QVector<ChannelDisplayInfo> &virtualChannels);
170
171 //=========================================================================================================
178 void setSignalColor(const QColor &color);
179
180 //=========================================================================================================
188 void setMaxStoredSamples(int n);
189
190 //=========================================================================================================
197 void setChannelBad(int channelIdx, bool bad);
198
199 //=========================================================================================================
206 void setRemoveDC(bool remove);
207 bool removeDC() const { return m_detrendMode != DetrendMode::None; }
208
209 void setDetrendMode(DetrendMode mode);
210 DetrendMode detrendMode() const { return m_detrendMode; }
211
212 // ── Accessors (all thread-safe read) ──────────────────────────────
213
214 int channelCount() const;
215 int firstSample() const;
216 int totalSamples() const;
217 float sfreq() const;
218
219 //=========================================================================================================
226 ChannelDisplayInfo channelInfo(int channelIdx) const;
227
228 //=========================================================================================================
239 float channelRms(int channelIdx, int firstSample, int lastSample) const;
240
241 //=========================================================================================================
258 QVector<float> decimatedVertices(int channelIdx,
259 int firstSample,
260 int lastSample,
261 int pixelWidth,
262 int &vboFirstSample) const;
263
264 //=========================================================================================================
273 float sampleValueAt(int channelIdx, int sample) const;
274
275signals:
276 //=========================================================================================================
281
282 //=========================================================================================================
287
288private:
289 void rebuildDisplayInfo();
290 float amplitudeMaxForChannel(int ch) const;
291 QColor colorForChannel(int ch) const;
292 QString typeLabelForChannel(int ch) const;
293
294 mutable QReadWriteLock m_lock;
295
296 QSharedPointer<FIFFLIB::FiffInfo> m_pFiffInfo;
297 QVector<QVector<float>> m_channelData; // [ch][sample]
298 int m_firstSample = 0;
299 int m_maxStoredSamples = 0; // 0 = unlimited
300
301 QMap<qint32, float> m_scaleMap;
302 QColor m_signalColor { Qt::darkGreen };
303
304 QVector<ChannelDisplayInfo> m_virtualDisplayInfo;
305 QVector<ChannelDisplayInfo> m_displayInfo; // pre-computed, rebuild on meta change
306 DetrendMode m_detrendMode = DetrendMode::None;
307};
308
309} // namespace DISPLIB
310
311#endif // CHANNELDATAMODEL_H
disp library export/import macros.
#define DISPSHARED_EXPORT
Definition disp_global.h:51
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
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
FIFF measurement file information.
Definition fiff_info.h:86