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.

src/examples/ex_dsp_preprocessing/main.cpp
EpochExtractor::Params params;
params.dTmin = -0.1;
params.dTmax = 0.4;
params.dBaseMin = -0.1;
params.dBaseMax = 0.0;
const QVector<MNEEpochData> epochs = EpochExtractor::extract(raw, events, kSFreq, params, codes);
QVector<MNEEpochData> targets;
for (const MNEEpochData& epoch : epochs) {
if (epoch.event == 1) {
targets.append(epoch);
}
}
const MatrixXd evoked = EpochExtractor::average(EpochExtractor::rejectMarked(targets));

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.

Example​

Authors of this file​