autods_pet.config#
Configuration loading and validation for autods_pet.
Reads an INI file with per-ROI parameters and statistics choices.
Any key not provided in the user file falls back to built-in defaults.
Uses only stdlib configparser - no external dependencies.
- autods_pet.config.default_config()[source]#
Return a deep copy of the built-in default configuration.
- autods_pet.config.load_config(path=None, *, validate=True)[source]#
Load an INI configuration file and merge it with built-in defaults.
- Parameters:
path (
str|Path|None(default:None)) – Path to an INI file. If None, returns the built-in defaults.validate (
bool(default:True)) – When True (default) the merged config is validated and aValueErroris raised on the first problem. Set to False to skip validation - useful when you want to runConfigValidatoryourself to collect all issues.
- Returns:
Merged configuration (user values override defaults).
- Return type:
- autods_pet.config.parse_stat(name)[source]#
Parse a stat name into
(kind, param).- Parameters:
name (
str) – Stat name such as"mean","median","p95".- Returns:
("percentile", 95.0)for"p95",("mean", None)for"mean", etc.- Return type:
- Raises:
ValueError – If name is not a recognised statistic.
Examples
>>> from autods_pet.config import parse_stat >>> parse_stat("mean") ('mean', None) >>> parse_stat("p95") ('percentile', 95.0) >>> parse_stat("median") ('median', None)
- autods_pet.config.get_roi_config(cfg, roi)[source]#
Return the sub-dict for a single ROI, raising on unknown names.
- autods_pet.config.get_all_targets(cfg)[source]#
Return a list of all configured target ROIs (named + custom).
Each entry is a dict with at least
name,mask_filename,stats. Named targets (focal_lesion, paramedullary, extramedullary) are only included if the user explicitly added the section to the INI file. Custom targets from[targets.*]sections are always included.
- class autods_pet.config.ValidationIssue(section, key, level, message)[source]#
Bases:
objectA single validation problem found in a configuration.
- class autods_pet.config.ConfigValidator(cfg)[source]#
Bases:
objectCollect all validation issues from a merged configuration dict.
Unlike
load_config(), which raises on the first error, this class accumulates every problem so that users can fix them all at once.- Parameters:
cfg (
dict[str,Any]) – A merged configuration dict (as returned byload_config()withvalidate=False).
Examples
>>> from autods_pet.config import load_config, ConfigValidator >>> cfg = load_config("config.ini", validate=False) >>> v = ConfigValidator(cfg) >>> v.validate() >>> if not v.is_valid: ... for issue in v.errors: ... print(issue)
- issues: list[ValidationIssue]#
- property errors: list[ValidationIssue]#
Return only error-level issues.
- property warnings: list[ValidationIssue]#
Return only warning-level issues.
- autods_pet.config.create_default_config(path, profile='standard')[source]#
Write a commented INI template for the given profile.
The generated file can be loaded by
load_config()without errors and serves as a starting point for users to customise.