Skip to main content

EpochExtractor

Namespace: UTILSLIB  ·  Library: Utilities Library

#include <utils/epoch_extractor.h>

class UTILSLIB::EpochExtractor

Segments continuous raw data into fixed-length epochs locked to events.

EpochExtractor::Params p;
p.dTmin = -0.2; // 200 ms pre-stimulus
p.dTmax = 0.8; // 800 ms post-stimulus
p.dBaseMin = -0.2;
p.dBaseMax = 0.0;
p.dThreshold = 150e-6; // 150 µV peak-to-peak rejection

QVector<MNELIB::MNEEpochData> epochs =
EpochExtractor::extract(matRawData, eventSamples, sFreq, p);

// Good epochs only
QVector<MNELIB::MNEEpochData> clean =
EpochExtractor::rejectMarked(epochs);

Static Methods

extract(matData, eventSamples, dSFreq, params, eventCodes)

Extract epochs from a continuous raw data matrix.

For each event sample index the function: Cuts a window [tmin, tmax] around the event.

Applies mean baseline correction over [baseMin, baseMax] (if bApplyBaseline and the window is valid).

Marks the epoch for rejection if any channel has peak-to-peak > dThreshold (and dThreshold > 0).

Epochs whose window extends outside the data boundaries are silently skipped.

Parameters:

  • matData : const Eigen::MatrixXd & Continuous raw data (n_channels × n_samples), calibrated (SI units).

  • eventSamples : const QVector< int > & 0-based sample indices of events.

  • dSFreq : double Sampling frequency in Hz.

  • params : const Params & Extraction parameters.

  • eventCodes : const QVector< int > & Optional per-event integer codes stored in MNEEpochData::event. Must be empty or the same length as eventSamples.

Returns:

  • QVector< MNEEpochData > — Vector of MNEEpochData (one per valid event). Rejected epochs are included with MNEEpochData::bReject == true so callers can choose whether to exclude them.

average(epochs)

Compute the grand average (ERP/ERF) across all non-rejected epochs.

Parameters:

  • epochs : const QVector< MNEEpochData > & Vector of extracted epochs (output of extract()).

Returns:

  • Eigen::MatrixXd — Mean data matrix (n_channels × n_epoch_samples), or empty matrix if no good epochs.

rejectMarked(epochs)

Return only the epochs that are NOT marked for rejection.

Parameters:

  • epochs : const QVector< MNEEpochData > & Input epoch vector.

Returns:

  • QVector< MNEEpochData > — Subset of epochs with bReject == false.

Authors of this file