SlicerRt / SlicerRT

Open-source toolkit for radiation therapy research, an extension of 3D Slicer. Features include DICOM-RT import/export, dose volume histogram, dose accumulation, external beam planning (TPS), structure comparison and morphology, isodose line/surface generation, etc.
https://slicerrt.org
126 stars 60 forks source link

Can't export segmentation as Dicom RTStruct #184

Closed Namng1210 closed 3 years ago

Namng1210 commented 3 years ago

Dear authors, Everything seems to be really good when i exported it by hand and I've followed your instructions video of exporting RT-STRUCT file by right click at Study and choose Export to DICOM then click in RT struct and got the result as i want.

ui

But when i was doing it in python script by the following code, after passing the studyID as parameter, i got the result return 'Exportable list contains no exportables'. Then, i have also tried to pass the segmentationID, but got another warning : 'Must export the primary anatomical (CT/MR) image'. How can i fix this problem ?

export

Hope you reply me soon.

cpinter commented 3 years ago

In the above screenshot you export the study. In your script, you try to export only the segmentation, instead of the study, which would be the correct way.

We prefer questions asked in the Slicer discourse forum for better visibility. Here please report bugs. Thank you.

Namng1210 commented 3 years ago

Can you give me an instruction how to export study with DicomRTImportExportPlugin in Python Script. I've tried many ways but still can't make it. :(

cpinter commented 3 years ago

As I said you try to export the segmentation: exporter.examineForExport(segmentationShItem) and instead you need to export the study: exporter.examineForExport(studyShItem)

Namng1210 commented 3 years ago
exportable

Yes i've also tried it but here is the result. When i checked source code it seems like dataNode can't read the studyID.. so it return nothing in exportables...

cpinter commented 3 years ago

I see. It seems you need to run the examineForExport function on all the series you want to export (the segmentation and the CT), collect the returned exportables in a list, and and pass that list for the export function.

At least this is what the GUI does, see https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/DICOMLib/Widgets/qSlicerDICOMExportDialog.cxx#L271

Namng1210 commented 3 years ago

OMG! It was actually worked ! Thanks you so much for helping for me <3

cpinter commented 3 years ago

Perfeft, thank you! Closing the issue then.

roger-sun commented 2 years ago

Hello, I am kinda new with python. Can you explain to me how you manage to solve this issue?

I tried to run the ExamineForExport function on the volume and the segmentations, then past them in a list for the export function, but it did not worked:

exporter = DicomRtImportExportPlugin.DicomRtImportExportPluginClass() exportable1 = exporter.examineForExport(segmentationShItem) exportable2 = exporter.examineForExport(referenceVolumeShItem)

for exp in exportable1: exp.directory=outputFolder for exp in exportable2: exp.directory=outputFolder

exportables = [exportable1,exportable2]

exporter.export(exportables) Traceback (most recent call last): File “”, line 1, in File “C:/Users/tmp/AppData/Roaming/NA-MIC/Extensions-29402/SlicerRT/lib/Slicer-4.11/qt-scripted-modules/DicomRtImportExportPlugin.py”, line 122, in export exportable.copyToVtkExportable(vtkExportable) AttributeError: ‘list’ object has no attribute ‘copyToVtkExportable’

thanks !