config

Overview

This package uses yacs for hierarchical configuration management, providing a flexible system for managing default settings and user overrides. For detailed schema, YAML examples, and usage patterns, see Configuration Guide.

Main Components

config.defaults.get_cfg_defaults()

Get a cloned yacs CfgNode object with default values.

Module Contents

src.config

config

Configuration management module for NEMA analysis tools.

This package provides centralized configuration management for the NEMA (National Electrical Manufacturers Association) phantom analysis tools. It handles default settings for acquisition parameters, activity measurements, phantom definitions, ROI (Region of Interest) specifications, file patterns, and visualization styles.

The module uses the yacs (Yet Another Configuration System) library to provide hierarchical configuration management, allowing easy override of default values for different use cases and datasets.

Submodules
defaultsmodule

Contains the default configuration settings for all NEMA tools, including:

  • Acquisition parameters (emission image time)

  • Activity measurements (hot/background ratios, units)

  • Phantom definitions (ROI positions and dimensions)

  • ROI configurations (central slice, background offsets, orientation)

  • File naming patterns and case identifiers

  • Visualization styles (colors, plot parameters, grid settings)

Configuration Structure

The configuration is organized into logical sections:

ACQUISITION

Emission image acquisition parameters

ACTIVITY

Activity concentration measurements and ratios

PHANTHOM

Phantom geometry and ROI definitions

ROIS

Region of Interest specifications

FILE

File pattern matching and naming conventions

STYLE

Visualization and plotting parameters

Key Configuration Groups
  • ACQUISITION: Emission imaging time (default: 10 minutes)

  • ACTIVITY: Activity concentrations with units (mCi/mL or MBq)

  • PHANTHOM: 6 hot spheres with diameters (37, 28, 22, 17, 13, 10 mm)

  • ROIS: Central slice definition and background sampling points

  • FILE: User pattern for frame numbering and case identifiers

  • STYLE: Color schemes, matplotlib rcParams, legend/grid/plot styling

Usage

Import the default configuration:

from src.config.defaults import get_cfg_defaults cfg = get_cfg_defaults()

Access and modify configuration values:

cfg.ACQUISITION.EMMISION_IMAGE_TIME_MINUTES = 15 activity_ratio = cfg.ACTIVITY.RATIO

Notes

  • Configuration uses hierarchical CfgNode structure from yacs

  • All YAML configuration files in this directory can be merged with defaults

  • ROI definitions include center coordinates (y, x), diameter, color, and name

  • Style settings apply to matplotlib visualization output

See also

defaults

Default configuration implementation

yacs

Yet Another Configuration System for hierarchical configs

src.config.defaults

defaults

Default configuration settings for NEMA phantom analysis tools.

This module establishes the default configuration hierarchy for NEMA (National Electrical Manufacturers Association) phantom analysis using the yacs (Yet Another Configuration System) library. It provides sensible defaults for acquisition parameters, activity measurements, phantom geometry, ROI definitions, file patterns, and visualization styles that can be easily overridden for different datasets and use cases.

The configuration is organized into logical sections using nested CfgNode objects, enabling hierarchical access and modification of settings without affecting other configuration areas.

Configuration Sections
ACQUISITIONCfgNode

Acquisition parameters for PET imaging.

EMMISION_IMAGE_TIME_MINUTESint

Duration of emission image acquisition in minutes (default: 10).

ACTIVITYCfgNode

Activity concentration measurements for phantom calibration.

HOTfloat

Activity concentration in hot sphere regions (default: 0.79 mCi/mL).

BACKGROUNDfloat

Activity concentration in background region (default: 0.079 mCi/mL).

RATIOfloat

Ratio of hot to background activity (default: 9.91).

UNITSstr

Activity measurement units (default: “mCi”).

ACTIVITY_TOTALstr

Total activity in the phantom (default: “29.24 MBq”).

PHANTHOMCfgNode

EARL NEMA phantom geometry and ROI definitions.

ROI_DEFINITIONS_MMlist of dict

List of 6 hot sphere definitions with keys:

  • center_yxtuple of int

    Center position in (y, x) image coordinates

  • diameter_mmfloat

    Sphere diameter in millimeters

  • colorstr

    Visualization color name

  • alphafloat

    Transparency value [0, 1]

  • namestr

    Descriptive sphere identifier

ROISCfgNode

Region of Interest specifications for analysis.

CENTRAL_SLICEint

Central axial slice index for analysis (default: 172).

BACKGROUND_OFFSET_YXlist of tuple

12 background sampling positions as (y, x) offsets from phantom center.

ORIENTATION_YXlist of int

Image orientation indicators [y_orient, x_orient] (default: [1, 1]).

ORIENTATION_Zint

Z-axis orientation indicator (default: 1).

SPACINGfloat

Pixel spacing in mm (default: 2.0644).

PHANTOM_CENTER_METHODstr

