v2.0.0
Loading...
Searching...
No Matches
DISPLIB::ChannelDataModel Class Reference

Circular-buffer Qt model exposing a rolling window of the live FIFF stream as a table. More...

#include <channeldatamodel.h>

Public Types

typedef QSharedPointer< ChannelDataModelSPtr
typedef QSharedPointer< const ChannelDataModelConstSPtr

Signals

void dataChanged ()
void metaChanged ()

Public Member Functions

 ChannelDataModel (QObject *parent=nullptr)
void init (QSharedPointer< FIFFLIB::FiffInfo > pFiffInfo)
void setData (const Eigen::MatrixXd &data, int firstSample=0)
void appendData (const Eigen::MatrixXd &data)
void clearData ()
void setScaleMap (const QMap< qint32, float > &scaleMap)
void setScaleMapFromStrings (const QMap< QString, double > &scaleMap)
void setVirtualChannels (const QVector< ChannelDisplayInfo > &virtualChannels)
void setSignalColor (const QColor &color)
void setMaxStoredSamples (int n)
void setChannelBad (int channelIdx, bool bad)
void setRemoveDC (bool remove)
bool removeDC () const
void setDetrendMode (DetrendMode mode)
DetrendMode detrendMode () const
int channelCount () const
int firstSample () const
int totalSamples () const
float sfreq () const
ChannelDisplayInfo channelInfo (int channelIdx) const
float channelRms (int channelIdx, int firstSample, int lastSample) const
QVector< float > decimatedVertices (int channelIdx, int firstSample, int lastSample, int pixelWidth, int &vboFirstSample) const
float sampleValueAt (int channelIdx, int sample) const

Detailed Description

Circular-buffer Qt model exposing a rolling window of the live FIFF stream as a table.

Keeps a per-channel Eigen::MatrixXd ring buffer of the most recent N seconds, tracks bad-channel flags, trigger annotations and the active SSP / compensation / filter operators so the delegate can render the pre-processed signal without touching the raw buffer.

Definition at line 97 of file channeldatamodel.h.

Inheritance diagram for DISPLIB::ChannelDataModel:
Inheritance graph

Member Typedef Documentation

◆ ConstSPtr

Definition at line 103 of file channeldatamodel.h.

◆ SPtr

Definition at line 102 of file channeldatamodel.h.

Constructor & Destructor Documentation

◆ ChannelDataModel()

ChannelDataModel::ChannelDataModel ( QObject * parent = nullptr)
explicit

Definition at line 63 of file channeldatamodel.cpp.

Member Function Documentation

◆ appendData()

void ChannelDataModel::appendData ( const Eigen::MatrixXd & data)

Append new samples to the ring buffer. Oldest samples are dropped when the internal capacity (maxStoredSamples) is exceeded.

Parameters
[in]dataChannels × newSamples matrix.

Definition at line 117 of file channeldatamodel.cpp.

◆ channelCount()

int ChannelDataModel::channelCount ( ) const

Definition at line 280 of file channeldatamodel.cpp.

◆ channelInfo()

ChannelDisplayInfo ChannelDataModel::channelInfo ( int channelIdx) const

Display metadata for the given channel.

Parameters
[in]channelIdxZero-based channel index.
Returns
ChannelDisplayInfo struct with name, colour, amplitudeMax, bad flag.

Definition at line 305 of file channeldatamodel.cpp.

◆ channelRms()

float ChannelDataModel::channelRms ( int channelIdx,
int firstSample,
int lastSample ) const

Compute the RMS amplitude of a channel over a sample window. Samples outside the buffer are silently ignored. Capped internally at 1000 samples for rendering-thread safety.

Parameters
[in]channelIdxZero-based channel index.
[in]firstSampleAbsolute first sample (inclusive).
[in]lastSampleAbsolute last sample (exclusive).
Returns
RMS in raw (physical) units, or 0 if no data is available.

Definition at line 315 of file channeldatamodel.cpp.

◆ clearData()

void ChannelDataModel::clearData ( )

Override the per-channel-type amplitude scale. Key = FIFF channel kind constant (e.g. FIFFV_MEG_CH), value = physical amplitude.

Parameters
[in]scaleMapMap from FIFF kind to amplitude max. Clear all stored sample data without affecting channel metadata. After this call totalSamples() == 0 and firstSample() == 0. Emits dataChanged().

Definition at line 151 of file channeldatamodel.cpp.

◆ dataChanged

void DISPLIB::ChannelDataModel::dataChanged ( )
signal

Emitted whenever stored data changes (new data appended or replaced).

◆ decimatedVertices()

QVector< float > ChannelDataModel::decimatedVertices ( int channelIdx,
int firstSample,
int lastSample,
int pixelWidth,
int & vboFirstSample ) const

Return a flat float array ready for VBO upload. The array contains interleaved (x_offset, y_amplitude) pairs.

When samplesPerPixel <= 1 (zoomed in), raw samples are returned. When samplesPerPixel > 1 (zoomed out), min/max decimation is applied so that at most 2 * pixelWidth vertices are returned.

