Recipe

Segmentation Recipe loader.

Recipes are Python scripts that define a run(effect) function. This module loads recipes and provides utilities for running them.

Example recipe (brain_tumor_1.py):

sample_data = “MRBrainTumor1” segment_name = “Tumor”

def run(effect):

effect.applyPreset(“tumor_lesion”) effect.brushRadiusMm = 20.0 effect.paintAt(-5.31, 34.77, 20.83) effect.paintAt(-5.31, 25.12, 35.97)

Classes

class Recipe

A loaded recipe ready to execute.

Attributes:

name: Recipe name (from filename). path: Path to the recipe file. sample_data: Slicer SampleData name to load (or empty if using dicom_source). dicom_source: Path to DICOM directory relative to project root (or empty if using sample_data). segment_name: Name for the segment to create. gold_standard: Name of gold standard to compare against (optional). run: The run(effect) function to execute. module: The loaded Python module.

Methods:

load()

Load a recipe from a Python file.

execute()

Execute the recipe with the given effect.

Functions

load()

Load a recipe from a Python file.

Args:

path: Path to the recipe file.

Returns:

Loaded Recipe object.

Raises:

FileNotFoundError: If recipe file doesn’t exist. AttributeError: If recipe doesn’t define required attributes.

execute()

Execute the recipe with the given effect.

Args:

effect: The Adaptive Brush scripted effect instance.

list_recipes()

List available recipe files.

Args:

recipes_dir: Directory to search. If None, uses default location.

Returns:

List of recipe file paths.