From 48e8ba39b634f96862899fc33120d4f89b790420 Mon Sep 17 00:00:00 2001 From: Phillip Chlap Date: Wed, 20 Dec 2023 12:05:39 +1100 Subject: [PATCH 1/2] Add HD 95 metric --- platipy/imaging/label/comparison.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platipy/imaging/label/comparison.py b/platipy/imaging/label/comparison.py index b59981fa..9425fb48 100644 --- a/platipy/imaging/label/comparison.py +++ b/platipy/imaging/label/comparison.py @@ -95,8 +95,7 @@ def compute_surface_metrics(label_a, label_b, verbose=False): std_sd_list = [] median_sd_list = [] num_points = [] - for (la, lb) in ((label_a, label_b), (label_b, label_a)): - + for la, lb in ((label_a, label_b), (label_b, label_a)): label_intensity_stat = sitk.LabelIntensityStatisticsImageFilter() reference_distance_map = sitk.Abs( sitk.SignedMaurerDistanceMap( @@ -118,6 +117,7 @@ def compute_surface_metrics(label_a, label_b, verbose=False): mean_surf_dist = np.dot(mean_sd_list, num_points) / np.sum(num_points) max_surf_dist = np.max(max_sd_list) + hd_95 = np.percentile(max_sd_list, 95) std_surf_dist = np.sqrt( np.dot( num_points, @@ -131,6 +131,7 @@ def compute_surface_metrics(label_a, label_b, verbose=False): result = {} result["hausdorffDistance"] = hd + result["hausdorffDistance95"] = hd_95 result["meanSurfaceDistance"] = mean_surf_dist result["medianSurfaceDistance"] = median_surf_dist result["maximumSurfaceDistance"] = max_surf_dist @@ -294,8 +295,7 @@ def compute_metric_masd(label_a, label_b, auto_crop=True): mean_sd_list = [] num_points = [] - for (la, lb) in ((label_a, label_b), (label_b, label_a)): - + for la, lb in ((label_a, label_b), (label_b, label_a)): label_intensity_stat = sitk.LabelIntensityStatisticsImageFilter() reference_distance_map = sitk.Abs( sitk.SignedMaurerDistanceMap( @@ -364,7 +364,6 @@ def compute_apl(label_ref, label_test, distance_threshold_mm=3): # iterate over each slice for i in range(n_slices): - if ( sitk.GetArrayViewFromImage(label_ref)[i].sum() + sitk.GetArrayViewFromImage(label_test)[i].sum() From 34e2ebb8f4fd86cbde9a1363099e60c58cc8fea7 Mon Sep 17 00:00:00 2001 From: Phillip Chlap Date: Wed, 20 Dec 2023 12:14:13 +1100 Subject: [PATCH 2/2] Update docstring --- platipy/imaging/label/comparison.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platipy/imaging/label/comparison.py b/platipy/imaging/label/comparison.py index 9425fb48..e154b999 100644 --- a/platipy/imaging/label/comparison.py +++ b/platipy/imaging/label/comparison.py @@ -74,8 +74,8 @@ def compute_surface_dsc(label_a, label_b, tau=3.0): def compute_surface_metrics(label_a, label_b, verbose=False): """Compute surface distance metrics between two labels. Surface metrics computed are: - hausdorffDistance, meanSurfaceDistance, medianSurfaceDistance, maximumSurfaceDistance, - sigmaSurfaceDistance, surfaceDSC + hausdorffDistance, hausdorffDistance95, meanSurfaceDistance, medianSurfaceDistance, + maximumSurfaceDistance, sigmaSurfaceDistance, surfaceDSC Args: label_a (sitk.Image): A mask to compare