Skip to main content

MNEEpochDataList

Namespace: MNELIB  ·  Library: MNE Library

#include <mne/mne_epoch_data_list.h>

class MNELIB::MNEEpochDataList

Epoch data list, which corresponds to a set of events.

Ordered list of MNEEpochData objects sharing a common measurement info.

src/examples/ex_mne_api/main.cpp
QFile rawFile(data + "/MEG/sample/sample_audvis_trunc_raw.fif");
const FiffRawData raw(rawFile);
FiffEvents events;
FiffEvents::detect_from_raw(raw, events); // rising edges on STI 014
// Epochs of event 1 from -100 to 300 ms, no rejection
MNEEpochDataList epochs = MNEEpochDataList::readEpochs(raw, events.events, -0.1f, 0.3f, 1, {});
const MNEEpochData& firstEpoch = *epochs.first();
FiffEvoked evoked = epochs.average(raw.info, raw.first_samp, raw.last_samp);
src/examples/ex_mne_api/main.cpp
// Peak-to-peak rejection like mne.Epochs(reject=...): flagged epochs stay in the list with bReject set
const QMap<QString, double> reject{{"grad", 1.6e-14}, {"eeg", 1.6e-8}};
MNEEpochDataList checked = MNEEpochDataList::readEpochs(raw, events.events, -0.1f, 0.3f, 1, reject);
QList<int> keptEpochs;
for (int i = 0; i < checked.size(); ++i) {
if (!checked.at(i)->bReject) {
keptEpochs << i;
}
}
const bool firstIsClean = !MNEEpochDataList::checkForArtifact(firstEpoch.epoch, raw.info, reject);

Inheritance​


Public Methods​

MNEEpochDataList()​

Default constructor.


~MNEEpochDataList()​

Destroys the MNEEpochDataList.


average(p_info, first, last, sel, proj)​

Averages epoch list.

Note that no baseline correction performed.

Parameters:

  • p_info : const FiffInfo & measurement info.

  • first : FIFFLIB::fiff_int_t First time sample.

  • last : FIFFLIB::fiff_int_t Last time sample.

  • sel : Eigen::VectorXi Which epochs should be averaged (optional).

  • proj : bool Apply SSP projection vectors (optional, default = false).

Returns:

  • FiffEvoked — Averaged evoked response; aspect_kind is FIFFV_ASPECT_STD_ERR with no data if the list is empty.

applyBaselineCorrection(baseline)​

Applies baseline correction to the evoked data.

Parameters:

  • baseline : const QPair< float, float > & time definition of the baseline in seconds [from, to].

dropRejected()​

Drop/Remove all epochs tagged as rejected.


pick_channels(sel)​

Reduces alld epochs to the selected rows.

Parameters:

  • sel : const Eigen::RowVectorXi & The selected rows to keep.

Static Methods​

readEpochs(raw, events, tmin, tmax, event, mapReject, lExcludeChs, picks)​

Read the epochs from a raw file based on provided events.

Parameters:

  • raw : const FiffRawData & The raw data.

  • events : const Eigen::MatrixXi & The events provided in samples and event kind.

  • tmin : float The start time relative to the event in seconds.

  • tmax : float The end time relative to the event in seconds.

  • event : qint32 The event kind.

  • mapReject : const QMap< QString, double > & Peak-to-peak rejection thresholds per channel type (e.g. "grad", "mag", "eeg").

  • lExcludeChs : const QStringList & List of channel names to exclude.

  • picks : const Eigen::RowVectorXi & Which channels to pick.

Returns:

  • MNEEpochDataList — List of epochs with rejection flags set; empty if no matching events are found.

checkForArtifact(data, pFiffInfo, mapReject, lExcludeChs)​

Checks the givven matrix for artifacts beyond a threshold value.

Parameters:

  • data : const Eigen::MatrixXd & The data matrix.

  • pFiffInfo : const FiffInfo & The fiff info.

  • mapReject : const QMap< QString, double > & The channel data types to scan for. EEG, MEG or EOG.

  • lExcludeChs : const QStringList & List of channel names to exclude.

Returns:

  • bool — Whether a threshold artifact was detected.

averageCategories(raw, events, eventCodes, comments, tmin, tmax, mapReject, baseline, proj)​

averageCategories

Multi-category offline averaging. Reads epochs from raw data for multiple event types and returns an FiffEvokedSet with one FiffEvoked per category. Ported from average.c (MNE-C).

