From 9d0318c2bf00f64296834b872d08ca80429b476f Mon Sep 17 00:00:00 2001 From: Joeran Bosma Date: Thu, 22 Jun 2023 18:01:41 +0200 Subject: [PATCH] Implement `lesion_TPR_at_FPR` (#14) Calculate the lesion-level true positive rate (sensitivity) at a given false positive rate (average number of false positives per examimation) --- src/picai_eval/metrics.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/picai_eval/metrics.py b/src/picai_eval/metrics.py index 63eda8c..2d99e00 100644 --- a/src/picai_eval/metrics.py +++ b/src/picai_eval/metrics.py @@ -116,6 +116,13 @@ def score(self): """Calculate the ranking score, as used in the PI-CAI 22 Grand Challenge""" return (self.auroc + self.AP) / 2 + def lesion_TPR_at_FPR(self, FPR: float) -> float: + """Calculate the lesion-level true positive rate (sensitivity) at a given + false positive rate (average number of false positives per examimation)""" + if np.max(self.lesion_FPR) < FPR: + return 0 + return self.lesion_TPR[self.lesion_FPR <= FPR][-1] + # lesion-level results def get_lesion_results_flat(self, subject_list: Optional[List[str]] = None): """Flatten the per-case lesion evaluation results into a single list"""