How to pass a specific label to LabelOverlapMeasuresImageFilter

i would like to get values of the overlap measures for specific labels in my masks, and not just the averaged values for all mask labels.
In the original code of Nick Tustison that was possible, but i do not find how to get it in sitk.

Thank you and kind regards,

Hello @TanjaIvanovska,

This is a missing feature in SimpleITK, please create an issue on github.

As a temporary workaround the following should work:

#Assume we have label images with the following names
# reference_segmentation
# new_segmentation

label_list = [0,1,2]
def compute_overlap_measures(segmentation1, segmentation2, label):
    overlap_measures_filter = sitk.LabelOverlapMeasuresImageFilter()
    overlap_measures_filter.Execute(segmentation1==label, segmentation2==label)
    # List of all overlap measures we are interested in.
    return [overlap_measures_filter.GetDiceCoefficient(),

overlap_measures_per_label = [compute_overlap_measures(reference_segmentation, new_segmentation, label) for label in label_list]

1 Like