autods_pet.ops.stats#
Statistics helpers for voxel-level image analysis.
For computing multiple statistics on the same image/mask pair, prefer
compute_stats() over calling individual functions (e.g.
mean_in_mask(), max_in_mask()). compute_stats extracts
the masked voxel array once and reuses it for all requested statistics,
avoiding redundant O(n) array copies per call.
- autods_pet.ops.stats.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.stats.mean_in_mask(img, mask)[source]#
Return the arithmetic mean of voxel values inside mask.
- autods_pet.ops.stats.voxelwise_median(img, mask)[source]#
Return the median of voxel values inside mask.
- autods_pet.ops.stats.compute_stats(stat_names, img, mask)[source]#
Compute multiple named statistics for img inside mask.
- autods_pet.ops.stats.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.stats.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.stats.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: