meeg_utils.Step#

class meeg_utils.Step[source]#

Base class for all processing steps.

A step follows scikit-learn conventions:

  • All parameters are declared as keyword arguments of __init__ and stored unmodified as attributes; __init__ does no work.

  • fit() learns state from the data and returns self. Learned state is stored in attributes with a trailing underscore.

  • transform() applies the learned state without refitting and returns the processed data.

  • fit_transform() fits and transforms the same data.

Subclasses implement _fit() (optional, for stateful steps) and _transform(), and may record quality-control metrics in self.qc_ during either.

Subclasses must not drop channels, nor change first_samp, meas_date or the timing of annotations, unless they declare it with changes_channels = True / changes_times = True.

Figures: subclasses list them in plot_kinds (kind -> whether the figure needs data) and draw each with _plot_<kind>(inst, **kwargs); plot() dispatches to them.

system_#

Acquisition system the step was fitted on (see meeg_utils.io.detect_system()).

Type:

str

qc_#

Quality-control metrics recorded while fitting and transforming.

Type:

dict

__init__()#

Methods

__init__()

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).

returns

Data type the step returns; None means the same type as its input.

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: ClassVar[type | None] = None#

Data type the step returns; None means the same type as its input.

systems: ClassVar[frozenset[str] | None] = None#

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

changes_channels: ClassVar[bool] = False#

Whether the step may add, drop or reorder channels.

changes_times: ClassVar[bool] = False#

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

drops_epochs: ClassVar[bool] = False#

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

adds_annotations: ClassVar[bool] = False#

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

fit(inst, y=None, *, system=None)[source]#

Learn the step’s state from the data.

Parameters:
  • inst (Raw | Epochs | Evoked) – The data to fit on. It is not modified.

  • y (None) – Ignored; present for scikit-learn API compatibility.

  • system (str | None) – Acquisition system of the data. If None, it is detected from inst. Pipelines detect it once and pass it to every step.

Returns:

self – The fitted step.

Return type:

Step

transform(inst, *, copy=True)[source]#

Apply the fitted step to the data.

Parameters:
  • inst (Raw | Epochs | Evoked) – The data to transform.

  • copy (bool) – If True (default), inst is left untouched and a processed copy is returned. If False, inst may be modified in place to save memory; use the return value either way.

Returns:

The processed data.

Return type:

Raw | Epochs | Evoked

fit_transform(inst, y=None, *, system=None, copy=True)[source]#

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

Parameters:
  • inst (Raw | Epochs | Evoked) – The data.

  • y (None) – Ignored; present for scikit-learn API compatibility.

  • system (str | None) – Acquisition system of the data; detected if None.

  • copy (bool) – Whether to leave inst untouched (see transform()).

Returns:

The processed data.

Return type:

Raw | Epochs | Evoked