autods_pet.ops#
Operations subpackage: mask manipulation and statistics.
- autods_pet.ops.compute_stats(stat_names, img, mask)[source]#
Compute multiple named statistics for img inside mask.
- autods_pet.ops.count_voxels(mask)[source]#
Count non-zero voxels in a binary mask.
- Parameters:
mask (
Image) – Binary mask image.- Returns:
Number of non-zero voxels.
- Return type:
- autods_pet.ops.fill_holes(mask, max_hole_volume_mm3=None)[source]#
Fill holes in a binary mask.
- Parameters:
- Returns:
Binary
uint8mask with holes filled.- Return type:
Image
- autods_pet.ops.keep_largest_component(mask)[source]#
Keep only the largest connected component of a binary mask.
- Parameters:
mask (
Image) – Binary mask (non-zero values are foreground).- Returns:
Binary
uint8mask containing only the largest connected component. If the mask is empty, returns the input unchanged.- Return type:
Image
- autods_pet.ops.label_mask(seg, label)[source]#
Extract a binary mask for a single label from a multilabel segmentation.
- Parameters:
seg (
Image) – Multilabel segmentation image (integer-valued).label (
int) – The label value to extract.
- Returns:
Binary
uint8mask where the selected label is 1 and all else is 0.- Return type:
Image
- autods_pet.ops.mask_volume_mm3(mask)[source]#
Compute the physical volume of non-zero voxels in mm3.
- Parameters:
mask (
Image) – Binary mask image with valid spacing metadata.- Returns:
Volume in mm3.
- Return type:
- autods_pet.ops.mean_in_mask(img, mask)[source]#
Return the arithmetic mean of voxel values inside mask.
- autods_pet.ops.percentile_in_mask(img, mask, pct)[source]#
Return the pct-th percentile of voxel values inside mask.
- Parameters:
img (
Image) – Scalar image (e.g. PET SUVbw).mask (
Image) – Binary mask selecting the voxels of interest.pct (
float) – Percentile in the range[0, 100].
- Returns:
The requested percentile, or
Noneif the mask is empty.- Return type:
- Raises:
ValueError – If pct is outside
[0, 100].
- autods_pet.ops.shrinkage_report(original, refined)[source]#
Compute voxel-count and physical-volume deltas between two masks.
- Parameters:
original (
Image) – Binary mask before refinement (e.g. raw segmentation).refined (
Image) – Binary mask after refinement (e.g. eroded version).
- Returns:
Keys:
original_voxels,refined_voxels,original_volume_mm3,refined_volume_mm3,delta_voxels,delta_volume_mm3,shrinkage_pct.- Return type: