Events and epoching
Extract events from continuous recordings and segment data into epochs.
almkanal.almkanal_steps.event_utils.Events
Bases: AlmKanalStep
Extract discrete events from a continuous raw recording.
Events detects events from one or more stimulus channels using
:func:mne.find_events. The detected event array is returned unchanged
alongside the original raw object and is stored in the processing history
for use by later steps such as Epochs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_channel
|
str | None
|
Name of the stimulus channel used for event detection. If |
None
|
output
|
str
|
Event representation returned by :func: |
'onset'
|
consecutive
|
bool | str
|
How consecutive non-zero values on the stimulus channel are treated.
Passed directly to :func: |
'increasing'
|
min_duration
|
float
|
Minimum event duration, in seconds. |
0.0
|
shortest_event
|
int
|
Minimum number of samples that an event must span. |
2
|
mask
|
int | None
|
Optional bit mask applied to the stimulus channel during event detection. |
None
|
uint_cast
|
bool
|
Whether the stimulus channel should be cast to an unsigned integer representation before event detection. |
False
|
mask_type
|
str
|
Masking operation applied when |
'and'
|
initial_event
|
bool
|
Whether a non-zero stimulus value at the beginning of the recording should be emitted as an event. |
False
|
verbose
|
bool | str | int | None
|
Verbosity setting passed to :func: |
None
|
Notes
Event detection does not modify the input raw data.
The processing metadata returned by :meth:run is stored under
'event_info' and contains both the detected events array and the
effective event-detection settings.
The resulting event array has the standard MNE shape (n_events, 3) and
can be consumed by later processing steps such as Epochs.
Events can occur only once in a pipeline.
See Also
mne.find_events Detect events from stimulus channels. Epochs Create epochs from explicitly supplied or previously detected events.
almkanal.almkanal_steps.epoch_utils.Epochs
Bases: AlmKanalStep
Create epochs from continuous M/EEG data.
Epochs segments a continuous :class:mne.io.BaseRaw recording into
time-locked trials using :class:mne.Epochs.
Events can either be supplied directly through events or obtained from the
most recent preceding Events step in the processing history. Explicitly
supplied events take precedence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tmin
|
float
|
Start of each epoch relative to the event, in seconds. |
0.
|
tmax
|
float
|
End of each epoch relative to the event, in seconds. |
0.5
|
events
|
array - like | None
|
Event array used to construct the epochs. Expected to follow MNE's standard
|
None
|
event_id
|
dict | None
|
Mapping from event names to integer event codes. Passed to
:class: |
None
|
baseline
|
tuple | None
|
Baseline correction interval in seconds. |
None
|
preload
|
bool
|
Whether to preload epoched data into memory. |
True
|
picks
|
str | array - like | None
|
Channels to include in the epochs. |
None
|
reject
|
dict | None
|
Peak-to-peak amplitude rejection thresholds by channel type. |
None
|
filter_events
|
bool
|
Whether to filter the event array to include only event codes specified
in |
False
|
flat
|
dict | None
|
Minimum acceptable peak-to-peak amplitudes by channel type. |
None
|
proj
|
bool | str
|
Projection handling passed to :class: |
True
|
reject_tmin
|
float | None
|
Start of the time interval used for rejection, in seconds relative to the event. |
None
|
reject_tmax
|
float | None
|
End of the time interval used for rejection, in seconds relative to the event. |
None
|
detrend
|
int | None
|
Detrending order. |
None
|
on_missing
|
str
|
Behaviour when entries in |
'raise'
|
reject_by_annotation
|
bool
|
Whether epochs overlapping annotations marked as bad should be rejected. |
True
|
metadata
|
DataFrame | None
|
Metadata associated with individual epochs. |
None
|
event_repeated
|
str
|
Behaviour when multiple events occur at the same sample. Passed directly to
:class: |
'error'
|
verbose
|
bool | str | int | None
|
Verbosity setting passed to :class: |
None
|
Notes
If events is provided directly, no preceding Events step is required.
Otherwise, the event array is obtained from the most recent Events entry in
the processing history.
The input raw object is not replaced by this step. :meth:run returns a new
:class:mne.Epochs object under 'data'.
The processing metadata returned by :meth:run is stored under
'epochs_info' and contains the event array together with the effective epoch
construction, baseline, channel-selection, rejection, detrending,
and metadata settings.
Epochs can occur only once in a pipeline and is expected to run after
artifact-correction steps such as Maxwell and ICA and before source
modelling and reconstruction steps.
See Also
mne.Epochs MNE-Python class used to construct the epoched data. Events Detect events from a continuous recording for use by this step.