verse icon indicating copy to clipboard operation
verse copied to clipboard

computation of dice

Open rijobro opened this issue 3 years ago • 4 comments

Hi,

I was looking at your implementation of the dice score.

I notice that in your example notebook, the image is loaded and passed straight into compute_dice function without any pre-processing.

The input image is not one-hotted (np.unique returns [ 0. 16. 17. 18. 19. 20. 21. 22. 23. 24.]), but then is converted to a boolean (im1 = np.asarray(im1).astype(bool)). This means that you can get a dice of 1 if you correctly differentiate foreground and background, even if all labels are incorrect. Am I missing something or is this intentional?

## compute dice

true_msk_arr =  true_msk.get_fdata()
pred_msk_arr =  pred_msk.get_fdata()
wrong = pred_msk_arr.copy()
wrong[wrong > 0] = 100

dice = compute_dice(pred_msk_arr, true_msk_arr)
dice2 = compute_dice(pred_msk_arr, wrong)

print('Dice: {:.2f}'.format(dice))
print('Dice2: {:.2f}'.format(dice2))

Output: Dice: 1.00 Dice2: 1.00

rijobro avatar Nov 30 '21 10:11 rijobro

Thank you for pointing this out. The dice should indeed be computed vertebra wise. The notebook only tells you there is a function for this. I will update the notebook to only compute the dice for one vertebra, so it is clear.

anjany avatar Dec 02 '21 15:12 anjany

Thanks. So for the competition, did you do the average across all labels present in a given image? And then average this across all images in the dataset?

rijobro avatar Dec 02 '21 21:12 rijobro

Yes for both. This is what is reported in the VerSe MedIA manuscript. However, for determining the winner I adopted a pairwise-significance test to check which algorithm is better, not the average across all images.

anjany avatar Dec 03 '21 10:12 anjany

Great, thanks.

rijobro avatar Dec 03 '21 16:12 rijobro