MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / compute_froc_curve_data

Function compute_froc_curve_data

monai/metrics/froc.py:122–155  ·  view source on GitHub ↗

This function is modified from the official evaluation code of `CAMELYON 16 Challenge `_, and used to compute the required data for plotting the Free Response Operating Characteristic (FROC) curve. Args: fp_probs: an array that conta

(
    fp_probs: np.ndarray | torch.Tensor, tp_probs: np.ndarray | torch.Tensor, num_targets: int, num_images: int
)

Source from the content-addressed store, hash-verified

120
121
122def compute_froc_curve_data(
123 fp_probs: np.ndarray | torch.Tensor, tp_probs: np.ndarray | torch.Tensor, num_targets: int, num_images: int
124) -> tuple[np.ndarray, np.ndarray]:
125 """
126 This function is modified from the official evaluation code of
127 `CAMELYON 16 Challenge <https://camelyon16.grand-challenge.org/>`_, and used to compute
128 the required data for plotting the Free Response Operating Characteristic (FROC) curve.
129
130 Args:
131 fp_probs: an array that contains the probabilities of the false positive detections for all
132 images under evaluation.
133 tp_probs: an array that contains the probabilities of the True positive detections for all
134 images under evaluation.
135 num_targets: the total number of targets (excluding `labels_to_exclude`) for all images under evaluation.
136 num_images: the number of images under evaluation.
137
138 """
139 if not isinstance(fp_probs, type(tp_probs)):
140 raise AssertionError("fp and tp probs should have same type.")
141 if isinstance(fp_probs, torch.Tensor):
142 fp_probs = fp_probs.detach().cpu().numpy()
143 if isinstance(tp_probs, torch.Tensor):
144 tp_probs = tp_probs.detach().cpu().numpy()
145
146 total_fps, total_tps = [], []
147 all_probs = sorted(set(list(fp_probs) + list(tp_probs)))
148 for thresh in all_probs[1:]:
149 total_fps.append((fp_probs >= thresh).sum())
150 total_tps.append((tp_probs >= thresh).sum())
151 total_fps.append(0)
152 total_tps.append(0)
153 fps_per_image = np.asarray(total_fps) / float(num_images)
154 total_sensitivity = np.asarray(total_tps) / float(num_targets)
155 return fps_per_image, total_sensitivity
156
157
158def compute_froc_score(

Callers 2

evaluateMethod · 0.90
test_valueMethod · 0.90

Calls 1

appendMethod · 0.45

Tested by 1

test_valueMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…