# Incorrect number of segments when loading DICOM segmentation file

**URL:** <https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387>\
**Category:** Support\
**Tags:** segmentation, dicom\
**Created:** [March 8, 2022, 10:11pm UTC](https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387 "2022-03-08T22:11:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeepaKrishnaswamy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/deepakrishnaswamy/32/8913_2.png) [@DeepaKrishnaswamy](https://discourse.slicer.org/u/DeepaKrishnaswamy)\
**Post date:** [March 8, 2022, 10:11pm UTC](https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387/1 "2022-03-08T22:11:06Z")

</div>

Hi,

I created and saved a DICOM segmentation file:  
 ![create_segments](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/7/e731b22c3dc4add64d041c84cf4bb2ddf9a00d25.jpeg)

I checked the logs, and it seems to have exported successfully. However, when I load this file, it seems that the number of regions is doubled:  
 ![load_seg_dicom_error](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/2/02e8efbb5bf3f730713ced13b64a3b4b2166f245.jpeg)

Checking the logs, I see the following errors:

 ![load_log_error_1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/f/3fa538f992a5860a554a8f44c619f4ed4e902abf.jpeg)  
 ![load_log_error_2](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/c/fc11c40d3918534d884fe51a908e83b2e9cc0400.jpeg)

I’m unsure of how to debug this, thanks!

Deepa

---

<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:** [March 9, 2022, 6:31am UTC](https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387/2 "2022-03-09T06:31:15Z")

</div>

I could not reproduce this issue with the latest Slicer Preview Release? Could you please check if that version works well for you, too?

---

<div class="post-metadata">

**Author:** ![DeepaKrishnaswamy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/deepakrishnaswamy/32/8913_2.png) [@DeepaKrishnaswamy](https://discourse.slicer.org/u/DeepaKrishnaswamy)\
**Post date:** [March 9, 2022, 6:13pm UTC](https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387/3 "2022-03-09T18:13:08Z")

</div>

Previously I was using Slicer 4.13.0-2022-01-26, but the same issue occurs when switching to the latest Slicer preview release. It seems to happen when multiple segments are present. With a single segment, the DICOM SEG file seems to load successfully – but when I check the logs, the same warnings/errors are present (as above) concerning the AnatomicContext.

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [March 9, 2022, 9:13pm UTC](https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387/4 "2022-03-09T21:13:20Z")

</div>

I was able to reproduce the issue. Here’s the sample dataset (I am not sure if the slice location mismatch pointed to by the second red arros is an issue or not, since I did not create the sample - that might be a “red herring”): [Dropbox - prostate\_repeatability\_mpReview\_Andrey.zip - Simplify your life](https://www.dropbox.com/s/d3pyl6moin4giq8/prostate_repeatability_mpReview_Andrey.zip?dl=0).

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/9/89f327f871b50d0b0e2fcded14d5b92bcc7c31fd.jpeg)

---

<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:** [March 10, 2022, 1:07am UTC](https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387/5 "2022-03-10T01:07:03Z")

</div>

I’ve submitted a pull request with the fix:

> <https://github.com/QIICR/QuantitativeReporting/pull/264>
>
> Single-slice segmentations were loaded as an image stack (from files 1.nrrd, 2.n…rrd, ...), therefore each volume contained every label.
> Fixed by enforcing loading each nrrd file as a single file.
> 
> Fixes the problem described at https://discourse.slicer.org/t/incorrect-number-of-segments-when-loading-dicom-segmentation-file/22387

The problem was that the ITK interpreted the single-slice images as an image volume by default. Fixed by forcing loading each segment labelmap with single-file option.
