labeledTubuli,numberTubuli=label(np.asarray(labelmap==1,np.uint8))# datatype of 'labeledTubuli': int32
foriinrange(1,numberTubuli+1):
result[binary_dilation(binary_dilation(binary_dilation(labeledTubuli==i)))]=np.random.randint(low=0,high=256,size=3,dtype=np.uint8)# assign random colors to tubuli
logger.info('[# WARNING #] Label(s): '+str(np.argwhere(label_GT_occurrences==0).flatten()+1)+' not present at all in predictions and ground-truth of current dataset!')
Compute mean dice scores of predicted foreground labels.
NOTE: Dice scores of missing gt labels will be excluded and are thus represented by -1 value entries in returned dice score matrix!
NOTE: Method changes prediction to 0/1 values in the binary case!
:param prediction: BxCxHxW (if 2D) or BxCxHxWxD (if 3D) FloatTensor (care: prediction has not undergone any final activation!) (note: C=1 for binary segmentation task)
:param segBatch: BxCxHxW (if 2D) or BxCxHxWxD (if 3D) FloatTensor (Onehot-Encoding) or Bx1xHxW (if 2D) or Bx1xHxWxD (if 3D) LongTensor