pymia
pymia copied to clipboard
[feature request] Please add center line dice score to the evaluation pkg
Please do add center line dice score to the evaluation pkg. described here: https://arxiv.org/abs/2003.07311
We came up with this probably very inefficient implementation (not tested):
from skimage.morphology import skeletonize, skeletonize_3d
class ClDice(INumpyArrayMetric):
"""
Represents the clDice Metric as defined in: https://arxiv.org/abs/2003.07311
"""
def __init__(self, metric: str = 'CLDICE'):
"""Initializes a new instance of the DiceCoefficient class.
Args:
metric (str): The identification string of the metric.
"""
super().__init__(metric)
def calculate(self):
"""Calculates the clDice coefficient."""
gt = self.ground_truth
seg = self.segmentation
gt_cl = skeletonize_3d(gt)
seg_cl = skeletonize_3d(seg)
cl_sc_rec = (np.sum(seg*gt_cl)*1.0)/(np.sum(seg*gt_cl)*1.0)
cl_sc_prec = (np.sum(gt*seg_cl)*1.0)/(np.sum(gt*seg_cl)*1.0)
f1_cl = 2*((cl_sc_prec*cl_sc_rec)/(cl_sc_prec+cl_sc_rec))
return f1_cl
Thanks! :7