Parameters
[in]channelIdxZero-based channel index.
[in]firstSampleAbsolute sample index of the first desired sample.
[in]lastSampleAbsolute sample index (exclusive) of the last desired sample.
[in]pixelWidthDestination viewport width in pixels.
[out]vboFirstSampleThe absolute sample index stored at VBO vertex 0 (= firstSample, returned for the UBO uniform).
Returns
Flat float array: [x0, y0, x1, y1, ...] where x is offset from vboFirstSample.

Definition at line 351 of file channeldatamodel.cpp.

◆ detrendMode()

DetrendMode DISPLIB::ChannelDataModel::detrendMode ( ) const
inline

Definition at line 199 of file channeldatamodel.h.

◆ firstSample()

int ChannelDataModel::firstSample ( ) const

Definition at line 289 of file channeldatamodel.cpp.

◆ init()

void ChannelDataModel::init ( QSharedPointer< FIFFLIB::FiffInfo > pFiffInfo)

Initialise with channel metadata from a FiffInfo.

Parameters
[in]pFiffInfoThe FiffInfo describing the channels.

Definition at line 78 of file channeldatamodel.cpp.

◆ metaChanged

void DISPLIB::ChannelDataModel::metaChanged ( )
signal

Emitted when channel metadata (scale, colour, bad-flag) changes.

◆ removeDC()

bool DISPLIB::ChannelDataModel::removeDC ( ) const
inline

Definition at line 196 of file channeldatamodel.h.

◆ sampleValueAt()

float ChannelDataModel::sampleValueAt ( int channelIdx,
int sample ) const

Return the raw sample value at a specific absolute sample index for the given channel. Returns 0 if the sample is outside the buffer or channel index is out of range.

Parameters
[in]channelIdxZero-based channel index.
[in]sampleAbsolute sample index.
Returns
Sample value in physical units, or 0 if unavailable.

Definition at line 337 of file channeldatamodel.cpp.

◆ setChannelBad()

void ChannelDataModel::setChannelBad ( int channelIdx,
bool bad )

Mark/unmark a channel as bad.

Parameters
[in]channelIdxZero-based channel index.
[in]badTrue to mark bad.

Definition at line 256 of file channeldatamodel.cpp.

◆ setData()

void ChannelDataModel::setData ( const Eigen::MatrixXd & data,
int firstSample = 0 )

Replace all stored data with the provided matrix (channels × samples). The absolute index of the first column is firstSample.

Parameters
[in]dataChannels × samples matrix (double precision).
[in]firstSampleAbsolute sample index of column 0.

Definition at line 96 of file channeldatamodel.cpp.

◆ setDetrendMode()

void ChannelDataModel::setDetrendMode ( DetrendMode mode)

Definition at line 245 of file channeldatamodel.cpp.

◆ setMaxStoredSamples()

void ChannelDataModel::setMaxStoredSamples ( int n)

Set the maximum number of samples to keep in the ring buffer. When samples are appended beyond this limit, the oldest are dropped. Set to 0 (default) for unlimited storage.

Parameters
[in]nMaximum sample count per channel, or 0 for unlimited.

Definition at line 230 of file channeldatamodel.cpp.

◆ setRemoveDC()

void ChannelDataModel::setRemoveDC ( bool remove)

Enable or disable DC (mean) removal applied on-the-fly during rendering. When enabled each channel's mean amplitude over the requested window is subtracted.

Parameters
[in]removetrue = subtract mean, false = raw data.

Definition at line 238 of file channeldatamodel.cpp.

◆ setScaleMap()

void ChannelDataModel::setScaleMap ( const QMap< qint32, float > & scaleMap)

Definition at line 164 of file channeldatamodel.cpp.

◆ setScaleMapFromStrings()

void ChannelDataModel::setScaleMapFromStrings ( const QMap< QString, double > & scaleMap)

Definition at line 176 of file channeldatamodel.cpp.

◆ setSignalColor()

void ChannelDataModel::setSignalColor ( const QColor & color)

Set the signal line colour for all channels. Individual channel colours are derived from this base colour by type.

Parameters
[in]colorThe base signal colour.

Definition at line 218 of file channeldatamodel.cpp.

◆ setVirtualChannels()

void ChannelDataModel::setVirtualChannels ( const QVector< ChannelDisplayInfo > & virtualChannels)

Set extra browser-level virtual channels appended after the FIFF channels.

Parameters
[in]virtualChannelsDisplay metadata for each appended virtual channel.

Definition at line 200 of file channeldatamodel.cpp.

◆ sfreq()

float ChannelDataModel::sfreq ( ) const

Sampling frequency in Hz; 0 if no FiffInfo attached.

Definition at line 576 of file channeldatamodel.cpp.

◆ totalSamples()

int ChannelDataModel::totalSamples ( ) const

Definition at line 297 of file channeldatamodel.cpp.


The documentation for this class was generated from the following files: