Biba
Biba

Reputation: 651

Incorrect results when using simpleITK STAPLE algotithm in python

I'm trying to generate ground truth segmentation using SimpleITK STAPLE algorithm in python. The code looks like this:

segmentations = [sitk.ReadImage(file_name, sitk.sitkUInt8) for file_name in in segmentation_file_names]

foregroundValue = 255

threshold = 0.5

reference_segmentation_STAPLE_probabilities = sitk.STAPLE(segmentations, foregroundValue)

reference_segmentation_STAPLE = reference_segmentation_STAPLE_probabilities > threshold

For testing purposes i have two segmentations that i want to merge into ground truth (segmentations[0] and segmentations[1]). When displayed they look like this:

enter image description here enter image description here

But displaying reference_segmentation_STAPLE results in: enter image description here

I assumed, that the result should be a structure similar to segmentations[0] and [1]. Is my assumption wrong or my implementation incorrect?

Upvotes: 1

Views: 818

Answers (1)

Nikolay Burlutsky
Nikolay Burlutsky

Reputation: 46

I faced a similar problem recently. Assuming that your image is a binary array of zeros and 255s, I'd suggest you to convert the array to [0,1] and then choose foregroundValue = 1. At least this approach helped me to solve a similar issue.

Good luck!

Upvotes: 1

Related Questions