# DiceComputation module does not calculate

**URL:** <https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757>\
**Category:** Support\
**Created:** [January 2, 2018, 8:31pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757 "2018-01-02T20:31:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![aharris](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aharris/32/892_2.png) [@aharris](https://discourse.slicer.org/u/aharris)\
**Post date:** [January 2, 2018, 8:31pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/1 "2018-01-02T20:31:40Z")

</div>

I have segmented label maps from two imaging modalities (3D ultrasound and MRI), and have performed a registration and transformation between them. When the Hausdorff distance option is clicked in the DiceComputation module I get numbers in the results matrix. However, with the Dice option clicked, clicking the Compute button doesn’t do anything. Any suggestions?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 3, 2018, 12:37am UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/2 "2018-01-03T00:37:14Z")

</div>

You can also try Segment Comparison module in SlicerRT extension. It computes both Dice and Hausdorff.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 3, 2018, 12:48pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/3 "2018-01-03T12:48:48Z")

</div>

I tried the DiceComputation extension and it worked fine for me with two labelmaps generated from the same source volume (using the legacy editor on the MRHead from SampleData). @aharris perhaps your volume data is not in the same pixel space and needs to be resampled. Check in the error log for clues.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 3, 2018, 3:32pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/4 "2018-01-03T15:32:11Z")

</div>

Segment comparison module in SlicerRT extension takes care of all transformations and resampling. It works on segmentation nodes, if you have labelmaps or models then you can convert them into segmentation using Import section of Segmentations module.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/b/ab06d212ac93bcfd32af00ac8649b4c5638c1a60.png)

---

<div class="post-metadata">

**Author:** ![aharris](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aharris/32/892_2.png) [@aharris](https://discourse.slicer.org/u/aharris)\
**Post date:** [January 5, 2018, 5:43pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/5 "2018-01-05T17:43:26Z")

</div>

This worked, thanks!

---

<div class="post-metadata">

**Author:** ![carnico](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@carnico](https://discourse.slicer.org/u/carnico)\
**Post date:** [September 21, 2020, 9:17am UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/6 "2020-09-21T09:17:22Z")

</div>

Dear Slicer users,

I post here to not open a new discussion.

I just try to use the Segment Comparison module in SlicerRT, but the calculated Dice coefficient is always 1. I’m using latest Slicer nightly on macOS.

How can I resolve this problem?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/b/1baaf13c6732ef3cf458aae2c330acf9b031f26c.jpeg)

Thanks a lot.

Best Regards

P.s.: I also cannot find on slicer extension manager the [DiceComputation](http://slicer.kitware.com/midas3/slicerappstore/extension/view?extensionId=39201) extension, which I would like to try.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 21, 2020, 9:41am UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/7 "2020-09-21T09:41:09Z")

</div>

Based on your screenshot the two segments do not overlap, so the calculation based on this is correct.

In order to have two segments that have overlapping parts and meaningful dice, you need to either

1. Enable overlapping in Segment Editor before drawing the second segment, or
2. Use different segmentations for the two regions

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/3/036c0639de1dd81812ab58a7ad1ddb9d2aa38cef.png)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 21, 2020, 2:57pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/8 "2020-09-21T14:57:47Z")

</div>

DSC should be 0 if there is no overlap, so indeed there is something wrong here.

@Sunderlandkyl I suspect that Segment Comparison module was not updated to handle merged labelmaps. Could you please check if this and other SlicerRT modules use the correct API for getting labelmap representations?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [September 21, 2020, 3:27pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/9 "2020-09-21T15:27:55Z")

</div>

OK, I need to re-compile SlicerRT and then I can submit a PR.

Most of the modules in SlicerRT seem to be fine, except for a couple (SegmentComparison, RoomsEyeView, SegmentMorphology) that use vtkSlicerSegmentationsModuleLogic::GetSegmentRepresentation() / GetSegmentBinaryLabelmapRepresentation().

I can fix this in SegmentComparison (and vtkSlicerRoomsEyeViewModuleLogic) by getting the individual non-shared labelmap with vtkSegmentationNode::GetBinaryLabelmapRepresentation().

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 21, 2020, 3:32pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/10 "2020-09-21T15:32:16Z")

</div>

Thank you @Sunderlandkyl.

It seems that SegmentMorphology module does the same as Margin effect and Logical operators effect. Maybe we could just remove it, to reduce SlicerRT maintenance burden. @cpinter what do you think?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 21, 2020, 3:48pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/11 "2020-09-21T15:48:00Z")

</div>

> [@lassoan](#):
>
> DSC should be 0 if there is no overlap

Yes this is actually true. Thanks @Sunderlandkyl for fixing this!

> [@lassoan](#):
>
> It seems that SegmentMorphology module does the same as Margin effect and Logical operators effect. Maybe we could just remove it, to reduce SlicerRT maintenance burden.

I have thought about this as well, but didn’t have time to check if some workflow or other extension relies on this etc. But in theory I agree, it is basically a duplication of features.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 21, 2020, 4:10pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/12 "2020-09-21T16:10:07Z")

</div>

> [@cpinter](#):
>
> I have thought about this as well, but didn’t have time to check if some workflow or other extension relies on this etc. But in theory I agree, it is basically a duplication of features.

SegmentMorphology module was developed when Segment Editor did not have these features, so it made sense then, but not necessary now. We have the option of A. fix it now and commit to its maintenance, 2. remove it now and fix&maintain if it turns out that somebody needs it. I would vote for B.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 21, 2020, 4:14pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/13 "2020-09-21T16:14:04Z")

</div>

Absolutely, I agree.

I just said I haven’t removed the Segment Morphology module because for that I wanted to check if another extension used that particular module. You have a build machine so doing that check should be easy. If nobody else uses the module, then it can be removed.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 21, 2020, 4:21pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/14 "2020-09-21T16:21:55Z")

</div>

SegmentMorphology module is not used in any other extensions. It is not used either in SlicerRT workflow tests. So, removing it should not disrupt anything.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 21, 2020, 6:17pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/15 "2020-09-21T18:17:29Z")

</div>

@Sunderlandkyl, since you already have a SlicerRT build configured, would you mind submitting a pull request that removes SegmentMorphology module? Thank you!

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [September 21, 2020, 6:30pm UTC](https://discourse.slicer.org/t/dicecomputation-module-does-not-calculate/1757/16 "2020-09-21T18:30:35Z")

</div>

OK, PR made here: [https://github.com/SlicerRt/SlicerRT/pull/156](https://github.com/SlicerRt/SlicerRT/pull/156).
