Trying to load RTStruct dicom file but tool crashes

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


I select the RTStruct option, it tries to load it but then the software crashes when the progress bar is at 50%

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

@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!

1 Like

Thanks for the response, I tried out the latest preview build , now it doesnt crash, but 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.

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.

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!

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

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?

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

Can you share this dataset with us so we can try?

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?

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 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.

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

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

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.

2 Likes

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.

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

1 Like