# Trying to load RTStruct dicom file but tool crashes

**URL:** <https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177>\
**Category:** Support\
**Created:** [August 26, 2020, 1:20pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177 "2020-08-26T13:20:13Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [August 26, 2020, 1:20pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/1 "2020-08-26T13:20:13Z")

</div>

Hi All,

I have a binary segmentation mask which I converted to nifti format and using the original dicom files I converted that to an RTStruct dicom file.

But when I try to load the RTStruct file it crashes the tool. I tried to load it by dragging and dropping the folder containing the dicom files and the RTstruct file, when I do so it asks me if I want to load the RTstruct or some other referenced dataset

 ![slicer3derr](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/4/34de1a5385f6882ba4302f6968984c46f906ba24.png)  
I select the RTStruct option, it tries to load it but then the software crashes when the progress bar is at 50%

---

<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:** [August 26, 2020, 1:31pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/2 "2020-08-26T13:31:17Z")

</div>

I can take a look at it. Can you upload the RTSTRUCT somewhere and send me a message with a link to it?

---

<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, 1:36pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/3 "2020-08-26T13:36:07Z")

</div>

@Gabriel_T I see from the screenshot that you probably use a not so recent version. Can you please try the latest nightly? (@Sunderlandkyl please hold until this is confirmed).  
Thanks!

---

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [August 31, 2020, 12:40am UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/4 "2020-08-31T00:40:27Z")

</div>

Thanks for the response, I tried out the latest preview build , now it doesnt crash, but slicer3d still isnt loading anything.

---

<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 31, 2020, 8:07am UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/5 "2020-08-31T08:07:33Z")

</div>

> [@Gabriel\_T](#):
>
> slicer3d still isnt loading anything.

If you provide more information we might be able to help. What do you do exactly? What do you expect to happen? What happens instead? An error log is also useful. Thank you.

---

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [August 31, 2020, 2:39pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/6 "2020-08-31T14:39:43Z")

</div>

Thanks for the response.

I had generated a segmentation mask in the form of a numpy array, I was trying to load this segmentation mask in Slicer3D so I converted the numpy array to an RTStruct file. I’m not sure if I constructed the right RTStruct file or what may be wrong with it. Please can you advice ? I was trying to load the generated segmentation masks onto slicer3D for editing and viewing.

---

<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 31, 2020, 2:46pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/7 "2020-08-31T14:46:11Z")

</div>

So the one thing I now know is that you exported an RT structure set using Slicer and tried to load it.

Then what happens? Please describe the _exact steps_ you take before you encounter the problem you mentioned. Also as I said please include an error log. Thanks!

---

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [August 31, 2020, 2:55pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/8 "2020-08-31T14:55:11Z")

</div>

Steps taken -  
Dragged folder containing dicom files and RTStruct file to Slicer  
It loads the folder in, then in Dicom Database I select the Series with RTSTRUCT Modality. When I do so it loads nothing, all I see are empty axial, coronal, saggital images (black images).  
Here is the error log -

Traceback (most recent call last):  
File “C:\Users\gabri\AppData\Local\NA-MIC\Slicer 4.11.0-2020-08-29\lib\Slicer-4.11\qt-scripted-modules\DICOMLib\DICOMBrowser.py”, line 221, in timerCallback  
self.promptForExtensions()  
File “C:\Users\gabri\AppData\Local\NA-MIC\Slicer 4.11.0-2020-08-29\lib\Slicer-4.11\qt-scripted-modules\DICOMLib\DICOMBrowser.py”, line 226, in promptForExtensions  
extensionsToOffer = self.checkForExtensions()  
File “C:\Users\gabri\AppData\Local\NA-MIC\Slicer 4.11.0-2020-08-29\lib\Slicer-4.11\qt-scripted-modules\DICOMLib\DICOMBrowser.py”, line 289, in checkForExtensions  
instance0 = slicer.dicomDatabase.filesForSeries(series)[0]  
IndexError: tuple index out of range

---

<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 31, 2020, 3:09pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/9 "2020-08-31T15:09:15Z")

</div>

Thank you for the details!

When you exported the dataset it also exported an anatomical volume alongside the RTSS. If you try to load the whole study with both series, do you still have the same problem?

---

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [August 31, 2020, 3:17pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/10 "2020-08-31T15:17:19Z")

</div>

When I loaded the whole study with both the CT modality and the RTStruct modality I still get empty images

