v2.0.0
Loading...
Searching...
No Matches
FIFFLIB::FiffEvents Class Reference

FIFF event list: (sample, prev, new) integer triples with read / write / detect / filter helpers. More...

#include <fiff_events.h>

Public Member Functions

 FiffEvents ()
 FiffEvents (QIODevice &p_IODevice)
bool write_to_fif (QIODevice &p_IODevice) const
bool write_to_ascii (QIODevice &p_IODevice, float sfreq=0.0f) const
int num_events () const
bool is_empty () const
FiffEvents pick (const QList< int > &include, const QList< int > &exclude={}, bool step=false) const
FiffEvents merge (const QList< int > &ids, int newId, bool replaceEvents=true) const
QMap< int, int > count (const QList< int > &ids={}) const

Static Public Member Functions

static bool read (const QString &t_sEventName, const QString &t_fileRawName, FiffEvents &p_Events)
static bool read_from_fif (QIODevice &p_IODevice, FiffEvents &p_Events)
static bool read_from_ascii (QIODevice &p_IODevice, FiffEvents &p_Events)
static bool detect_from_raw (const FiffRawData &raw, FiffEvents &p_Events, const QString &triggerCh=QString("STI 014"), unsigned int triggerMask=0xFFFFFFFF, bool leadingEdge=true)
static bool matchEvent (const AverageCategory &cat, const Eigen::MatrixXi &events, int eventIdx)
static FiffEvents concatenate (const QList< FiffEvents > &events, const QList< int > &firstSamps, const QList< int > &lastSamps)
static FiffEvents find_stim_steps (const Eigen::MatrixXi &stimData, int firstSamp, std::optional< int > padStart=std::nullopt, std::optional< int > padStop=std::nullopt, int merge=0)
static FiffEvents make_fixed_length (const FiffRawData &raw, int id=1, double start=0.0, double stop=-1.0, double duration=1.0, bool firstSamp=true, double overlap=0.0)

Public Attributes

Eigen::MatrixXi events

Detailed Description

FIFF event list: (sample, prev, new) integer triples with read / write / detect / filter helpers.

On-disk representation matches mne.io.write.write_events output and the -eve.fif files consumed by mne.read_events; the detection path mirrors mne.find_events. Used by FiffEpochs and the batch-averaging path in FiffEvokedSet to drive epoch extraction.

Definition at line 75 of file fiff_events.h.

Constructor & Destructor Documentation

◆ FiffEvents() [1/2]

FIFFLIB::FiffEvents::FiffEvents ( )

Default constructor. Creates an empty event set.

◆ FiffEvents() [2/2]

FIFFLIB::FiffEvents::FiffEvents ( QIODevice & p_IODevice)
explicit

Constructs FiffEvents by reading from an I/O device.

Attempts to read as FIFF first; if that fails, tries ASCII format.

Parameters
[in]p_IODeviceThe I/O device to read from.

Member Function Documentation

◆ concatenate()

FiffEvents FiffEvents::concatenate ( const QList< FiffEvents > & events,
const QList< int > & firstSamps,
const QList< int > & lastSamps )
static

Concatenate the events of consecutive recordings, like mne.concatenate_events.

Parameters
[in]eventsEvents of each recording.
[in]firstSampsFirst sample of each recording.
[in]lastSampsLast sample of each recording.
Returns
Events on the sample axis of the concatenated recording (empty if the list lengths differ).

Definition at line 493 of file fiff_events.cpp.

◆ count()

QMap< int, int > FiffEvents::count ( const QList< int > & ids = {}) const

Count the events per code (column 2), like mne.count_events.

Parameters
[in]idsCodes to report (0 if absent); if empty, every code that occurs.
Returns
Code to count.

Definition at line 479 of file fiff_events.cpp.

◆ detect_from_raw()

bool FIFFLIB::FiffEvents::detect_from_raw ( const FiffRawData & raw,
FiffEvents & p_Events,
const QString & triggerCh = QString("STI 014"),
unsigned int triggerMask = 0xFFFFFFFF,
bool leadingEdge = true )
static

Detect trigger events from raw data using a stimulus channel. Ported from detect_events (MNE-C).

Parameters
[in]rawThe raw data.
[out]p_EventsThe detected events.
[in]triggerChName of the trigger channel (empty = default "STI 014").
[in]triggerMaskBitmask to apply to trigger values.
[in]leadingEdgeIf true, only detect rising edges (default = true).
Returns
true if events were detected, false otherwise.

◆ find_stim_steps()

FiffEvents FiffEvents::find_stim_steps ( const Eigen::MatrixXi & stimData,
int firstSamp,
std::optional< int > padStart = std::nullopt,
std::optional< int > padStop = std::nullopt,
int merge = 0 )
static

Find the samples where all stimulus channels change at once, like mne.find_stim_steps.

