Export DICOM RT structure as segmentation

Hi,
I am trying to convert a DICOM RT structure file to STL file through exporting a segmentation from 3D Slicer 4.10.0. The segmentation was successfully loaded in Slicer by opening the DICOM RT Structure.
I can view the structure and edit it as a segmentation just fine. However, I tried to export it using the “Segment Editor” module and selected “Export to files” under “Segmentations”. Nothing is showing up in the destination folder or anywhere else.
Your help is greatly appreciated!

1 Like

What do you mean by “edit it as a segmentation just fine”? Loaded RT structure sets cannot directly be edited, so I suspect there is something strange going on here. Are you sure you are trying to edit and export the right dataset?

It would help if you’d either make a video of what you’re doing from the beginning, or describe each step in a very detailed manner. Thanks!

Thank you! You are right. I had to convert it to binary label map before editing, but that’s prompted properly and straightforward. The problem was exporting afterwards.

The problem is fixed now. I guess Slicer is having trouble dealing with the imported RT Structure as a segmentation. I created a new segmentation on the CT images and dragged that structure into the new segmentation and everything was fine. I am able to export.

I’m glad it works for you. I’d still feel better if I understood what is going wrong with your original approach. If you’re content with this solution I understand, but it would help us if you made a video or explained why exactly the first try didn’t go well.

Sure. I’ll submit the pictures on Monday. Thank you for following up on this.

Hi Csaba,
Here are the screenshots I took this morning regarding the export STL problem. I hope the pictures are self explanatory. Please let me know if you need additional information. Thank you for looking into this.

Yixiang
Import1 Import2 Edit1

1 Like

Export1 Export2

And the file is not appearing in the destination folder.
Export3

I’ll try to reproduce the issue you’ve had.

One question though. If you haven’t changed anything in the segmentation then why did you go through the Segment Editor route? It’s not necessary to change the master representation to labelmap to export it to STL.
Also no need to copy anything to another segmentation. Instead you can go to Segmentations module, make sure Closed surface is created (there should be a green tick next to it), go to Import/Export section towards the bottom, and do the STL export from there.

Thanks so much for the images, they are a great help!

I managed to reproduce the problem: the character ‘:’ is not allowed in file names. If you rename the segmentation to not have the colon character, then export is successful.
We will fix this to automatically replace the illegal characters.

However I still recommend not to go throudh Segment Editor and instead do what I described above, because going from surface to labelmap to surface again comes with data loss.

Thank you, Csaba! I needed to modify the structure a little bit to clean up the artifacts. But I will keep it in mind of the alternative method. Thanks!

Yixiang

I see. I’m already working on a solution for the illegal file name issue. It should be available in tomorrow’s nightly if all goes well, and then you won’t have to rename or copy.

1 Like

I fixed the issue in this commit: https://github.com/Slicer/Slicer/commit/2c39ac184feb665d0a1f229b9fa089656a45612a
Tomorrow’s nightly should be good. Thanks for helping us fix this problem!

1 Like

Hi Csaba,
I met with the similar problem and I followed your instructions. But still nothing is showing up in the destination folder or anywhere else. Your help is greatly appreciated!

02 03

Finally when I moved or copied to another segmentation, it worked out well. But I wonder whether it is the same as RTst which relates to the original image? And could you tell me how to extract the coordinate information of the contour? Thank you. 04 05

Can you please

  1. Start a fresh Slicer
  2. Load the RTSS
  3. Try to export it the way your screenshot shows
  4. Send us the log (About / Report an error)

Thanks!

Sorry I didn’t find where to upload the .log file.