Traceback (most recent call last):  
File “C:\Users\gabri\AppData\Local\NA-MIC\Slicer 4.11.0-2020-08-29\lib\Slicer-4.11\qt-scripted-modules\DICOMLib\DICOMUtils.py”, line 675, in getLoadablesFromFileLists  
loadablesByPlugin[plugin] = plugin.examine(fileLists)  
File “C:/Users/gabri/AppData/Local/NA-MIC/Slicer 4.11.0-2020-08-29/bin/…/lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py”, line 112, in examine  
loadables += self.examineFilesIPPAcqTime(files)  
File “C:/Users/gabri/AppData/Local/NA-MIC/Slicer 4.11.0-2020-08-29/bin/…/lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py”, line 343, in examineFilesIPPAcqTime  
desc = slicer.dicomDatabase.fileValue(files[0],self.tags[‘seriesDescription’]) # SeriesDescription  
IndexError: tuple index out of range  
DICOM Plugin failed: tuple index out of range

---

<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 31, 2020, 3:23pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/11 "2020-08-31T15:23:31Z")

</div>

Can you share this dataset with us so we can 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:** [August 31, 2020, 4:42pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/12 "2020-08-31T16:42:45Z")

</div>

Thanks for sharing it! I was also not able to load the structure set. However I don’t see the error messages you pasted. What I receive are error logs such as

`LoadContour: Contour sequence object item is invalid: number of contour points is 51 therefore expected 153 values in contour data but only found 51`

I did a segmentation on the CT you provided using Segment Editor, exported the result in DICOM-RT, and managed to load it back.

1. Did you do the segmentation in Segment Editor?
2. What kind of structures did you segment? For example were they very small/thin?
3. How did you export the dataset?

---

<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:** [August 31, 2020, 7:41pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/13 "2020-08-31T19:41:11Z")

</div>

Also note that if you use DICOM RT structure set because you just want to import planar contours, then you don’t need to go through DICOM. Instead, you can directly create planar contours segmentation representation using a simple Python script, as it is done in Slicer’s OsiriX segmentation importer ([ImportOsirixROI module](https://github.com/PerkLab/SlicerSandbox/tree/master/ImportOsirixROI) in Sandbox extension).

By the way, using planar contours for representing 3D segmentation is not a good idea. There is just too much difficulty and uncertainty creating a 3D shape from cross-sections and it does not work for arbitrarily complex shapes.

---

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [August 31, 2020, 10:59pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/14 "2020-08-31T22:59:54Z")

</div>

I see those errors too, what could the reason be for expecting multiple of 3 values ?

1. No the segmentation was generated through deep learning
2. Just the left ventricular wall, it was not small , it occupied about half the number of slices
3. The CT modality dicom files were directly from scanner, the RTStruct file I created using pydicom

---

<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:** [August 31, 2020, 11:59pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/15 "2020-08-31T23:59:00Z")

</div>

> [@Gabriel\_T](#):
>
> I see those errors too, what could the reason be for expecting multiple of 3 values ?

You must have multiple of 3 values (each point is specified by 3 coordinates).

> [@Gabriel\_T](#):
>
> the segmentation was generated through deep learning

What is the output of the segmentation? Yes/no (or probability) for each voxel? If yes, then don’t bother with creating RTSTRUCT representation, but keep it as labelmap and save as DICOM Segmentation Object. Alternatively, you may choose to just save in a research format (nrrd or mha) and convert to DICOM in Slicer.

---

<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 1, 2020, 7:56am UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/16 "2020-09-01T07:56:58Z")

</div>

> [@Gabriel\_T](#):
>
> No the segmentation was generated through deep learning

In this case the RTStruct file is probably not valid. As @lassoan says each point needs three coordinates, but apparently there is only one value. Maybe when you generated the values the coordinates were not separated. Consider this for example:

`33.703125\-147.92120098039214\-193.0\33.36004901960784`

Is it possible that the second and fourth values are actually three numbers that were not separated?

By the way, @lassoan is also right in that if you generate your segmentation with deep learning then you could use a much simpler format. RT structure set is an archaic format that introduces data loss because along one axis its resolution is very low, it does not handle holes or complex structures well, etc. You’d be better off using DICOM SEG, or nrrd.

---

<div class="post-metadata">

**Author:** ![Gabriel\_T](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gabriel_t/32/4222_2.png) [@Gabriel\_T](https://discourse.slicer.org/u/Gabriel_T)\
**Post date:** [September 1, 2020, 3:25pm UTC](https://discourse.slicer.org/t/trying-to-load-rtstruct-dicom-file-but-tool-crashes/13177/17 "2020-09-01T15:25:13Z")

</div>

Thanks for the suggestion, nrrd format works best for me, I was able to visualize the segmentations on slicer3d properly by importing the segmentation mask in .nrrd format as well as the dicom volume in the same .nrrd format
