channels.ChannelsMixin#

class autoclean.mixins.signal_processing.channels.ChannelsMixin[source]#

Mixin class providing channel operations functionality for EEG data.

clean_bad_channels(data=None, correlation_thresh=0.35, deviation_thresh=2.5, ransac_sample_prop=0.35, ransac_corr_thresh=0.65, ransac_frac_bad=0.25, ransac_channel_wise=False, random_state=1337, cleaning_method='interpolate', reset_bads=True, stage_name='post_bad_channels')[source]#

Detect and mark bad channels using various methods.

This method uses the MNE NoisyChannels class to detect bad channels using SNR, correlation, deviation, and RANSAC methods.

Parameters:
datamne.io.Raw, Optional

The data object to detect bad channels from. If None, uses self.raw.

correlation_threshfloat, Optional

Threshold for correlation-based detection.

deviation_threshfloat, Optional

Threshold for deviation-based detection.

ransac_sample_propfloat, Optional

Proportion of samples to use for RANSAC.

ransac_corr_threshfloat, Optional

Threshold for RANSAC-based detection.

ransac_frac_badfloat, Optional

Fraction of bad channels to use for RANSAC.

ransac_channel_wisebool, Optional

Whether to use channel-wise RANSAC.

random_stateint, Optional

Random state for reproducibility.

cleaning_methodstr, Optional

Method to use for cleaning bad channels. Options are ‘interpolate’ or ‘drop’ or None(default).

reset_badsbool, Optional

Whether to reset bad channels.

stage_namestr, Optional

Name for saving and metadata.

Returns:
result_rawinstance of mne.io.Raw

The raw data object with bad channels marked or cleaned

See also

pyprep.find_noisy_channels.NoisyChannels

For more information on the NoisyChannels class

drop_channels(data=None, channels=None, stage_name='drop_channels', use_epochs=False)[source]#

Drop specified channels from the data.

This method removes specified channels from the data.

Parameters:
datamne.io.Raw or mne.Epochs, Optional

The data object to drop channels from. If None, uses self.raw or self.epochs.

channelsList[str], Optional

List of channel names to drop.

stage_namestr, Optional

Name for saving and metadata.

use_epochsbool, Optional

If True and data is None, uses self.epochs instead of self.raw.

Returns:
result_datainstance of mne.io.Raw or mne.Epochs

The data object with channels dropped

See also

mne.io.Raw.drop_channels()

For MNE’s raw data channel dropping functionality

mne.Epochs.drop_channels()

For MNE’s epochs channel dropping functionality

set_channel_types(data=None, ch_types_dict=None, stage_name='set_channel_types', use_epochs=False)[source]#

Set channel types for specific channels.

This method sets the type of specific channels (e.g., marking channels as EOG).

Parameters:
datamne.io.Raw or mne.Epochs, Optional

The data object to set channel types for. If None, uses self.raw or self.epochs.

ch_types_dictdict, Optional

Dictionary mapping channel names to types (e.g., {‘E1’: ‘eog’})

stage_namestr, Optional

Name for saving and metadata.

use_epochsbool, Optional

If True and data is None, uses self.epochs instead of self.raw.

Returns:
result_datainstance of mne.io.Raw or mne.Epochs

The data object with updated channel types