Log
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Session start time .......: 2019-04-18 09:01:13
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Slicer version ...........: 4.11.0-2018-12-21 (revision 27668) win-amd64 - installed release
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Operating system .........: Windows / 7 / Service Pack 1 (Build 7601) - 64-bit
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Memory ...................: 3964 MB physical, 7927 MB virtual
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - CPU ......................: GenuineIntel , 4 cores, 4 logical processors
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - VTK configuration ........: OpenGL2 rendering, TBB threading
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Developer mode enabled ...: no
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Prefer executable CLI ....: yes
[DEBUG][Qt] 18.04.2019 09:01:13 [] (unknown:0) - Additional module paths ..: C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SegmentMesher/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/CleaverExtension/lib/Slicer-4.11/cli-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/OpenCAD/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SlicerElastix/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SlicerRT/lib/Slicer-4.11/cli-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SlicerRT/lib/Slicer-4.11/qt-loadable-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SlicerRT/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/MeshToLabelMap/lib/Slicer-4.11/cli-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/IntensitySegmenter/lib/Slicer-4.11/cli-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/MarkupsToModel/lib/Slicer-4.11/qt-loadable-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SegmentationWizard/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/VolumeClip/lib/Slicer-4.11/qt-scripted-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/ScatteredTransform/lib/Slicer-4.11/cli-modules, C:/Users/Administrator/AppData/Roaming/NA-MIC/Extensions-27668/SegmentEditorExtraEffects/lib/Slicer-4.11/qt-scripted-modules
[DEBUG][Python] 18.04.2019 09:01:19 [Python] (C:\Program Files\Slicer 4.11.0-2018-12-21\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: Annotations
[DEBUG][Python] 18.04.2019 09:01:21 [Python] (C:\Program Files\Slicer 4.11.0-2018-12-21\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentEditor
[DEBUG][Python] 18.04.2019 09:01:21 [Python] (C:\Program Files\Slicer 4.11.0-2018-12-21\lib\Slicer-4.11\qt-scripted-modules\SubjectHierarchyPlugins\AbstractScriptedSubjectHierarchyPlugin.py:36) - Scripted subject hierarchy plugin registered: SegmentStatistics
[DEBUG][Qt] 18.04.2019 09:01:22 [] (unknown:0) - Switch to module:  "Welcome"
[DEBUG][Qt] 18.04.2019 09:01:25 [] (unknown:0) - Switch to module:  "DICOM"
[DEBUG][Qt] 18.04.2019 09:01:41 [] (unknown:0) - New patient inserted: 18
[DEBUG][Qt] 18.04.2019 09:01:41 [] (unknown:0) - New patient inserted as :  18
[DEBUG][Qt] 18.04.2019 09:01:41 [] (unknown:0) - Need to insert new study:  "1.2.840.113704.1.111.4716.1524036773.1"
[DEBUG][Qt] 18.04.2019 09:01:41 [] (unknown:0) - Study Added
[DEBUG][Qt] 18.04.2019 09:01:41 [] (unknown:0) - Need to insert new series:  "1.2.840.113704.1.111.4716.1524036821.7"
[DEBUG][Qt] 18.04.2019 09:01:41 [] (unknown:0) - Series Added
[DEBUG][Qt] 18.04.2019 09:01:43 [] (unknown:0) - "DICOM indexer has successfully processed 79 files [1.81s]"
[INFO][Python] 18.04.2019 09:01:44 [Python] (C:\Program Files\Slicer 4.11.0-2018-12-21\lib\Slicer-4.11\qt-scripted-modules\DICOMLib\DICOMWidgets.py:471) - Imported a DICOM directory, checking for extensions
[INFO][Stream] 18.04.2019 09:01:44 [] (unknown:0) - Imported a DICOM directory, checking for extensions
[DEBUG][Qt] 18.04.2019 09:01:50 [] (unknown:0) - Found patient in the database as UId:  18
[DEBUG][Qt] 18.04.2019 09:01:50 [] (unknown:0) - Used existing study:  "1.2.840.113704.1.111.4716.1524036773.1"
[DEBUG][Qt] 18.04.2019 09:01:50 [] (unknown:0) - Study Added
[DEBUG][Qt] 18.04.2019 09:01:50 [] (unknown:0) - Need to insert new series:  "2.16.840.1.114362.1.11826050.22065096001.513296353.681.20"
[DEBUG][Qt] 18.04.2019 09:01:50 [] (unknown:0) - Series Added
[DEBUG][Qt] 18.04.2019 09:01:50 [] (unknown:0) - "DICOM indexer has successfully processed 1 files [0.04s]"
[INFO][Python] 18.04.2019 09:01:52 [Python] (C:\Program Files\Slicer 4.11.0-2018-12-21\lib\Slicer-4.11\qt-scripted-modules\DICOMLib\DICOMWidgets.py:471) - Imported a DICOM directory, checking for extensions
[INFO][Stream] 18.04.2019 09:01:52 [] (unknown:0) - Imported a DICOM directory, checking for extensions
[DEBUG][Python] 18.04.2019 09:01:55 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py:455) - MultiVolumeImportPlugin::examine
[DEBUG][Python] 18.04.2019 09:01:55 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py:495) - DICOMMultiVolumePlugin found 0 multivolumes!
[DEBUG][Python] 18.04.2019 09:01:55 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py:455) - MultiVolumeImportPlugin::examine
[DEBUG][Python] 18.04.2019 09:01:56 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py:495) - DICOMMultiVolumePlugin found 1 multivolumes!
[DEBUG][Python] 18.04.2019 09:01:58 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py:165) - MultiVolumeImportPlugin:examineMultiseries
[DEBUG][Python] 18.04.2019 09:01:58 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/MultiVolumeImporterPlugin.py:170) - DICOMMultiVolumePlugin found 0 multivolumes!
[INFO][Stream] 18.04.2019 09:01:59 [] (unknown:0) - Loading series '1: RTSTRUCT: RTstruct' from file 'D:/crayon/workspace/Images/zhangyanhua/0418zyh/1/RTSTRUCT14642.1.dcm'
[INFO][Python] 18.04.2019 09:01:59 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/DICOMScalarVolumePlugin.py:301) - Loading with imageIOName: GDCM
[WARNING][Python] 18.04.2019 09:02:01 [Python] (C:/Program Files/Slicer 4.11.0-2018-12-21/bin/../lib/Slicer-4.11/qt-scripted-modules/DICOMScalarVolumePlugin.py:699) - Irregular volume geometry detected, but maximum error non-zero but is within tolerance (maximum error of 2.56e-06 mm, tolerance threshold is 0.001 mm).
[INFO][Stream] 18.04.2019 09:01:59 [] (unknown:0) - Loading with imageIOName: GDCM
[CRITICAL][Stream] 18.04.2019 09:02:01 [] (unknown:0) - Irregular volume geometry detected, but maximum error non-zero but is within tolerance (maximum error of 2.56e-06 mm, tolerance threshold is 0.001 mm).
[DEBUG][Qt] 18.04.2019 09:02:03 [] (unknown:0) - Switch to module:  "Volumes"
[DEBUG][Qt] 18.04.2019 09:02:11 [] (unknown:0) - Switch to module:  "Segmentations"
[ERROR][VTK] 18.04.2019 09:03:09 [vtkSTLWriter (000000001C8A1AA0)] (D:\D\P\Slicer-0-build\VTK\IO\Geometry\vtkSTLWriter.cxx:243) - Couldn't open file: F://1: RTSTRUCT: RTstruct.stl Reason: Invalid argument
[WARNING][Qt] 18.04.2019 09:03:32 [] (unknown:0) - bool __cdecl qSlicerSegmentationsModuleWidget::copySegmentsBetweenSegmentations(bool,bool) : No segments are selected
[ERROR][VTK] 18.04.2019 09:03:35 [vtkTransformPolyDataFilter (0000000017E0C400)] (D:\D\P\Slicer-0-build\VTK\Filters\General\vtkTransformPolyDataFilter.cxx:85) - No input data
[ERROR][VTK] 18.04.2019 09:03:35 [vtkCompositeDataPipeline (000000001DB7C670)] (D:\D\P\Slicer-0-build\VTK\Common\ExecutionModel\vtkDemandDrivenPipeline.cxx:709) - Input port 0 of algorithm vtkCleanPolyData(000000001D9D8A00) has 0 connections but is not optional.
[ERROR][VTK] 18.04.2019 09:03:39 [vtkCompositeDataPipeline (000000001DB7C670)] (D:\D\P\Slicer-0-build\VTK\Common\ExecutionModel\vtkDemandDrivenPipeline.cxx:709) - Input port 0 of algorithm vtkCleanPolyData(000000001D9D8A00) has 0 connections but is not optional.
1 Like

This indicates that saving failed because “F://1: RTSTRUCT: RTstruct.stl” is not a valid filename. Either rename the segmentation node to not contain special character, such as colon (:) or use a more recent nightly version of Slicer (that removes special characters from the path automatically).

I got it, thank you! Succeed in exporting.

1 Like

@lassoan Maybe we should add the colon character to this expression