functions
GCC-specific thickness calculation functions.
The shared retinal-layer primitives (parse_center_coordinates,
build_thickness_map, layer selection, etc.) live in
bitfount.steps.data_utils.thickness_metrics and are used by both the CST
and GCC steps. The shared per-file orchestration loop lives in
bitfount.steps.data_utils.thickness_calculation.
This module provides the GCC-specific glaucoma staging + region statistics
(GlaucomaStage, compute_gcc) and the high-level per-file
compute_gcc_metrics_for_scan — ported from _GCCWorkerSide in
federated/algorithms/ophthalmology/gcc_calculation_algorithm.py
(GlaucomaStage lines 39-54, _compute_gcc lines 184-309 and
_calculate_metric lines 107-182).
Module
Functions
compute_gcc
def compute_gcc( thickness_um: NDArray[Any], center_coords: tuple[float, float, float], slice_thickness_mm: float, pixel_spacing_x_mm: float, radius_mm: float = 1.0, metric_name: str = 'GCC',) ‑> GCCMetrics | str:Compute GCC asymmetry index and related metrics.
Ports _GCCWorkerSide._compute_gcc.
Arguments
thickness_um: Thickness map in micrometers, shape (num_slices, width).center_coords: Center coordinates (slice, x, y). Only slice and x are used.slice_thickness_mm: Slice thickness in mm.pixel_spacing_x_mm: Pixel spacing in x direction in mm.radius_mm: Radius of circular region in mm.metric_name: Name of the metric being calculated (log text only).
Returns
A GCCMetrics object with the computed values, or a
calculation_error:<detail> reason string when the region yields no
computable thickness — never a partial object.
compute_gcc_metrics_for_scan
def compute_gcc_metrics_for_scan( layer_pred: pd.Series, file_row: pd.Series, *, inner_layer: RetinalLayer, outer_layer: RetinalLayer, strict_measurement: bool, landmark_idx: int, radius_mm: float, center_landmark_type: str = 'macula', metric_name: str = 'GCC',) ‑> GCCMetrics | str:Calculate GCC for a single file.
Ports _GCCWorkerSide._calculate_metric. Per-instance configuration
that the legacy worker read from self is passed as explicit parameters.
Arguments
layer_pred: Layer segmentation predictions for one file.file_row: Row containing DICOM metadata and macula predictions.inner_layer: Desired inner layer for the thickness measurement.outer_layer: Desired outer layer for the thickness measurement.strict_measurement: If True, only calculate if both desired inner and outer layers are available (no fallback).landmark_idx: Index of the landmark to use (0=start, 1=end, 2=middle).radius_mm: Radius of the circular region in mm.center_landmark_type: Nature of the center landmark ("fovea"/"macula").metric_name: Name of the metric being calculated (log text only).
Returns
A GCCMetrics object for a computable file, or a reason string when
the file cannot be computed — missing_data:<fields> for absent
inputs, calculation_error:<detail> for compute failures. Never a
partial object: an incomplete result would give false confidence that a
real measurement was produced.
Classes
GlaucomaStage
class GlaucomaStage(*args, **kwds):Enum to indicate stage of Glaucoma.
Methods
next_level
def next_level(self) ‑> GlaucomaStage:Get one stage worse than current stage.