Hi All,

Could you please point out where can I find the source code for Segment Comparison module (Slicer version 5.2.2). I’m getting different values of dice score for 3D binary nifti masks when using 3D Slicer and the 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()
```

Please note that I have tried both mean and sum for reduction method and still getting different values from Slicer and Monai .

Thank you!