config¶
Configuration management for Super-Slurpy.
Handles the loading of the YAML configuration file from multiple potential fallback locations and validates it using Pydantic.
Examples
>>> from super_slurpy.config import load_config
>>> from pathlib import Path
>>> config = load_config(config_dir=Path("/path/to/data"))
>>> print(config.gui.proportional_frame)
0.5
- class GuiConfig[source]¶
Bases:
BaseModelConfiguration model for the Graphical User Interface.
- Variables:
default_frame (int | None) – The absolute frame number to start on, defaults to None.
proportional_frame (float | None) – The proportional position to start on (0.0 to 1.0), defaults to 0.5.
seed_spline_file (str | None) – Path or filename of the seed spline file, defaults to None.
- default_frame: int | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- proportional_frame: float | None¶
- seed_spline_file: str | None¶
- class ParticleConfig[source]¶
Bases:
BaseModelConfiguration model for Particle Filter tracking.
- Variables:
num_particles (int) – Number of particles to generate, defaults to 50.
percent_var (float) – Variance percentage for PCA shape model, defaults to 0.98.
noise_scale (float) – Scale of the noise applied to particles, defaults to 1.0.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- noise_scale: float¶
- num_particles: int¶
- percent_var: float¶
- class SlurpyConfig[source]¶
Bases:
BaseModelRoot configuration model for the application.
- Variables:
apply_tracking_to_current_frame (bool) – Should the current frame be replaced by applying the tracking algorithm to it too or not, defaults to True.
gui (GuiConfig) – Nested configuration for the GUI.
particle (ParticleConfig) – Configuration for the particle tracking algorithm.
snake (SnakeConfig) – Configuration for the snake algorithm.
- apply_tracking_to_current_frame: bool¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- particle: ParticleConfig¶
- snake: SnakeConfig¶
- class SnakeConfig[source]¶
Bases:
BaseModelConfiguration model for the Snake active contour algorithm.
- Variables:
alpha (float) – Continuity weight, defaults to 0.1.
lambda1 (float) – Smoothness weight, defaults to 0.5.
band_penalty (float) – Penalty for venturing outside the target band, defaults to 10.0.
- alpha: float¶
- band_penalty: float¶
- lambda1: float¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- load_config(config_dir=None)[source]¶
Load and validate the YAML configuration file.
This function attempts to find the configuration file in the following order of precedence: 1. The explicitly provided config_dir (e.g., video directory). 2. Current working directory (cwd). 3. User’s home directory under ~/.slurpy/. 4. Bundled package resources via importlib.
- Parameters:
config_dir (
Path|None) – A specific directory to check first for the configuration file. Defaults to None.- Returns:
The validated configuration object populated with YAML data or default values if no file/data is found.
- Return type:
Examples
>>> from super_slurpy.config import load_config >>> from pathlib import Path >>> config = load_config(config_dir=Path("/path/to/data")) >>> print(config.gui.proportional_frame) 0.5
- load_resource_config()[source]¶
Load the default configuration strictly from the package resource.
- Returns:
The configuration populated exclusively from the internal YAML.
- Return type:
Examples
>>> from super_slurpy.config import load_resource_config >>> default_config = load_resource_config() >>> print(default_config.snake.alpha) 0.1