lw_pipeline.Pipeline_Step#
- class lw_pipeline.Pipeline_Step(description, config, short_id='')[source]#
Bases:
ABCAbstract class for a pipeline step.
Methods
__init__(description, config[, short_id])get_output_path(name[, suffix, extension, ...])Get an output file path for this step.
should_generate_output(name)Check if a specific output should be generated.
step(data)Abstract method to be implemented by the pipeline step.
Attributes
Configuration of the pipeline step.
Get a logger for this pipeline step.
Get the Output_Manager for this step.
Get the Output_Registry for this step.
Short id of the pipeline step.
- property config#
Configuration of the pipeline step.
- get_output_path(name, suffix=None, extension=None, use_bids_structure=False, custom_dir=None, **bids_params)[source]#
Get an output file path for this step.
This is a convenience wrapper around output_manager.get_output_path().
- Parameters:
name (str) – Output name (will be prefixed with step_id).
suffix (str, optional) – BIDS suffix.
extension (str, optional) – File extension.
use_bids_structure (bool, optional) – Use BIDS directory structure. Default is False.
custom_dir (str or Path, optional) – Custom output directory.
**bids_params (dict) – BIDS parameters (subject, session, task, run, datatype).
- Returns:
Output file path.
- Return type:
Path
- property logger#
Get a logger for this pipeline step.
- Returns:
Logger instance named after this step.
- Return type:
logging.Logger
- property output_manager#
Get the Output_Manager for this step.
- Returns:
Manager for saving outputs with consistent paths and metadata.
- Return type:
- property output_registry#
Get the Output_Registry for this step.
- Returns:
Registry of registered outputs for this step.
- Return type:
- property short_id#
Short id of the pipeline step.
- should_generate_output(name)[source]#
Check if a specific output should be generated.
This method checks the configuration and registered outputs to determine if the output matching the given name should be generated. Use this in methods decorated with @register_output to conditionally skip expensive computations.
- Parameters:
name (str) – Name of the output to check.
- Returns:
True if the output should be generated.
- Return type:
bool
Examples
>>> @register_output("expensive_plot", enabled_by_default=False) >>> def create_plot(self): ... if not self.should_generate_output("expensive_plot"): ... return ... # ... expensive plotting code ...