Pipeline Functions API Reference
This page documents the core functions of the AutoClean pipeline.
Data Import Functions
step_import_raw
Import and configure raw EEG data.
Parameters:
autoclean_dict(dict): Dictionary containing pipeline configuration including:unprocessed_file: Path to raw EEG data fileeeg_system: Name of the EEG system montagepreload(bool): If True, data will be loaded into memory at initialization
Returns:
mne.io.Raw: Imported and configured raw EEG data with appropriate montage set
step_convert_to_bids
def step_convert_to_bids(
raw,
output_dir,
task="rest",
participant_id=None,
line_freq=60.0,
overwrite=False,
events=None,
event_id=None,
study_name="EEG Study"
)
Converts a single EEG data file into BIDS format with default/dummy metadata.
Parameters:
raw(mne.io.Raw): Raw EEG dataoutput_dir(str or Path): Directory for BIDS datasettask(str): Task nameparticipant_id(str): Participant IDline_freq(float): Power line frequency in Hzoverwrite(bool): Whether to overwrite existing filesevents(array): Events arrayevent_id(dict): Event ID dictionarystudy_name(str): Name of the study
Preprocessing Functions
step_clean_bad_channels
Detect and interpolate bad channels using PyPrep.
Parameters:
raw(mne.io.Raw): Raw EEG dataautoclean_dict(dict): Configuration dictionary
step_resample_data
Resample data using frequency from config.
Parameters:
raw(mne.io.Raw): Raw EEG dataresample_freq(float): Target sampling frequency
Artifact Rejection Functions
step_run_pylossless
Run the PyLossless pipeline for artifact rejection.
Parameters:
autoclean_dict(dict): Configuration dictionary
detect_muscle_beta_focus_robust
def detect_muscle_beta_focus_robust(
epochs,
pipeline,
autoclean_dict,
freq_band=(20, 30),
scale_factor=3.0
)
Detect muscle artifacts using a robust measure focusing on beta band.
Parameters:
epochs(mne.Epochs): Epoched datapipeline: Pipeline objectautoclean_dict(dict): Configuration dictionaryfreq_band(tuple): Frequency band for detectionscale_factor(float): Scale factor for threshold
Quality Control Functions
step_psd_topo_figure
def step_psd_topo_figure(
raw_original,
raw_cleaned,
pipeline,
autoclean_dict,
bands=None,
metadata=None
)
Generate PSD and topographical plots for quality control.
Parameters:
raw_original(mne.io.Raw): Original raw dataraw_cleaned(mne.io.Raw): Cleaned datapipeline: Pipeline objectautoclean_dict(dict): Configuration dictionarybands(list): Frequency bandsmetadata(dict): Additional metadata
generate_ica_reports
Generate comprehensive ICA component reports.
Parameters:
pipeline: Pipeline objectcleaned_raw(mne.io.Raw): Cleaned raw dataautoclean_dict(dict): Configuration dictionaryduration(int): Duration in seconds for plots
Database Management Functions
manage_database
def manage_database(
operation: str = 'connect',
run_record: dict = None,
update_record: dict = None
)
Manage the pipeline's database operations.
Parameters:
operation(str): Database operation typerun_record(dict): Record to insertupdate_record(dict): Record to update