loli / medpy

Medical image processing in Python
http://loli.github.io/medpy/
GNU General Public License v3.0
559 stars 136 forks source link

Should Dice coefficient for empty result and empty reference be 1? #106

Closed baumgach closed 1 year ago

baumgach commented 2 years ago

Hi there,

This issue is in reference to the following line:

https://github.com/loli/medpy/blob/39131b94f0ab5328ab14a874229320efc2f74d98/medpy/metric/binary.py#L79

Shouldn't an empty reference and an empty result set output a Dice coefficient of 1 rather than 0? I.e. if no pixels of a class are present in the image and no mask is predicted, then the prediction is correct. Or am I missing something here?

(For the Jaccard coefficient the division by 0 detection seems to be missing altogether.)

Thanks and best wishes, Christian

loli commented 1 year ago

Thanks for noticing!