# Convert DICOM-RTSTRUCT format to Nifti format

**URL:** <https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [December 3, 2017, 5:17am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580 "2017-12-03T05:17:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![glhfgg1024](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/glhfgg1024/32/947_2.png) [@glhfgg1024](https://discourse.slicer.org/u/glhfgg1024)\
**Post date:** [December 3, 2017, 5:17am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/1 "2017-12-03T05:17:52Z")

</div>

Hi all, I’m facing another problem. I’m using machine learning method to do segmentation for medical images, and at first I convert the DICOM files to Nifti format. I have several DICOM directories and their corresponding DICOM-RTSTRUCT file as the segmentation masks. The problem is: for several cases, the python script can convert the DICOM-RTSTRUCT file to a valid Nifti file, but for other cases, the generated Nifti file of DICOM-RTSTRUCT has inconsistency image origin information as that of the corresponding DICOM files. I have asked one physician in our group for help, he said that the files may come from different DICOM imaging system, and thus has different meta information. But the commercial software (like 3D Slicer) can handle these issues automatically. Could you please suggest some software to convert DICOM-RTSTRUCT file to Nifti format? It seems the 3D Slicer doesn’t have this functionality. 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:** [December 3, 2017, 6:13am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/2 "2017-12-03T06:13:00Z")

</div>

> [@How to show DICOM and the corresponding RT STRUCTURE?](https://discourse.slicer.org/t/how-to-show-dicom-and-the-corresponding-rt-structure/1562/3):
>
> Could you please suggest some software to convert DICOM-RTSTRUCT file to Nifti format? It seems the 3D Slicer doesn’t have this functionality.

Slicer can certainly read DICOM RTSTRUCT and save it as a labelmap in Nifti format.

> [@How to show DICOM and the corresponding RT STRUCTURE?](https://discourse.slicer.org/t/how-to-show-dicom-and-the-corresponding-rt-structure/1562/3):
>
> for other cases, the generated Nifti file of DICOM-RTSTRUCT has inconsistency image origin information as that of the corresponding DICOM files

By default, when you export a segmentation to a labelmap volume, Slicer uses the smallest necessary image extent, so the input grayscale volume’s geometry will not be the same as labelmap volume’s. If your software requires the grayscale and labelmap volumes to have the exact same geometry then you just need to specify the grayscale volume as reference volume for labelmap export (see Segmentations module Export/import… / Advanced section).

---

<div class="post-metadata">

**Author:** ![glhfgg1024](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/glhfgg1024/32/947_2.png) [@glhfgg1024](https://discourse.slicer.org/u/glhfgg1024)\
**Post date:** [December 3, 2017, 4:33pm UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/3 "2017-12-03T16:33:05Z")

</div>

@lassoan Thanks a lot! Now I can export the contours successfully!

---

<div class="post-metadata">

**Author:** ![Zone1314](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zone1314/32/3737_2.png) [@Zone1314](https://discourse.slicer.org/u/Zone1314)\
**Post date:** [May 22, 2019, 1:29am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/4 "2019-05-22T01:29:59Z")

</div>

Does the value of the ROI outline defined in the labelmap exported by this segmentation module be 1 or 0?

---

<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:** [May 22, 2019, 2:35am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/5 "2019-05-22T02:35:21Z")

</div>

If you export to labelmap, each segment will be assigned a unique voxel value, starting from 1. Voxel value of 0 means outside of all segments.

---

<div class="post-metadata">

**Author:** ![Zone1314](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zone1314/32/3737_2.png) [@Zone1314](https://discourse.slicer.org/u/Zone1314)\
**Post date:** [May 22, 2019, 7:30am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/6 "2019-05-22T07:30:24Z")

</div>

Thank you for your answer!

---

<div class="post-metadata">

**Author:** ![Marianne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianne/32/7886_2.png) [@Marianne](https://discourse.slicer.org/u/Marianne)\
**Post date:** [August 26, 2020, 8:53am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/7 "2020-08-26T08:53:28Z")

</div>

When I am saving a CTV RTstructure as a labelmap, I am not able to save this as a nifti. The choices are STL or OBJ. What am I missing here? I am using the T1 MRI as grayscale reference volume, and I need to save the labelmap as a nifti in order to use in python and compare to machine learning-derived CTV. Any suggestions? I am using 3Dslicer 4.10.2

---

<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:** [August 26, 2020, 9:18am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/8 "2020-08-26T09:18:23Z")

</div>

First of all, please use the latest nightly because 4.10.2 is almost two years old.

To save a segmentation as nifti, you need to export it to labelmap, but it seems you exported it to models.

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

Then you can save the labelmap to nifti using the save function

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/8/1820eecfdeb51bb29b8229ca09fb588aee36621c.png)

---

<div class="post-metadata">

**Author:** ![Marianne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianne/32/7886_2.png) [@Marianne](https://discourse.slicer.org/u/Marianne)\
**Post date:** [August 26, 2020, 10:07am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/9 "2020-08-26T10:07:47Z")

</div>

Thank you!! You made my day 🙂

---

<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/convert-dicom-rtstruct-format-to-nifti-format/1580/10 "2021-09-12T00:38:36Z")

</div>

A post was split to a new topic: [RT structure set has holes after exporting to labelmap](https://discourse.slicer.org/t/rt-structure-set-has-holes-after-exporting-to-labelmap/19625)

---

<div class="post-metadata">

**Author:** ![qaz158aaa](https://avatars.discourse-cdn.com/v4/letter/q/73ab20/32.png) [@qaz158aaa](https://discourse.slicer.org/u/qaz158aaa)\
**Post date:** [January 27, 2025, 7:00am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/11 "2025-01-27T07:00:59Z")

</div>

When I was about to create the binary map, the software just had no response. Do you know why? My version is the newest one.

---

<div class="post-metadata">

**Author:** ![qaz158aaa](https://avatars.discourse-cdn.com/v4/letter/q/73ab20/32.png) [@qaz158aaa](https://discourse.slicer.org/u/qaz158aaa)\
**Post date:** [January 27, 2025, 7:02am UTC](https://discourse.slicer.org/t/convert-dicom-rtstruct-format-to-nifti-format/1580/12 "2025-01-27T07:02:41Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/e/4e07d67cb4ad8783ea4ee9cabbf0981d75fc6891.jpeg)  
I choose this option.
