meeg_utils.steps.ByChannelType#
- class meeg_utils.steps.ByChannelType(branches, *, on_missing='raise')[source]#
Process channel types with separate steps, like scikit-learn’s
ColumnTransformer.Each branch selects some channel types and runs its own steps on a copy holding only those channels; the results are written back, so all channels stay in place. Typical use: MEG and EEG recorded together, with a different ICA or bad-channel method for each.
- Parameters:
branches (dict) – Channel group (
"meg","mag","grad","eeg","eog", …) mapped to a step or a list of(name, step). Groups must not overlap."meg"includes CTF reference sensors.on_missing ({"raise", "ignore"}) – What to do when the data have no channels of a branch.
- pipelines_#
Group mapped to the fitted
Pipelineof the branch (it shares its step objects withbranches).- Type:
Notes
Steps in a branch must keep the channels and the time axis (no resampling, epoching or epoch rejection). What the branch changes is carried back: the data, new annotations (e.g. from
BadSegments),info["bads"]and the channel descriptions of its channels (e.g. CTF compensation), projectors added or removed, the EEG reference flag, and, from a MEG branch, the device-to-head transform and the Maxwell-filtering history.info["highpass"]/info["lowpass"]describe all channels and are left unchanged, as MNE does when filtering a subset of channels.Parameters of branch steps are
<group>__<param>(a single step) or<group>__<step>__<param>, e.g.pipe.set_params(by_type__eeg__ica__n_components=15).Figures (
plot()) are those of the branch steps, named"<group>/<step>/<kind>".Examples
>>> from meeg_utils import steps as S >>> step = S.ByChannelType({ ... "meg": [("ica", S.ICA(picks="meg", labeler="megnet"))], ... "eeg": [("bads", S.BadChannels("prep")), ("ica", S.ICA(picks="eeg"))], ... })
Methods
__init__(branches, *[, on_missing])fit(inst[, y, system])Learn the step's state from the data.
fit_transform(inst[, y, system, copy])Fit every branch and return the processed data, running each branch once.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters, including those of the branch steps.
plot([kind, inst])Draw the figures of the branch steps.
set_fit_request(*[, inst, system])Configure whether metadata should be requested to be passed to the
fitmethod.set_params(**params)Set parameters, including
<group>__[<step>__]<param>of branch steps.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).changes_channelsWhether the step may add, drop or reorder channels.
changes_timesWhether the step may change the time axis (e.g. resampling, cropping).
drops_epochsWhether the step may drop epochs (e.g. artifact rejection).
Figures of the branch steps, as
"<group>/<step>/<kind>".returnsData type the step returns;
Nonemeans the same type as its input.systemsAcquisition systems the step applies to;
Nonemeans all systems.- accepts: ClassVar[tuple[type, ...]] = (<class 'mne.io.base.BaseRaw'>, <class 'mne.epochs.BaseEpochs'>)#
Data types the step accepts.
- adds_annotations: ClassVar[bool] = True#
Whether the step may add
BAD_annotations (existing ones are kept).
- fit_transform(inst, y=None, *, system=None, copy=True)[source]#
Fit every branch and return the processed data, running each branch once.
- set_params(**params)[source]#
Set parameters, including
<group>__[<step>__]<param>of branch steps.- Parameters:
**params (Any) –
branches,on_missingor nested branch parameters.- Returns:
self – The step.
- Return type:
- plot(kind=None, *, inst=None, **kwargs)[source]#
Draw the figures of the branch steps.
- Parameters:
kind (str | None) –
"<group>/<step>/<kind>", orNonefor every figure the inputs allow.inst (Raw | Epochs | None) – Data for the figures that need it; each branch replays its steps on its own channels, so every step plots the data it received.
**kwargs (Any) – Passed to the plotting method of
kind.
- Returns:
Kind mapped to its figure.
- Return type: