Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error in calculation of DICE scores #30

Open
gdims opened this issue Apr 29, 2021 · 0 comments
Open

Possible error in calculation of DICE scores #30

gdims opened this issue Apr 29, 2021 · 0 comments

Comments

@gdims
Copy link

gdims commented Apr 29, 2021

In segmentation.py:
https://github.com/echonet/dynamic/blob/master/echonet/utils/segmentation.py

, lines #175-#178, there are the following 4 lines of code:

loss, large_inter, large_union, small_inter, small_union = echonet.utils.segmentation.run_epoch(model, dataloader, phase == "train", optim, device)

overall_dice = 2 * (large_inter.sum() + small_inter.sum()) / (large_union.sum() + large_inter.sum() + small_union.sum() + small_inter.sum())

large_dice = 2 * large_inter.sum() / (large_union.sum() + large_inter.sum())

small_dice = 2 * small_inter.sum() / (small_union.sum() + small_inter.sum())

If I understand correctly, the large_inter, large_union, small_inter, small_union returned by run_epoch() are lists, with a length equal to the number of dataset items. To output one (large, small or overall) DICE value for the whole epoch, it would be reasonable to take the average (large, small or overall) DICE accross dataset items. However, the above code does something different: It sums the enumerators separately, sums the denominators separately, and then divides them.
This is not equal to averaging the individual DICE scores.

Was it done this way intentionally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant