med-air / Endo-FM

[MICCAI'23] Foundation Model for Endoscopy Video Analysis via Large-scale Self-supervised Pre-train
Apache License 2.0
154 stars 15 forks source link

Question about metric #18

Open Lycus99 opened 4 months ago

Lycus99 commented 4 months ago

Thanks for your work. I have a question about the metric used in TransUNet. In the /TransUNet/trainer.py file, I found the metrics defined as follows:

def calculate_metric_percase(pred, gt): pred[pred > 0] = 1 gt[gt > 0] = 1 if pred.sum() > 0 and gt.sum() > 0: dice = medpy.metric.binary.dc(pred, gt) hd95 = medpy.metric.binary.hd95(pred, gt) return dice, hd95 elif pred.sum() > 0 and gt.sum() == 0: return 1., 0. else: return 0., 0.

I think when pred.sum()==0 and gt.sum()==0, the dice score should be 1.0, not 0.0, and when pred.sum()>0 and gt.sum()==0, the dice score should be calculated by taking the complement of the original pred and gt.

Kyfafyd commented 4 months ago

Hi @Lycus99 , thanks for your interest! For this metric, we directly adopt it from https://github.com/Beckschen/TransUNet, you can refer to this discussion: https://github.com/Beckschen/TransUNet/issues/39