basic_steps.BasicStepsMixin#

class autoclean.mixins.signal_processing.basic_steps.BasicStepsMixin[source]#

Mixin class providing basic signal processing steps for autoclean tasks.

run_basic_steps(data=None, use_epochs=False, stage_name='post_basic_steps', export=False)[source]#

Runs all basic preprocessing steps sequentially based on configuration.

The steps included are: 1. Resample Data 2. Filter Data 3. Drop Outer Layer Channels 4. Assign EOG Channels 5. Trim Edges 6. Crop Duration

Each step’s execution depends on its ‘enabled’ status in the configuration.

Parameters:
dataOptional

The data object to process. If None, uses self.raw or self.epochs.

use_epochsbool, Optional

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

stage_namestr, Optional

Name of the processing stage for export. Default is “post_basic_steps”.

exportbool, Optional

If True, exports the processed data to the stage directory. Default is False.

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

The data object after applying all enabled basic processing steps.

filter_data(data=None, use_epochs=False, l_freq=None, h_freq=None, notch_freqs=None, notch_widths=None, method=None, phase=None, fir_window=None, verbose=None)[source]#

Apply filtering to EEG data within the AutoClean pipeline.

This method wraps the standalone autoclean.filter_data() function with pipeline integration including configuration management, metadata tracking, and automatic export functionality.

Parameters override configuration values when provided. If not provided, values are read from the task configuration using the existing _check_step_enabled system.

Parameters:
datamne.io.Raw, mne.Epochs, or None, default None

Input data. If None, uses self.raw or self.epochs based on use_epochs parameter.

use_epochsbool, default False

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

l_freqfloat or None, optional

Low cutoff frequency for highpass filtering in Hz. Overrides config if provided.

h_freqfloat or None, optional

High cutoff frequency for lowpass filtering in Hz. Overrides config if provided.

notch_freqslist of float or None, optional

Frequencies to notch filter in Hz. Overrides config if provided.

notch_widthsfloat, list of float, or None, optional

Width of notch filters in Hz. Overrides config if provided.

methodstr or None, optional

Filtering method (‘fir’ or ‘iir’). Overrides config if provided.

phasestr or None, optional

Filter phase (‘zero’, ‘zero-double’, ‘minimum’). Overrides config if provided.

fir_windowstr or None, optional

FIR window function. Overrides config if provided.

verbosebool or None, optional

Control verbosity. Overrides config if provided.

Returns:
filtered_datamne.io.Raw or mne.Epochs

Filtered data object. Also updates self.raw or self.epochs and triggers metadata tracking and export if configured.

See also

autoclean.filter_data

The underlying standalone filtering function

resample_data(data=None, target_sfreq=None, stage_name='post_resample', use_epochs=False, npad=None, window=None, n_jobs=None, pad=None, verbose=None)[source]#

Apply resampling to EEG data within the AutoClean pipeline.

This method wraps the standalone autoclean.resample_data() function with pipeline integration including configuration management, metadata tracking, and automatic export functionality.

Parameters override configuration values when provided. If not provided, values are read from the task configuration using the existing _check_step_enabled system.

Parameters:
datamne.io.Raw, mne.Epochs, or None, default None

Input data. If None, uses self.raw or self.epochs based on use_epochs parameter.

target_sfreqfloat or None, optional

Target sampling frequency in Hz. Overrides config if provided.

stage_namestr, default “post_resample”

Name for saving the resampled data.

use_epochsbool, default False

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

npadstr or None, optional

Padding parameter. Overrides config if provided.

windowstr or None, optional

Window function. Overrides config if provided.

n_jobsint or None, optional

Number of parallel jobs. Overrides config if provided.

padstr or None, optional

Padding mode. Overrides config if provided.

verbosebool or None, optional

Control verbosity. Overrides config if provided.

Returns:
resampled_datamne.io.Raw or mne.Epochs

Resampled data object. Also updates self.raw or self.epochs and triggers metadata tracking and export if configured.

See also

autoclean.resample_data

The underlying standalone resampling function

rereference_data(data=None, ref_type=None, use_epochs=False, stage_name='post_rereference')[source]#

Rereference raw or epoched data based on configuration settings.

This method can work with self.raw, self.epochs, or a provided data object. It checks the rereference_step toggle in the configuration if no ref_type is provided.

Parameters:
dataOptional

The raw data to rereference. If None, uses self.raw or self.epochs.

use_epochsbool, Optional

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

ref_typestr, Optional

The type of reference to use. If None, reads from config.

stage_namestr, Optional

Name for saving the rereferenced data (default: “post_rereference”).

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

The rereferenced data object (same type as input)

See also

mne.io.Raw.set_eeg_reference()

For MNE’s raw data rereferencing functionality

mne.Epochs.set_eeg_reference()

For MNE’s epochs rereferencing functionality

Examples

>>> #Inside a task class that uses the autoclean framework
>>> self.rereference_data()
drop_outer_layer(data=None, stage_name='post_outerlayer', use_epochs=False)[source]#

Drop outer layer channels based on configuration settings.

Parameters:
dataOptional

The data object to process. If None, uses self.raw or self.epochs.

stage_namestr, Optional

Name for saving the processed data (default: “post_outerlayer”).

use_epochsbool, Optional

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

Returns:

inst : instance of mne.io.Raw or mne.io.Epochs The data object with outer layer channels removed.

assign_eog_channels(data=None, use_epochs=False)[source]#

Assign EOG channel types based on configuration settings.

Parameters:
dataOptional

The data object to process. If None, uses self.raw or self.epochs.

use_epochsbool, Optional

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

Returns:

inst : instance of mne.io.Raw or mne.io.Epochs The data object with EOG channels assigned.

trim_edges(data=None, stage_name='post_trim', use_epochs=False)[source]#

Trim data edges based on configuration settings.

Parameters:
dataOptional

The data object to process. If None, uses self.raw or self.epochs.

stage_namestr, Optional

Name for saving the processed data (default: “post_trim”).

use_epochsbool, Optional

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

Returns:

inst : instance of mne.io.Raw or mne.io.Epochs The data object with edges trimmed.

crop_duration(data=None, stage_name='post_crop', use_epochs=False)[source]#

Crop data duration based on configuration settings.

Parameters:
dataOptional

The data object to process. If None, uses self.raw or self.epochs.

stage_namestr, Optional

Name for saving the processed data (default: “post_crop”).

use_epochsbool, Optional

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

Returns:

inst : instance of mne.io.Raw or mne.io.Epochs The data object cropped to the specified duration.