braindecode.preprocessing.RegressArtifact#
- class braindecode.preprocessing.RegressArtifact(picks=None, *, exclude='bads', picks_artifact='eog', betas=None, proj=True, copy=True, verbose=None)[source]#
Braindecode preprocessor wrapper for
regress_artifact().Remove artifacts using regression based on reference channels.
- Parameters:
- instinstance of Epochs | Raw
The instance to process.
- picksstr | array-like | slice | None
Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g.,
['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values'all'to pick all channels, or'data'to pick data channels. None (default) will pick good data channels. Note that channels ininfo['bads']will be included if their names or indices are explicitly provided.- excludelist | ‘bads’
List of channels to exclude from the regression, only used when picking based on types (e.g., exclude=”bads” when picks=”meg”). Specify
'bads'(the default) to exclude all channels marked as bad.Added in version 1.2.
- picks_artifactarray-like | str
Channel picks to use as predictor/explanatory variables capturing the artifact of interest (default is “eog”).
- betasndarray, shape (n_picks, n_picks_ref) | None
The regression coefficients to use. If None (default), they will be estimated from the data.
- projbool
Whether to automatically apply SSP projection vectors before performing the regression. Default is
True.- copybool
If True (default), copy the instance before modifying it.
- verbosebool | str | int | None
Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- Returns:
- instinstance of Epochs | Raw
The processed data.
- betasndarray, shape (n_picks, n_picks_ref)
The betas used during regression.
Notes
To implement the method outlined in [1], remove the evoked response from epochs before estimating the regression coefficients, then apply those regression coefficients to the original data in two calls like (here for a single-condition
epochsonly):>>> epochs_no_ave = epochs.copy().subtract_evoked() >>> _, betas = mne.preprocessing.regress(epochs_no_ave) >>> epochs_clean, _ = mne.preprocessing.regress(epochs, betas=betas)
Methods
- fn(picks=None, *, exclude='bads', picks_artifact='eog', betas=None, proj=True, copy=True, verbose=None)[source]#
Remove artifacts using regression based on reference channels.
- Parameters:
inst (instance of Epochs | Raw) – The instance to process.
picks (str | array-like | slice | None) – Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g.,
['meg', 'eeg']) will pick channels of those types, channel name strings (e.g.,['MEG0111', 'MEG2623']will pick the given channels. Can also be the string values'all'to pick all channels, or'data'to pick data channels. None (default) will pick good data channels. Note that channels ininfo['bads']will be included if their names or indices are explicitly provided.exclude (list | 'bads') –
List of channels to exclude from the regression, only used when picking based on types (e.g., exclude=”bads” when picks=”meg”). Specify
'bads'(the default) to exclude all channels marked as bad.Added in version 1.2.
picks_artifact (array-like | str) – Channel picks to use as predictor/explanatory variables capturing the artifact of interest (default is “eog”).
betas (ndarray, shape (n_picks, n_picks_ref) | None) – The regression coefficients to use. If None (default), they will be estimated from the data.
proj (bool) – Whether to automatically apply SSP projection vectors before performing the regression. Default is
True.copy (bool) – If True (default), copy the instance before modifying it.
verbose (bool | str | int | None) – Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- Returns:
inst (instance of Epochs | Raw) – The processed data.
betas (ndarray, shape (n_picks, n_picks_ref)) – The betas used during regression.
Notes
To implement the method outlined in [1], remove the evoked response from epochs before estimating the regression coefficients, then apply those regression coefficients to the original data in two calls like (here for a single-condition
epochsonly):>>> epochs_no_ave = epochs.copy().subtract_evoked() >>> _, betas = mne.preprocessing.regress(epochs_no_ave) >>> epochs_clean, _ = mne.preprocessing.regress(epochs, betas=betas)
References