API Documentation#

lw_pipeline#

lw_pipeline:

Lightweight MNE Pipeline using MNE-Python and MNE-BIDS.

Pipeline(steps)

Pipeline class to run pipeline steps in sequence.

Config([config_file_path, verbose])

A class representing the configuration settings.

Pipeline_Exception

Exception class for the pipeline.

Pipeline_Step(description, config[, short_id])

Abstract class for a pipeline step.

Pipeline_Data(config)

Data representation for the pipeline.

Pipeline_MNE_BIDS_Data(config[, from_bids, ...])

Data representation of eeg/ieeg/meg files for the pipeline.

Output_Manager(config, step_id[, ...])

Manage output saving with consistent paths, metadata, and overwrite handling.

Output_Registry(step_instance)

Registry for managing registered outputs in a pipeline step.

register_output(name[, description, ...])

Register a method as an optional output generator.

lw_pipeline.discovery#

lw_pipeline.discovery:

Step discovery and dynamic loading utilities.

lw_pipeline.discovery.find_all_step_classes(step_files, config)[source]#

Find and instantiate all Pipeline_Step classes from step files.

Dynamically imports Python modules from the specified step files, searches for Pipeline_Step subclasses, and instantiates them with the provided configuration.

Parameters:
  • step_files (list of str) – List of Python filenames containing step definitions. Files should be in the directory specified by config.steps_dir.

  • config (Config) – Configuration object to pass to step constructors.

Returns:

List of instantiated Pipeline_Step objects ready for execution.

Return type:

list of Pipeline_Step

Notes

  • The function automatically discovers all Pipeline_Step subclasses in each module (excluding the base Pipeline_Step class itself).

  • Each class is instantiated with the provided config object.

  • Module names are derived from the steps_dir basename.

Examples

>>> from lw_pipeline import Config
>>> config = Config("config.py")
>>> step_files = find_all_step_files(config.steps_dir)
>>> steps = find_all_step_classes(step_files, config)
>>> len(steps)
3
lw_pipeline.discovery.find_all_step_files(steps_dir)[source]#

Find all .py files in the steps directory.

Scans the specified directory for Python files that can contain pipeline step definitions. Excludes special files like __init__.py.

Parameters:

steps_dir (str) – Path to the directory containing step files.

Returns:

Sorted list of Python filenames (without path) found in the directory. Files starting with ‘__’ are excluded.

Return type:

list of str

Examples

>>> find_all_step_files("steps/")
['00_preprocessing.py', '01_analysis.py', '02_visualization.py']
lw_pipeline.discovery.list_all_outputs(config)[source]#

List all registered outputs in pipeline steps.

Discovers all pipeline steps and displays their registered outputs in a formatted table, showing which outputs are enabled by default.

Parameters:

config (Config) – Configuration object containing steps_dir.

Notes

Outputs are marked with: - ✓ : Enabled by default - ○ : Disabled by default

Examples

>>> from lw_pipeline import Config
>>> config = Config("config.py")
>>> list_all_outputs(config)
00 - Preprocessing:

Preprocess raw data Outputs:

✓ cleaned_data - Cleaned EEG data ○ debug_plot - Debug visualization (disabled by default)

lw_pipeline.helper#

lw_pipeline.helper:

Helpers

mne

MNE helpers.

naming

Naming helpers.

report

Create a report of the pipeline's derivatives.