Implements functions for ground truth estimation from the annotations of multiple experts. Based on SimpleITK.

Helper Functions

Installing SimpleITK, which is not a dependency of deepflash2.



Ground Truth Estimation

Simultaneous truth and performance level estimation (STAPLE)

The STAPLE algorithm considers a collection of segmentations and computes a probabilistic estimate of the true segmentation and a measure of the performance level represented by each segmentation.

Source: Warfield, Simon K., Kelly H. Zou, and William M. Wells. "Simultaneous truth and performance level estimation (STAPLE): an algorithm for the validation of image segmentation." IEEE transactions on medical imaging 23.7 (2004): 903-921


staple(segmentations, foregroundValue=1, threshold=0.5)

STAPLE: Simultaneous Truth and Performance Level Estimation with simple ITK

Majority Voting

Use majority voting to obtain the reference segmentation. Note that this filter does not resolve ties. In case of ties it will assign the backgtound label (0) to the result.


m_voting(segmentations, labelForUndecidedPixels=0)

Majority Voting from simple ITK Label Voting

GT Estimator

Class for ground truth estimation


msk_show(ax, msk, title, cbar=None, ticks=None, **kwargs)

class GTEstimator[source]

GTEstimator(exp_dir='expert_segmentations', config=None, path=None, cmap='viridis', verbose=1) :: GetAttr

Class for ground truth estimation

exp_dir = Path('deepflash2/sample_data/expert_segmentations')
files=['0004_mask.png', '0001_mask.png']
t = GTEstimator(exp_dir=exp_dir);
t.gt_estimation(method='majority_voting', save_dir='mv_test')
t.show_gt(method='majority_voting', max_n=2)