Hi,
I have NIFTI files of sizes (512 x 512 x 150) of auto-segmentation and manual segmentation. Each file/slice contains the segmentation of multiple regions (seven regions). I want to compute the dice score, Hausdorff distance, Jaccard index, and average surface distance.
Could you please suggest the easiest method for that purpose? I don’t want to convert NIFTI to PNGs/JPEGs. I tried the plastimatch dice. It seems that it doesn’t work for multi-region segmentation. Please find the command and relevant output of plastimatch. Please suggest if I am missing anything or if there is a better approach.
The Segment Comparison module in the SlicerRT extension allows you to compute Dice and Hausdorff on segmentations containing multiple labels. You’ll need to first convert the labelmap volumes to segmentation nodes (in Segmentations module Import/Export section, or in the Data module by right-clicking the labelmap volume).
@cpinter Thanks a lot! It worked. I love Slicer! Btw, some features can be improved and can be made more interactive by incorporating some sort of automation. For example, the “Segment Comparison” tool should have the Box/tick option for all segments rather than the drop-down menu.
@cpinter Could you please point out where can I find the source code for Segment Comparison module (Version 5.2.2). I’m getting different values of dice score for 3D binary nifti masks when using 3D Slicer and Monai framework. This is the monai function I’m using:
def calculate_dice_score(predicted, ground_truth):
dice_metric = monai.metrics.DiceMetric(include_background=False, reduction="mean")
# Convert the predicted and ground truth masks to PyTorch tensors
predicted_tensor = torch.from_numpy(predicted)
ground_truth_tensor = torch.from_numpy(ground_truth)
# Reshape tensors to have batch size and number of channels
predicted_tensor = predicted_tensor.unsqueeze(0).unsqueeze(0)
ground_truth_tensor = ground_truth_tensor.unsqueeze(0).unsqueeze(0)
# Calculate the Dice score
dice_score = dice_metric(y_pred =predicted_tensor, y = ground_truth_tensor)
return dice_score.item()
@cpinter thank you. However I have trouble locating Dice and Hausdorff from SlicerRT extension. I’m using Slicer 5.6. Could you please point me where they are.
@cpinter , thanks for getting back to me. I use 14.2 (23C64) on an Apple M1 Pro. I couldn’t find this Segment Comparison module on Slicer 5.6 and Slicer 5.6.1. But I was able to find it on Slicer 5.2 after I revert it back.