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 returnsself. 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 inself.qc_during either.Subclasses must not drop channels, nor change
first_samp,meas_dateor the timing of annotations, unless they declare it withchanges_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:
- __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
fitmethod.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
transformmethod.transform(inst, *[, copy])Apply the fitted step to the data.
Attributes
Data types the step accepts.
Whether the step may add
BAD_annotations (existing ones are kept).Whether the step may add, drop or reorder channels.
Whether the step may change the time axis (e.g. resampling, cropping).
Whether the step may drop epochs (e.g. artifact rejection).
plot_kindskind -> whether it needs data (
inst).Data type the step returns;
Nonemeans the same type as its input.Acquisition systems the step applies to;
Nonemeans 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;
Nonemeans the same type as its input.
- systems: ClassVar[frozenset[str] | None] = None#
Acquisition systems the step applies to;
Nonemeans all systems.
- changes_times: ClassVar[bool] = False#
Whether the step may change the time axis (e.g. resampling, cropping).
- 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 frominst. Pipelines detect it once and pass it to every step.
- Returns:
self – The fitted step.
- Return type:
- 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),instis left untouched and a processed copy is returned. IfFalse,instmay 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
instuntouched (seetransform()).
- Returns:
The processed data.
- Return type:
Raw | Epochs | Evoked