Parameters
[in]stimDataStimulus channel data (channels x samples); steps carry the values of the first row.
[in]firstSampSample number of the first column.
[in]padStartIf set, a step from this value at sample 0 is added when the data start elsewhere.
[in]padStopIf set, a step to this value after the last sample is added.
[in]mergeMerge steps at most |merge| samples apart (> 0: into the later, < 0: into the earlier).
Returns
Steps as [sample, value before, value after].

Definition at line 517 of file fiff_events.cpp.

◆ is_empty()

bool FIFFLIB::FiffEvents::is_empty ( ) const
inline

Returns true if no events are stored.

Returns
true if the event matrix has zero rows.

Definition at line 307 of file fiff_events.h.

◆ make_fixed_length()

FiffEvents FiffEvents::make_fixed_length ( const FiffRawData & raw,
int id = 1,
double start = 0.0,
double stop = -1.0,
double duration = 1.0,
bool firstSamp = true,
double overlap = 0.0 )
static

Events at regular intervals, like mne.make_fixed_length_events.

Parameters
[in]rawThe recording.
[in]idEvent code.
[in]startFirst event time in s.
[in]stopTime in s after which no event may start (negative: end of the recording).
[in]durationDuration of each segment in s.
[in]firstSampWhether times count from the recording's first sample (true) or from 0.
[in]overlapOverlap of consecutive segments in s, 0 <= overlap < duration.
Returns
The events (empty if none fit or the overlap is invalid).

Definition at line 567 of file fiff_events.cpp.

◆ matchEvent()

bool FIFFLIB::FiffEvents::matchEvent ( const AverageCategory & cat,
const Eigen::MatrixXi & events,
int eventIdx )
static

Check whether an event matches a category definition.

Parameters
[in]catThe averaging category to match against.
[in]eventsFull event matrix (nEvents x 3): [sample, from, to].
[in]eventIdxIndex of the current event row.
Returns
true if the event matches.

◆ merge()

FiffEvents FiffEvents::merge ( const QList< int > & ids,
int newId,
bool replaceEvents = true ) const

Replace codes in both code columns by a new one, like mne.merge_events.

Parameters
[in]idsCodes to replace.
[in]newIdThe new code.
[in]replaceEventsIf false, the original events are kept as well, sorted by row.
Returns
The merged events.

Definition at line 448 of file fiff_events.cpp.

◆ num_events()

int FIFFLIB::FiffEvents::num_events ( ) const
inline

Returns the number of events.

Returns
Number of events.

Definition at line 300 of file fiff_events.h.

◆ pick()

FiffEvents FiffEvents::pick ( const QList< int > & include,
const QList< int > & exclude = {},
bool step = false ) const

Select events by code, like mne.pick_events.

Parameters
[in]includeCodes to keep; if empty, all codes except exclude are kept.
[in]excludeCodes to drop when include is empty.
[in]stepAlso match the code before the step (column 1).
Returns
The selected events in their original order.

Definition at line 432 of file fiff_events.cpp.

◆ read()

bool FIFFLIB::FiffEvents::read ( const QString & t_sEventName,
const QString & t_fileRawName,
FiffEvents & p_Events )
static

Read events from a FIFF or ASCII event file.

If t_sEventName is empty, the event file name is derived from the raw file name (replacing ".fif" with "-eve.fif").

Parameters
[in]t_sEventNamePath to the event file (empty = derive from raw file name).
[in]t_fileRawNamePath to the raw data file (used to derive event file name if needed).
[out]p_EventsThe loaded events.
Returns
true if succeeded, false otherwise.

◆ read_from_ascii()

bool FIFFLIB::FiffEvents::read_from_ascii ( QIODevice & p_IODevice,
FiffEvents & p_Events )
static

Read a list of events from an ASCII event file.

Parameters
[in]p_IODeviceThe I/O device to read from.
[out]p_EventsThe loaded events.
Returns
true if succeeded, false otherwise.

◆ read_from_fif()

bool FIFFLIB::FiffEvents::read_from_fif ( QIODevice & p_IODevice,
FiffEvents & p_Events )
static

Read an event list from a FIFF file.

Parameters
[in]p_IODeviceThe I/O device to read from.
[out]p_EventsThe loaded events.
Returns
true if succeeded, false otherwise.

◆ write_to_ascii()

bool FIFFLIB::FiffEvents::write_to_ascii ( QIODevice & p_IODevice,
float sfreq = 0.0f ) const

Write the event list to a text file (MNE-C compatible format).

Parameters
[in]p_IODeviceThe I/O device to write to.
[in]sfreqSampling frequency for time column computation.
Returns
true if succeeded, false otherwise.

◆ write_to_fif()

bool FIFFLIB::FiffEvents::write_to_fif ( QIODevice & p_IODevice) const

Write the event list to a FIFF file.

Parameters
[in]p_IODeviceThe I/O device to write to.
Returns
true if succeeded, false otherwise.

Member Data Documentation

◆ events

Eigen::MatrixXi FIFFLIB::FiffEvents::events

Event matrix (nEvents x 3): [sample, before, after].

Definition at line 291 of file fiff_events.h.


The documentation for this class was generated from the following files: