basic_ops.drop_channels#

autoclean.functions.preprocessing.basic_ops.drop_channels(data, ch_names, on_missing='raise')[source]#

Drop channels from EEG data.

This function removes specified channels from continuous (Raw) or epoched EEG data. Useful for removing bad channels, artifact channels, or channels not needed for analysis.

Parameters:
datamne.io.BaseRaw or mne.Epochs

The EEG data from which to drop channels.

ch_namesstr or list of str

Name(s) of channel(s) to drop. Can be a single channel name or list of names.

on_missingstr, default ‘raise’

What to do if a channel name is not found. Options: - ‘raise’: Raise an error - ‘warn’: Issue a warning and continue - ‘ignore’: Silently ignore missing channels

Returns:
data_droppedmne.io.BaseRaw or mne.Epochs

Data with specified channels removed.

Raises:
TypeError

If data is not an MNE Raw or Epochs object.

ValueError

If on_missing=’raise’ and channels are not found.

Examples

Drop single channel:

>>> from autoclean import drop_channels
>>> data_clean = drop_channels(raw, 'E125')  # Drop channel E125

Drop multiple channels:

>>> data_clean = drop_channels(raw, ['E125', 'E126', 'E127'])

Drop channels with warning for missing:

>>> data_clean = drop_channels(raw, ['E125', 'NonExistent'], on_missing='warn')