meeg_utils.steps.Epoch#

class meeg_utils.steps.Epoch(event_id=None, tmin=-0.2, tmax=0.5, *, baseline=(None, 0.0), events='auto', stim_channel=None, reject=None, flat=None, reject_by_annotation=True, decim=1, detrend=None, metadata=None, event_repeated='error')[source]#

Cut the recording into epochs around events.

Events come from the annotations (excluding BAD/EDGE; for BIDS data these are the trial_type of events.tsv) or from the stimulus channel. The event names and codes are fixed when fitting, so every run transformed with the fitted step uses the same codes.

Parameters:
  • event_id (None | str | list of str | dict) – Events to epoch: None for all; names (or MNE’s /-separated tags, e.g. "video" matches "video/on"); or a dict mapping names to codes.

  • tmin (float) – Epoch start and end relative to the events, in seconds.

  • tmax (float) – Epoch start and end relative to the events, in seconds.

  • baseline (tuple | None) – Baseline interval subtracted by mne.Epochs (MNE’s default (None, 0)); None to leave it to Baseline.

  • events ({"auto", "annotations", "stim"}) – Where to find the events; "auto" uses the annotations if there are event annotations, otherwise the stimulus channel.

  • stim_channel (str | None) – Stimulus channel (default: MNE’s choice).

  • reject (dict | None) – Peak-to-peak rejection limits per channel type (see mne.Epochs).

  • flat (dict | None) – Peak-to-peak rejection limits per channel type (see mne.Epochs).

  • reject_by_annotation (bool) – Drop epochs overlapping BAD annotations.

  • decim (int) – Decimation factor (low-pass the data first).

  • detrend (int | None) – 0 to remove the mean, 1 to remove a linear trend of each epoch.

  • metadata (None | "bids" | str) – "bids" adds the rows of the recording’s BIDS events.tsv (matched by onset); a path adds the rows of a TSV/CSV file with one row per selected event. Needs pandas.

  • event_repeated ({"error", "drop", "merge"}) – What to do with several events at the same sample.

event_id_#

Event names mapped to codes.

Type:

dict

qc_#

n_events (per condition), n_kept, n_dropped, fraction_kept and drop_reasons (count per reason).

Type:

dict

Notes

Figures (plot()): "drop_log" (mne.viz.plot_drop_log()) and "evoked" (averages per condition, mne.viz.plot_compare_evokeds(), one figure per channel type).

__init__(event_id=None, tmin=-0.2, tmax=0.5, *, baseline=(None, 0.0), events='auto', stim_channel=None, reject=None, flat=None, reject_by_annotation=True, decim=1, detrend=None, metadata=None, event_repeated='error')[source]#

Methods

__init__([event_id, tmin, tmax, baseline, ...])

fit(inst[, y, system])

Learn the step's state from the data.

fit_transform(inst[, y, system, copy])

Fit the step on the data and transform the same data.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

plot([kind, inst])

Draw quality-control figures.

set_fit_request(*[, inst, system])

Configure whether metadata should be requested to be passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_transform_request(*[, copy, inst])

Configure whether metadata should be requested to be passed to the transform method.

transform(inst, *[, copy])

Apply the fitted step to the data.

Attributes

accepts

Data types the step accepts.

adds_annotations

Whether the step may add BAD_ annotations (existing ones are kept).

changes_channels

Whether the step may add, drop or reorder channels.

changes_times

Whether the step may change the time axis (e.g. resampling, cropping).

drops_epochs

Whether the step may drop epochs (e.g. artifact rejection).

plot_kinds

kind -> whether it needs data (inst).

systems

Acquisition systems the step applies to; None means all systems.

accepts: ClassVar[tuple[type, ...]] = (<class 'mne.io.base.BaseRaw'>,)#

Data types the step accepts.

returns#

alias of BaseEpochs

changes_times: ClassVar[bool] = True#

Whether the step may change the time axis (e.g. resampling, cropping).

plot_kinds: ClassVar[dict[str, bool]] = {'drop_log': False, 'evoked': False}#

kind -> whether it needs data (inst). Each kind is drawn by a _plot_<kind>(inst, **kwargs) method.

Type:

Figures the object can draw once fitted