task
Prefect task for the CST/CRT calculation step (v2).
Consumes two RAW inference caches — retinal-layers segmentation predictions and fovea v7 landmark predictions — plus the scan filter's filenames, and computes per-file Central Subfield Thickness / Central Retinal Thickness, plus the EZ-integrity measurement on the fovea-reference B-scan.
Identical to v1 but for the EZ block: it takes exactly the two inputs the EZ
measurement needs, already parses the fovea centre, and already builds the
boundary grid the measurement reads. Hosting it here rather than in a new step
saves the cache table, the step package, and every line of tabulation plumbing
— cst_metrics is already an input to biomarker_tabulation and the built
frame is driven by CSTMetrics.expected_cols(), so the new columns flow with
no wiring change.
The table is unchanged (cst_calculation, version 1). What moves is the
task_hash: it is a Merkle hash over the step's version and semantic config,
so v2 lands in a fresh partition and every existing CST/CRT value is
recomputed. That recompute is thickness maths over already-cached layer
inferences, not GPU re-inference — the model_inferences cache is upstream
and keyed by (model_ref, model_version). Rollback is pinning a template back
to v1, whose partition survives untouched.
Delegates the per-file orchestration to the shared
run_thickness_calculation runner (which GCC reuses unchanged) and the
metric maths to compute_cst_metrics_for_scan.
Runs in background mode: an in-memory result does not cross the phase boundary,
so the per-file metrics are persisted to the cst_calculation cache table
(keyed by (task_hash, file_id), project_id provenance-only) and a downstream
step reads them via the cst_calculation.cache accessor.
Module
Functions
cst_calculation_task_v2
def cst_calculation_task_v2( datasource: BaseSource, config: CSTCalculationConfigV2, layer_predictions: CacheAccessor, center_predictions: CacheAccessor, filenames: list[str], cache: CacheProtocol, task_hash: str, project_id: str | None = None, run_id: str | None = None,) ‑> CSTCalculationResult:Compute CST/CRT metrics for each file and persist them to cache.
Arguments
datasource: The datasource providing DICOM metadata (slice thickness, pixel spacing row/column) for each file.config: CST calculation configuration, including the EZ-integrity layer pair and threshold.layer_predictions: Cache accessor for retinal-layers model inference results (background stepretinal_layers_inference.cache).center_predictions: Cache accessor for fovea model inference results (background stepfovea_inference.cache).filenames: List of file IDs to process.cache: Cache instance to persist the CST metrics into.task_hash: Partition key for thecst_calculationtable; a config change lands in a fresh partition.project_id: Provenance only — the project that triggered this run. NOT part of the cache key: rows are keyed by(task_hash, file_id)so two projects on the same datasource share them.run_id: Optional provenance run ID.
Returns
CSTCalculationResult carrying the number of rows persisted and a
CacheAccessor scoped to this task_hash (cst_calculation.cache).