make new indexes and added pfroc

This commit is contained in:
Stefan
2022-04-25 10:22:45 +02:00
parent 5d4eaf6e28
commit cd86205896
6 changed files with 53 additions and 26 deletions

View File

@@ -4,3 +4,4 @@ from .data_utils import *
from .cal_froc_from_np import *
from .blob_preprocess import *
from .analysis_utils import *
from .p_auc import *

25
src/sfransen/FROC/p_auc.py Executable file
View File

@@ -0,0 +1,25 @@
import numpy as np
def partial_auc(sensitivity, fp_per_patient, low=0.1, high=2.5):
"""
Calculates partial area-under-the-curve from FROC sensitivity/FPP curve.
"""
# Remove all values above min and max FPP
clipped_sens, clipped_fpp = [0.], [0.]
max_sens_before_window = 0
max_fpp_before_window = 0
for sens, fpp in zip(sensitivity, fp_per_patient):
if fpp < low and fpp > max_fpp_before_window:
max_sens_before_window = sens
if fpp >= low and fpp <= high:
clipped_sens.append(sens)
clipped_fpp.append(fpp)
# Extend the window to the limits supplied by the user
clipped_sens = [max_sens_before_window] + clipped_sens + [clipped_sens[-1]]
clipped_fpp = [low] + clipped_fpp + [high]
# Integrate y(x) with the trapezoid rule
return np.trapz(clipped_sens, clipped_fpp)