I used a code to compute the 95HD and DSC to assess the segmentaion accuracy of medical image, and the following problem appered “ITK ERROR: MaskNegatedImageFilter(000001D7CB479830): Inputs do not occupy the same physical space!“. I was wondeirng whether I should do resampling? does that mean the two segmentaions have to have same physical space?
**Here is the code:
**
def compute_surface_dsc(label_a, label_b, tau=2.0):
“””Compute Surface Dice
From: Nikolov S et al. Clinically Applicable Segmentation of Head and Neck Anatomy for
Radiotherapy: Deep Learning Algorithm Development and Validation Study J Med Internet Res
2021;23(7):e26151, DOI: 10.2196/26151
Args:
label_a (sitk.Image): A mask to compare
label_b (sitk.Image): Another mask to compare
tau (float): Accepted deviation between contours (in mm)
Returns:
float: The Surface DSC between the two labels
"""
binary_contour_filter = sitk.BinaryContourImageFilter()
binary_contour_filter.FullyConnectedOn()
a_contour = binary_contour_filter.Execute(label_a)
b_contour = binary_contour_filter.Execute(label_b)
dist_to_a = sitk.SignedMaurerDistanceMap(
a_contour, useImageSpacing=True, squaredDistance=False
)
dist_to_b = sitk.SignedMaurerDistanceMap(
b_contour, useImageSpacing=True, squaredDistance=False
)
b_intersection = sitk.GetArrayFromImage(b_contour * (dist_to_a <= tau)).sum()
a_intersection = sitk.GetArrayFromImage(a_contour * (dist_to_b <= tau)).sum()
surface_sum = (
sitk.GetArrayFromImage(a_contour).sum()
+ sitk.GetArrayFromImage(b_contour).sum()
)
return (b_intersection + a_intersection) / surface_sum