# RT structure set has holes after exporting to labelmap

**URL:** <https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625>\
**Category:** Support\
**Tags:** segmentation, radiotherapy\
**Created:** [September 11, 2021, 8:02am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625 "2021-09-11T08:02:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 11, 2021, 8:02am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/1 "2021-09-11T08:02:11Z")

</div>

Hi, I‘m facing another problem when I perform these operations. After export labelmap, the labelmap I got is missing some information. this picture is before export

 ![_before](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/9/09286d916e339cf142b00bf949c91f28e4f02f96.jpeg)

this one is after export

 ![_after](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/5/e5669ef71ca52a8fa915f9d3d0c2b5bfa6d43006.jpeg)

could u tell me why? Thanks a lot.

---

<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 12, 2021, 12:38am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/2 "2021-09-12T00:38:47Z")

</div>

It looks like that the RT structure set is invalid (multiple contours are specified for the same slice). What software did you use to create this? Can you send a download link to the anonymized data set so that we can have a look?

---

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 12, 2021, 1:45am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/3 "2021-09-12T01:45:38Z")

</div>

Thank you, you are right, a slice does have multiple contours. I have found a python package called “dcmrtstruct2nii”, it can convert DICOM-RTSTRUCT format to Nifti format.

---

<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 12, 2021, 1:54am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/4 "2021-09-12T01:54:12Z")

</div>

What software created this contour?

dcmrtstruct2nii uses an incorrect algorithm for contour conversion, based on a misinterpretation of the DICOM standard. If the software that created the RT structure set similarly misinterpreted the DICOM standard then the result may be good (the two errors cancel out each other). However, in general, you should not use neither the software that created these invalid contour, nor dcmstruct2nii.

---

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 12, 2021, 3:25am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/5 "2021-09-12T03:25:42Z")

</div>

sorry, I don’t know what software created this contour. After I converted rtstru with dcmrtstruct2nii and opened it with ITK-SNAP software, it seemed to be correct. As shown in this picture ![1631417109(1)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/8/2802e274445715df6918bcb028db6e8ed8eb989c.png)  
. Is it the case you mention? (the two errors cancel out each other) .

---

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 12, 2021, 5:13am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/6 "2021-09-12T05:13:06Z")

</div>

Another strange thing happened, some rtstruct can use 3d slicer to export to labelmap without holes, but its image dimension become smaller. As show in the picture

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/c/3c2ebe7334a90f13d7f87d706a4cdd900ef8d1a1.png)  
It’s original size should be 512_512_227

These questions really bother me. Hope can get your help. thanks!

---

<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 12, 2021, 11:42am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/7 "2021-09-12T11:42:30Z")

</div>

We enabled this feature (automatic cropping of the voxel array to minimize file size) by default in earlier Slicer versions. However, this caused complications when people wanted to press these images in software that ignored physical space information. So, we changed the behavior and in current Slicer Stable Release and Slicer Preview Release we don’t crop the exported labelmaps to the minimum necessary size by default anymore.

---

<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 12, 2021, 12:21pm UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/8 "2021-09-12T12:21:18Z")

</div>

> [@liuhuaying](#):
>
> I don’t know what software created this contour

Where did you get the data sets from? I would contact them and tell them to either fix their data sets or offer them in other formats.

---

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 13, 2021, 1:40am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/9 "2021-09-13T01:40:31Z")

</div>

I use Slicer 4.11.20210226 and Slicer 4.13.0-2021-09-07 versions, they both automatically crop the labelmap without holes to minimize the file size.

---

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 13, 2021, 1:44am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/10 "2021-09-13T01:44:50Z")

</div>

The data came from a hospital. The doctor said they used commercial software, but I had no way to get these commercial software. Can I use the data transferred from dcmrtstruct2nii? Will using them cause any other problems?

---

<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 13, 2021, 2:09pm UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/11 "2021-09-13T14:09:39Z")

</div>

