LIVIAETS / boundary-loss

Official code for "Boundary loss for highly unbalanced segmentation", runner-up for best paper award at MIDL 2019. Extended version in MedIA, volume 67, January 2021.
https://doi.org/10.1016/j.media.2020.101851
MIT License
652 stars 98 forks source link

Distances on GT boundaries #8

Closed maxmanko closed 5 years ago

maxmanko commented 5 years ago

Thank you for your loss function, it exceeded all my expectations. I applied it to solving the problem of pulmonary nodules segmentation, implementing this loss function in Keras framework.

You reset the distances for pixels that are on the edges of GT: res [c] = distance (negmask) * negmask - (distance (posmask) - 1) * posmask Thus, these pixels are not included in the loss function. Would it be better to take these pixels into account in the loss function? res [c] = distance (negmask) * negmask - distance (posmask) * posmask

HKervadec commented 5 years ago

The rationale, when I implemented it, was that we compute the distance to the boundary. By this logic, the distance of the boundary wrt the boundary should be 0. Since this not the behavior of the SciPy function distance_transform_edt. I did that manually by shifting the distance by 1 on the distance to the positive mask.

To be fair, I do not think it would change (much) the results, since it is only shifting the distance values inside the object. But I did not had time to compare the impact of this implementation detail.

JunMa11 commented 5 years ago

Hi @maxmanko , would it be possible for you to share your keras implementation of surface loss?

zye1996 commented 3 years ago

The rationale, when I implemented it, was that we compute the distance to the boundary. By this logic, the distance of the boundary wrt the boundary should be 0. Since this not the behavior of the SciPy function distance_transform_edt. I did that manually by shifting the distance by 1 on the distance to the positive mask.

To be fair, I do not think it would change (much) the results, since it is only shifting the distance values inside the object. But I did not had time to compare the impact of this implementation detail.

Hi, I have a question about the -1 shift here. If the distance of boundary wrt the boundary is 0, then the boundary would not contribute to loss and thus is not supervised. Will it affect the performance of small objects?

HKervadec commented 3 years ago

Hello,

Will it affect the performance of small objects?

Now that you mention it, it could be a possiblity on very small objects (such as very thin blood vessels). In that case, it could be worth your time to compare the two; with and without that shift. But I think as long as you have an area with a negative distance map, you should be good.

(That could actually be a new assertion to be included into the function ; that some negative area exists.)

Best,

Hoel