Method for phantom center detection (“weighted_slices” or “max_slice”, default: “weighted_slices”).

PHANTOM_CENTER_THRESHOLD_FRACTIONfloat

Threshold fraction for phantom center detection (0.0-1.0, default: 0.41).

UNIFORM_RADIUS_MMfloat

Uniform cylinder radius in mm (default: 11.25).

UNIFORM_HEIGHT_MMfloat

Uniform cylinder height in mm (default: 10.0).

AIR_RADIUS_MMfloat

Air cylinder radius in mm (default: 2.0).

AIR_HEIGHT_MMfloat

Air cylinder height in mm (default: 7.5).

WATER_RADIUS_MMfloat

Water cylinder radius in mm (default: 2.0).

WATER_HEIGHT_MMfloat

Water cylinder height in mm (default: 7.5).

UNIFORM_OFFSET_MMfloat

Offset from phantom center to uniform region in mm (default: 5.0).

AIRWATER_OFFSET_MMfloat

Offset from phantom center to air/water regions in mm (default: 10.0).

AIRWATER_SEPARATION_MMfloat

Separation between air and water cylinders in mm (default: 7.5).

FILECfgNode

File naming patterns and identifiers.

USER_PATTERNstr

Regular expression to extract frame numbers from filenames (default: r”frame(d+)”).

CASEstr

Case identifier for output labeling (default: “Test”).

STYLECfgNode

Visualization and matplotlib styling parameters.

COLORSlist of str

List of 8 hex color codes for plot series.

PLT_STYLEstr

Matplotlib style template (default: “seaborn-v0_8-talk”).

RCPARAMSlist of tuple

Matplotlib rcParams as (key, value) pairs for font sizes, line widths, and font family.

PLOTCfgNode

Plot styling with DEFAULT and ENHANCED substyles.

DEFAULTCfgNode

Base plot styling (dashed lines, lower alpha).

ENHANCEDCfgNode

Highlighted plot styling (solid lines, full opacity).

Functions
get_cfg_defaults()

Returns a cloned copy of the default configuration object.

returns:

A yacs CfgNode object containing all default configuration values.

rtype:

CfgNode

Notes

  • All configuration values are stored in the module-level _C variable

  • Use get_cfg_defaults() to obtain a modifiable clone rather than the original _C object

  • Hot spheres follow EARL NEMA IQ phantom specification (6 spheres: 37, 28, 22, 17, 13, 10 mm diameters)

  • Background sampling uses 12 distributed offset positions around phantom center

  • Visualization colors use 8-digit hex format (#RRGGBBAA) with alpha channel

  • ROI positions use (y, x) convention to match NumPy array indexing

Examples

Access default configuration:

>>> from src.config.defaults import get_cfg_defaults
>>> cfg = get_cfg_defaults()
>>> acquisition_time = cfg.ACQUISITION.EMMISION_IMAGE_TIME_MINUTES
>>> print(acquisition_time)
10

Modify configuration:

>>> cfg.ACQUISITION.EMMISION_IMAGE_TIME_MINUTES = 20
>>> cfg.ACTIVITY.UNITS = "MBq/mL"
>>> num_spheres = len(cfg.PHANTHOM.ROI_DEFINITIONS_MM)
>>> print(num_spheres)
6

Access nested styling parameters:

>>> default_color = cfg.STYLE.PLOT.DEFAULT.COLOR
>>> enhanced_linewidth = cfg.STYLE.PLOT.ENHANCED.LINEWIDTH

References

See also

yacs.config.CfgNode

Base configuration node class

src.config

Package containing all configuration modules

config.defaults.get_cfg_defaults()[source]

Get a cloned yacs CfgNode object with default values.

Returns a deep copy of the module-level default configuration object _C, containing all NEMA analysis tool settings. Cloning prevents modifications from affecting the original defaults.

Returns:

A cloned configuration node containing:

  • ACQUISITION: Emission imaging parameters

  • ACTIVITY: Activity measurements and ratios

  • PHANTHOM: Phantom geometry and ROI definitions

  • ROIS: Region of interest specifications

  • FILE: File pattern matching and naming

  • STYLE: Visualization and plotting parameters

Return type:

CfgNode

Notes

Always use this function rather than accessing _C directly to ensure configuration isolation between independent uses.

Examples

Create independent configuration instances:

>>> cfg1 = get_cfg_defaults()
>>> cfg2 = get_cfg_defaults()
>>> cfg1.ACQUISITION.EMMISION_IMAGE_TIME_MINUTES = 15
>>> cfg2.ACQUISITION.EMMISION_IMAGE_TIME_MINUTES
10

See Also

Notes

  • Configuration is immutable after calling .freeze()

  • Always use get_cfg_defaults() to obtain a fresh copy

  • ROI positions use (y, x) convention to match NumPy array indexing

  • Hot spheres follow EARL NEMA IQ phantom specification