meeg_utils.steps.AutoReject#

class meeg_utils.steps.AutoReject(method='local', *, n_interpolate=None, consensus=None, cv=None, thresh_method='bayesian_optimization', random_state=42, n_jobs=1)[source]#

Reject or repair bad epochs with thresholds learned from the data.

Wraps autoreject (Jas et al., 2017, NeuroImage 159:417):

  • "local": autoreject.AutoReject learns a peak-to-peak threshold per channel by cross-validation; in each epoch the worst channels are interpolated, and epochs with too many bad channels are dropped. Needs sensor positions.

  • "global": autoreject.get_rejection_threshold() learns one peak-to-peak threshold per channel type; epochs exceeding it are dropped.

Parameters:
  • method ({"local", "global"}) – See above.

  • n_interpolate (list of int | None) – Local: candidate numbers of channels to interpolate per epoch (None: autoreject’s default, 1, 4 and 32).

  • consensus (list of float | None) – Local: candidate fractions of bad channels that make an epoch bad (None: autoreject’s default, 0 to 1 in steps of 0.1).

  • cv (int) – Cross-validation folds (autoreject defaults: 10 local, 5 global).

  • thresh_method ({"bayesian_optimization", "random_search"}) – Local: how thresholds are searched.

  • random_state (int | None) – Seed.

  • n_jobs (int) – Parallel jobs.

reject_log_#

Bad epochs and channel labels on the fitted data.

Type:

autoreject.RejectLog

thresholds_#

Learned thresholds: per channel (local) or per channel type (global).

Type:

dict

qc_#

n_epochs, n_dropped, fraction_dropped, n_interpolated (channels interpolated per epoch, mean) and the most interpolated channels.

Type:

dict

Notes

Figures (plot()): "reject_log" (epochs x channels: bad, interpolated, dropped) and "thresholds".

__init__(method='local', *, n_interpolate=None, consensus=None, cv=None, thresh_method='bayesian_optimization', random_state=42, n_jobs=1)[source]#

Methods

__init__([method, n_interpolate, consensus, ...])

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.epochs.BaseEpochs'>,)#

Data types the step accepts.

drops_epochs: ClassVar[bool] = True#

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

plot_kinds: ClassVar[dict[str, bool]] = {'reject_log': False, 'thresholds': 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