> [@liuhuaying](#):
>
> I use Slicer 4.11.20210226 and Slicer 4.13.0-2021-09-07 versions, they both automatically crop the labelmap without holes to minimize the file size.

These Slicer versions use the segmentation geometry as output, which is determined from the first selected master volume. If you want to use a specific volume’s geometry in the segmentation then you can [choose that volume as reference volume](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentations.html#export-segmentation-to-labelmap-volume).

> [@liuhuaying](#):
>
> The data came from a hospital. The doctor said they used commercial software, but I had no way to get these commercial software. Can I use the data transferred from dcmrtstruct2nii? Will using them cause any other problems?

Let us know if you get to know what software they are using exactly and how. Maybe they do some conversion or anonymization step that messes up the original data or the segmentation tool is not used properly or not DICOM compliant.

---

<div class="post-metadata">

**Author:** ![issakomi](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@issakomi](https://discourse.slicer.org/u/issakomi)\
**Post date:** [September 13, 2021, 4:09pm UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/12 "2021-09-13T16:09:57Z")

</div>

> [@lassoan](#):
>
> It looks like that the RT structure set is invalid (multiple contours are specified for the same slice).

Interesting. IMHO, ROI for something concave that looks like e.g. tooth with two roots will have several slices with one contour, several with two. Do you think it is invalid? BTW, there is new type [CLOSEDPLANAR\_XOR](http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.8.8.6.3.html#figure_C.8.8.6-2), it works only with multiple contours of one ROI per slice, per definition. Or do you mean “duplicated contours are specified for the same slice”, i have seen such data sets, it were bad, of course.

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [September 13, 2021, 4:45pm UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/13 "2021-09-13T16:45:30Z")

</div>

What the O.P. is seeing looks like a display bug. I have seen similar.

You are correct, it’s totally fine to have multiple closed contours on a single slice. Or even not on a slice. And thank you for the reference about CLOSEDPLANAR\_XOR, this is new to me. 3D Slicer (plastimatch) uses XOR rather than keyholing for export, but with the CLOSED\_PLANAR. I wonder which systems would recognize and use CLOSEDPLANAR\_XOR.

---

<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 13, 2021, 5:26pm UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/14 "2021-09-13T17:26:01Z")

</div>

I meant that overlapping planar contours are invalid - or at least they were, until CLOSEDPLANAR\_XOR has been introduced. I have never seen CLOSEDPLANAR\_XOR before and I would be really sad if vendors chose to put another twist on an already horrible segmentation representation instead of adopting DICOM Segmentation Object.

The [correction proposal that introduced CLOSEDPLANAR\_XOR](http://dicom.nema.org/Dicom/News/September2020/docs/cpack108/cp2037.pdf) - submitted by Varian and BrainLab engineers - indicates that the goal is to manage the misuse of the DICOM standard by “current implementation base of RT Structure Set” (it is unclear what software they refer to), by making it easier for treatment planning systems to reject XOR-style overlapping contours:

> For safety reasons, it should be possible to express this different technique, while assuring that systems that do not support this can still operate safely and not consume contours using this different technique.

Probably we’ll need to wait for several more years to see if treatment planning system developers will start generating or accepting CLOSEDPLANAR\_XOR themselves or they go and adopt second-generation DICOM RT objects ([2G RT](https://www.dicomstandard.org/news/supplements/view/2g-rt-objects-prescription-and-segment-annotation)) instead. 2G RT promotes using common DICOM segmentation representations for “conceptual volume” definition in contrast to just locking into RT structure sets:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/7/470cf22642efb45f150b298d94a0925548ba43e7.png)

(_[source](https://www.dicomstandard.org/docs/librariesprovider2/dicomdocuments/news/ftsup/docs/sups/sup1475b81dad3499240fb8d4df9d98e4c29b0.pdf)_)

---

<div class="post-metadata">

**Author:** ![liuhuaying](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@liuhuaying](https://discourse.slicer.org/u/liuhuaying)\
**Post date:** [September 14, 2021, 2:48am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/15 "2021-09-14T02:48:11Z")

</div>

Thank you all, I will try to discuss with the hospital to see what’s going on.

---

<div class="post-metadata">

**Author:** ![issakomi](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@issakomi](https://discourse.slicer.org/u/issakomi)\
**Post date:** [September 18, 2021, 2:48am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/16 "2021-09-18T02:48:29Z")

</div>

> [@gcsharp](#):
>
> 3D Slicer (plastimatch) uses XOR rather than keyholing for export, but with the CLOSED\_PLANAR. I wonder which systems would recognize and use CLOSEDPLANAR\_XOR.

Probably Varian may use CLOSEDPLANAR\_XOR in a near future or uses already (Varian and BrainLab submitted the correction proposal). It looks like a kind of legalization of the technique they used already, e.g. screenshot with Varian’s ROI (CLOSED\_PLANAR), blue (“Bones”)

 ![20210913-183532](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/e/4e812207271ef5a2e651b1f7c517871431bfa0b0.jpeg)

I have created [test data set](https://drive.google.com/file/d/1hNH4NQfOuBGVHtfW4P5I8IqYopKxdTJ1/view?usp=sharing), seems that SlicerRT has no problem with the new contour type, at least at a first look.

 ![Screenshot at 2021-09-18 00-53-41](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/3/53ec1cabb242e4d4ca39ca6646c1c57c405e201f.png)

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [September 20, 2021, 7:26pm UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/17 "2021-09-20T19:26:19Z")

</div>

Thanks! The result looks good.

---

<div class="post-metadata">

**Author:** ![David\_Clunie](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/david_clunie/32/10689_2.png) [@David\_Clunie](https://discourse.slicer.org/u/David_Clunie)\
**Post date:** [October 11, 2023, 10:50am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/18 "2023-10-11T10:50:57Z")

</div>

The link to the test dataset illustrated doesn’t seem to work - can you repost the test data or link to a persistent location for it please?

---

<div class="post-metadata">

**Author:** ![Mik](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@Mik](https://discourse.slicer.org/u/Mik)\
**Post date:** [October 11, 2023, 11:08am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/19 "2023-10-11T11:08:32Z")

</div>

XOR test data set

> **[xor\_test.7z](https://disk.yandex.ru/d/iy2UnV0spDCLvA)**
>
> Посмотреть и скачать с Яндекс Диска

---

<div class="post-metadata">

**Author:** ![David\_Clunie](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/david_clunie/32/10689_2.png) [@David\_Clunie](https://discourse.slicer.org/u/David_Clunie)\
**Post date:** [October 11, 2023, 11:26am UTC](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625/20 "2023-10-11T11:26:50Z")

</div>

Thanks.

This reminds me that I need to add CP 2037 CLOSEDPLANAR\_XOR Contour Geometric Type to dicom3tools dciodvfy.
