scan_metric_names
Shared canonical naming for CST/GCC/fluid scan-metric columns.
The single home for the canonical technical column names of the CST/GCC/fluid
scan metrics, so both biomarker_tabulation (CSV feeder) and criteria_matching
(eligibility) resolve biomarker columns by identical names. These names are
DEFINED here; the calc steps that emit the metrics conform to them — the canon
does not belong to any one consumer.
Module
Functions
apply_canonical_scan_metric_names
def apply_canonical_scan_metric_names( df: pd.DataFrame, metrics_type: type,) ‑> pandas.core.frame.DataFrame:Rename a scan-metrics frame's columns to their canonical scan-metric names.
CST/GCC descriptor collisions become cst_*/gcc_*; fluid scalars gain the
fluid_ prefix and the per-scan segmentation_volumes dict column is
flattened into fluid_<label>_volume columns (absent label or non-dict cell
→ pd.NA) then dropped. Any other metrics type is returned unchanged. The
ORIGINAL_FILENAME_METADATA_COLUMN merge key is never renamed (it is not in
any rename map).
Arguments
df: The per-scan metrics frame produced byconvert_metrics_to_df.metrics_type: The metrics dataclass the frame's rows conform to.
Returns The frame with canonical column names. A metrics type needing no transform is returned unchanged (and unmutated); otherwise a copy.
canonical_scan_metric_field_specs
def canonical_scan_metric_field_specs( metrics_type: type,) ‑> list[FieldSpec]:FieldSpecs for a scan-metrics type, named to match the canonical frame.
Applies the same rename as apply_canonical_scan_metric_names to each of
the type's field_specs() (so a column_criteria targeting a canonical
name resolves), and for fluid appends the three flattened
fluid_<label>_volume columns (which field_specs_from_dataclass skips
because segmentation_volumes is a container). A type without field_specs
contributes nothing rather than raising.
Arguments
metrics_type: The metrics dataclass ascan_metricssource declares.
Returns
The canonical-named FieldSpec list (empty for an unrecognised type).
named_source_canonical_columns
def named_source_canonical_columns() ‑> frozenset[str]:Canonical column names owned by the statically-named metrics sources.
Derived from the dataclasses rather than hand-listed, so a column added to
one of them is accounted for without anyone remembering to update a literal
— the same reasoning as _shared_descriptor_fields.
Two callers need it, and both are about the <group>_<metric> shape being
ambiguous. fluid_distance_from_image_centre is fluid's own canonically
prefixed field, but it is also exactly what a lesion group named fluid
would emit: LesionCalculationConfig rejects such a group so the column can
only be fluid's, and CriteriaMatchConfig must not mistake a criterion on it
for a lesion-group criterion.
Returns Every canonical column name across the GA, fluid, CST and GCC metrics.