ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
643 stars 163 forks source link

Calculation of Jaccard's Metric #157

Closed willi3by closed 4 years ago

willi3by commented 4 years ago

Is your feature request related to a problem? Please describe. I am attempting to calculate the registration quality of a set of scans to template space. The patients in the study are acute stroke patients with lesions and the analysis is dependent on acceptable registration to MNI space. To assess this, I want to use Jaccard's metric.

Describe the solution you'd like Is there a way to calculate Jaccard's metric in ANTSpy?

Describe alternatives you've considered I am also open to other metrics and best practices for lesioned brains. From my reading, it just seemed like this was the best metric for registration quality.

stnava commented 4 years ago

probably correct for dice metric - no promises

img1 = ants.image_read( ants.get_data("r16") ).threshold_image("Otsu",3)
img2 = ants.image_read( ants.get_data("r27") ).threshold_image("Otsu",3)
s1 = ants.threshold_image(img1,3,3)
s2 = ants.threshold_image(img2,3,3)
dice = 2.0 * ( ( s1 + s2 ) == 2 ).sum() / ( s1.sum() + s2.sum() )
stnava commented 4 years ago

closing due to lack of interest on user's part.

willi3by commented 4 years ago

Yes, sorry I forgot to respond. I actually found both Dice and Jaccard functions in SimpleITK. Thanks for the reply

ntustison commented 4 years ago

In case anybody finds this issue, the functionality now exists in ANTsPy. The underlying ITK code is the same.

willi3by commented 4 years ago

Excellent! Thanks for the follow up!