loli / medpy

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

reduce redundant computation when computing multiple surface distance-based metrics #102

Closed FabianIsensee closed 6 months ago

FabianIsensee commented 3 years ago

Hi there,

is there a specific reason for __surface_distances being hidden with the __ prefix? Imagine someone (hint: me :-) ) would like to compute multiple surface-based metrics for the same predicted segmentation (ASD, ASSD, HD, HD95 etc). Right now the surface distances (which are expensive to be computed) will need to be recomputed for each metric: that can be a lot of redundant computation.

Suggestion: 1) make __surface_distances accessible by removing the __ prefix 2) let all surface metrics take surface_distances=None as additional argument. If it is None, the distances are computed (like they are right now). But users could also choose to precompute the distances and pass them to multiple surface-based metrics and thus save a lot of computation.

Would you be willing to accept a PR on this?

(we would somehow need to handle gt->pred and pred-> gt distances which are sometimes needed, sometimes not. Maybe using two input arguments, one for each)

Best,

Fabian

FabianIsensee commented 3 years ago

correction: I can import __surface_distances with from medpy.metric.binary import __surface_distances but that is not good practice because __ is telling users not to import it

loli commented 3 years ago

Sorry for the late reply. Sure I would accept a PR on that :)

loli commented 6 months ago

Closed due to inactivity.