meeg_utils.steps.Regression#

class meeg_utils.steps.Regression(artifact='ref_meg', *, picks=None)[source]#

Remove what reference or artifact channels record from the data, by linear regression.

Wraps mne.preprocessing.EOGRegression: each data channel is regressed on the artifact channels (means removed) and the fitted contribution is subtracted. Coefficients are learned in fit and reused by transform.

  • artifact="ref_meg" (default): environmental noise recorded by the reference magnetometers of KIT/Ricoh, BTi/4D, Artemis123 and CTF systems is removed from the MEG channels (least-squares reference regression; for CTF, the vendor’s synthetic gradiometers, Reference with ctf_grade=3, are the usual alternative and the data must be at grade 0).

  • artifact="eog" (or "ecg", a list of channels): regression of ocular artifacts (Gratton et al., 1983, Electroencephalogr Clin Neurophysiol 55:468). It also removes the brain activity the EOG electrodes pick up; ICA is usually preferable. Set the EEG reference first (Reference); MNE requires it.

Parameters:
  • artifact (str | list of str) – Channel type or names of the predictors.

  • picks (str | list of str | None) – Channels to clean; None uses the MEG channels for artifact="ref_meg" and all data channels otherwise. Bad channels are left out.

model_#

The fitted regression (coef_: data channels x artifact channels).

Type:

mne.preprocessing.EOGRegression

qc_#

n_channels, n_artifact_channels, artifact_channels, variance_removed_pct (fitted data) and per channel type power_change_db (last transform). Both ignore offsets (the mean over time), which the regression leaves alone.

Type:

dict

psd_#

Per channel type, PSDs of the cleaned channels before and after the last transform.

Type:

dict

Notes

Figures (plot()): "psd", spectra before and after.

__init__(artifact='ref_meg', *, picks=None)[source]#

Methods

__init__([artifact, picks])

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'>, <class 'mne.epochs.BaseEpochs'>, <class 'mne.evoked.Evoked'>)#

Data types the step accepts.

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