FiffEpochs
Namespace: FIFFLIB · Library: FIFF Library
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.
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:
- QList< FiffEpochData > — List of epoch data structures.
concatenateEpochs(epochSets)
Concatenate multiple epoch sets into a single list.
Parameters:
- epochSets : const QList< QList< FiffEpochData > > & List of epoch sets to concatenate.
Returns:
- QList< FiffEpochData > — Combined list of all epochs.
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:
- FiffEvoked —
FiffEvokedwith averaged data and metadata.
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:
- epochs : const QList< FiffEpochData > & List of epoch data.
Returns:
- QList< Eigen::MatrixXd > — List of data matrices (n_channels × n_times).
Example
- Full source:
src/examples/ex_fiff_structure/main.cpp - Build target:
ex_fiff_structure(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_fiff_structure
FIFF library: fixed-length epochs, CTF compensation, the file directory and raw buffers, and handing.
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
- Christoph Dinh <christoph.dinh@mne-cpp.org>