Parameters:

  • raw : const FiffRawData & The raw data.

  • events : const Eigen::MatrixXi & Event matrix (nEvents x 3): [sample, before, after].

  • eventCodes : const QList< int > & List of event codes, one per category.

  • comments : const QStringList & List of category names/comments, one per category.

  • tmin : float Start of epoch relative to event (seconds).

  • tmax : float End of epoch relative to event (seconds).

  • mapReject : const QMap< QString, double > & Rejection thresholds (key = channel type string, value = threshold).

  • baseline : const QPair< float, float > & Baseline interval [from, to] in seconds. If from==to, no baseline correction.

  • proj : bool Apply SSP projection vectors (optional, default = false).

Returns:

  • FiffEvokedSet — FiffEvokedSet containing one FiffEvoked per category.

computeAverage(raw, matEvents, fTMinS, fTMaxS, eventType, bApplyBaseline, fTBaselineFromS, fTBaselineToS, mapReject, lExcludeChs, vecPicks)​

Convenience function: reads epochs, optionally applies baseline correction and artifact rejection, then returns the averaged evoked response.

Parameters:

  • raw : const FiffRawData & The raw data.

  • matEvents : const Eigen::MatrixXi & The events provided in samples and event kinds.

  • fTMinS : float The start time relative to the event in seconds.

  • fTMaxS : float The end time relative to the event in seconds.

  • eventType : qint32 The event type.

  • bApplyBaseline : bool Whether to use baseline correction (mode=mean).

  • fTBaselineFromS : float The start baseline correction time relative to the event in seconds.

  • fTBaselineToS : float The end baseline correction time relative to the event in seconds.

  • mapReject : const QMap< QString, double > & The thresholds per channel type to reject epochs.

  • lExcludeChs : const QStringList & List of channel names to exclude.

  • vecPicks : const Eigen::RowVectorXi & Which channels to pick.

Returns:


Example​

Used in examples​

ex_mne_api​

MNE library: BEM surfaces, surface projection, ICP, source spaces and epochs.

src/examples/ex_mne_api/main.cpp, line 234
FiffEvents events;
FiffEvents::detect_from_raw(raw, events); // rising edges on STI 014
// Epochs of event 1 from -100 to 300 ms, no rejection
MNEEpochDataList epochs = MNEEpochDataList::readEpochs(raw, events.events, -0.1f, 0.3f, 1, {});
const MNEEpochData& firstEpoch = *epochs.first();
FiffEvoked evoked = epochs.average(raw.info, raw.first_samp, raw.last_samp);
// mne.Epochs(event_id=1, tmin=-0.1, tmax=0.3, baseline=None, proj=False): 6 epochs of 376 x 121, MEG 0113 first sample -7.5857e-15
ok &= expect(epochs.size() == 6 && firstEpoch.eventSample == 14385 && firstEpoch.epoch.rows() == 376 && firstEpoch.epoch.cols() == 121 && near(firstEpoch.epoch(0, 0), -7.585747577225703e-15, 1e-6) && near(firstEpoch.epoch.topRows(306).norm(), 7.05600718833613e-13, 1e-6),
"MNEEpochDataList/MNEEpochData: 6 epochs of event 1 match mne.Epochs");
// mne Epochs.average(): |MEG| = 6.0801e-13 over 6 epochs, times from -99.898 to 299.693 ms with 0 at sample 30
ok &= expect(evoked.nave == 6 && near(evoked.data.topRows(306).norm(), 6.080119131626428e-13, 1e-6) && evoked.times.size() == 121 && near(evoked.times[0], -0.09989760657919393, 1e-6) && near(evoked.times[120], 0.2996928197375818, 1e-6) && evoked.times[30] == 0.0f,
"MNEEpochDataList::average matches mne Epochs.average");

ex_connectivity​

Example of using the MNE-CPP Connectivity library.

src/examples/ex_connectivity/connectivitysettingsmanager.h, line 116
TFplot::SPtr m_pTfPlot;
Eigen::MatrixXd m_matEvoked;
Eigen::MatrixXd m_matEvokedSource;
MNELIB::MNEEpochDataList epochs;

ex_averaging​

Average data from a raw data file.

src/examples/ex_averaging/main.cpp, line 151
FiffEvoked evoked = MNEEpochDataList::computeAverage(raw,
events,
fTMin,
fTMax,
event,
false,
0.0f,
0.0f,
mapReject,
QStringList(),
picks);

Also used in ex_clustered_inverse_mne_raw, ex_clustered_inverse_pwl_rap_music_raw, ex_clustered_inverse_rap_music_raw, ex_connectivity_comparison, ex_inverse_mne_raw, ex_read_epochs.

Authors of this file​