Skip to main content

FiffEpochs

Namespace: FIFFLIB  ·  Library: FIFF Library

Python equivalent

mne.Epochs in MNE-Python.

#include <fiff/fiff_epochs.h>

class FIFFLIB::FiffEpochs

Static helpers that cut continuous data into fixed-length epochs, concatenate and average them.

Stateless; operates on data matrices. Counterpart of mne.make_fixed_length_epochs and mne.concatenate_epochs in MNE-Python.

src/examples/ex_fiff_structure/main.cpp
QFile rawFile(rawPath);
FiffRawData raw(rawFile);
MatrixXd data;
MatrixXd times;
ok &= raw.read_raw_segment(data, times); // all 6007 samples
const double sfreq = raw.info.sfreq;
const QList<FiffEpochData> epochs = FiffEpochs::makeFixedLengthEpochs(data, sfreq, 2.0, 0.5); // 2 s, 0.5 s overlap
const FiffEvoked average = FiffEpochs::averageEpochs(epochs, sfreq);

Static Methods​

makeFixedLengthEpochs(matData, dSFreq, dDuration, dOverlap, bDropLast)​

Create fixed-length epochs from continuous data.

Segments the data matrix into non-overlapping (or overlapping) epochs of the specified duration.

Parameters:

  • matData : const Eigen::MatrixXd & Continuous data (n_channels × n_times).

  • dSFreq : double Sampling frequency in Hz.

  • dDuration : double Epoch duration in seconds.

  • dOverlap : double Overlap between epochs in seconds (default 0.0).

  • bDropLast : bool Drop the last epoch if it's shorter than duration (default true).

Returns:


concatenateEpochs(epochSets)​

Concatenate multiple epoch sets into a single list.

Parameters:

  • epochSets : const QList< QList< FiffEpochData > > & List of epoch sets to concatenate.

Returns:


averageEpochs(epochs, dSFreq, comment)​

Compute the average (evoked response) across epochs.

All epochs must have the same dimensions. Returns a FiffEvoked with data, nave, times, and aspect_kind populated.

Parameters:

  • epochs : const QList< FiffEpochData > & List of epochs.

  • dSFreq : double Sampling frequency in Hz (used to compute times vector).

  • comment : const QString & Comment string for the evoked (default "Average").

Returns:


toMatrixList(epochs)​

Extract data matrices from epoch structures.

Convenience method to get a list of data matrices from epoch structures, suitable for use with CSP, SPoC, SSD, etc.

Parameters:

Returns:

  • QList< Eigen::MatrixXd > — List of data matrices (n_channels × n_times).

Example​

Used in examples​

ex_fiff_structure​

FIFF library: fixed-length epochs, CTF compensation, the file directory and raw buffers, and handing.

src/examples/ex_fiff_structure/main.cpp, line 98
MatrixXd times;
ok &= raw.read_raw_segment(data, times); // all 6007 samples
const double sfreq = raw.info.sfreq;
const QList<FiffEpochData> epochs = FiffEpochs::makeFixedLengthEpochs(data, sfreq, 2.0, 0.5); // 2 s, 0.5 s overlap
const FiffEvoked average = FiffEpochs::averageEpochs(epochs, sfreq);
// mne.make_fixed_length_epochs(raw, duration=2, overlap=0.5): 13 epochs of 601 samples, 450 samples apart
ok &= expect(epochs.size() == 13 && epochs[0].data.cols() == 601 && std::lround((epochs[1].tmin - epochs[0].tmin) * sfreq) == 450 && average.nave == 13,
"FiffEpochs/FiffEpochData: 13 fixed-length epochs like mne.make_fixed_length_epochs, averaged over 13");

Authors of this file​