nema_quant.phantom

Phantom models and automatic segmentation algorithms for NEMA phantoms.

class nema_quant.phantom.NemaPhantom(cfg: yacs.config.CfgNode, image_dims: Tuple[int, int, int], voxel_spacing: Tuple[float, float, float])[source]

Bases: object

__init__(cfg: yacs.config.CfgNode, image_dims: Tuple[int, int, int], voxel_spacing: Tuple[float, float, float]) None[source]

Initializes the phantom with the properties of the target image.

Sets up the phantom geometry using the provided image dimensions and voxel spacing, ensuring both are valid 3-element tuples.

Parameters:
  • cfg (yacs.config.CfgNode) – Configuration settings.

  • image_dims (tuple of int, shape (3,)) – Dimensions of the image (x, y, z) in voxels.

  • voxel_spacing (tuple of float, shape (3,)) – Size of each voxel (x, y, z) in mm.

Raises:
  • ValueError – If ‘image_dims’ does not contain exactly 3 elements.

  • ValueError – If ‘voxel_spacing’ does not contain exactly 3 elements.

image_dims: Tuple[int, int, int]

Image dimensions in voxels.

voxel_spacing: Tuple[float, float, float]

Voxel spacing in mm.

phantom_center_voxels: numpy.typing.NDArray.numpy.float64

Center of the phantom in voxel coordinates.

roi_definitions_mm: Any

ROI definitions in physical coordinates (mm).

rois: Dict[str, Dict[str, Any]]

Processed ROIs with voxel coordinates.

get_roi(name: str) Dict[str, Any] | None[source]

Retrieves the definition of a specific ROI by its name.

Provides efficient O(1) average time complexity for accessing ROI data by name.

Parameters:

name (str) – Name of the ROI to retrieve (e.g., ‘hot_sphere_10mm’).

Returns:

Dictionary with ROI properties (‘center_vox’, ‘radius_vox’) if found; otherwise, None.

Return type:

dict or None