Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.73k stars 1.05k forks source link

FROC metrics for 3D data #5172

Closed akiliyiu closed 1 year ago

akiliyiu commented 2 years ago

Is your feature request related to a problem? Please describe. To be used on 3D data such as MRI, CT images

Additional context Notice that the current froc metrics only support 2d data, wonder if it is possible to extend it to 3d data? Thanks

kretes commented 1 year ago

The only method that needs to be adapted is:

def compute_fp_tp_probs(
    probs: NdarrayOrTensor,
    y_coord: NdarrayOrTensor,
    x_coord: NdarrayOrTensor,
    evaluation_mask: NdarrayOrTensor,
    labels_to_exclude: list | None = None,
    resolution_level: int = 0,
) -> tuple[NdarrayOrTensor, NdarrayOrTensor, int]:

from https://github.com/Project-MONAI/MONAI/blob/8e725aa2f3c50ffd1c0c45e8917d85f20c6637d0/monai/metrics/froc.py#LL22C1-L81C1

And it seems impossible to introduce 3D support without breaking the API.

I could submit a PR if we agree on an API. E.g.:

def compute_fp_tp_probs(
    probs: NdarrayOrTensor,
    coords: NdarrayOrTensor,    
    evaluation_mask: NdarrayOrTensor,
    labels_to_exclude: list | None = None,
    resolution_level: int = 0,
) -> tuple[NdarrayOrTensor, NdarrayOrTensor, int]:
    """
    Args:
        probs: an array with shape (n,) that represents the probabilities of the detections.
            Where, n is the number of predicted detections.
        coords: an array with shape (n, n_dim) that represents the coordinates of the detections in the same order as in `evaluation_mask`.        
        evaluation_mask: the ground truth mask for evaluation (need to have same n_dim dimensions).
        labels_to_exclude: labels in this list will not be counted for metric calculation.
        resolution_level: the level at which the evaluation mask is made.
     """

this one would support arbitrary dimensions

wyli commented 1 year ago

thanks, for backward compatibility, we can create compute_fp_tp_nd and then reimplement compute_fp_tp_probs using compute_fp_tp_nd. also I think resolution_level should be remain in compute_fp_tp_probs as that's not a generic ND concept.