# SlicerRT: could not export RTPLAN

**URL:** <https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698>\
**Category:** Support\
**Created:** [October 7, 2019, 7:40pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698 "2019-10-07T19:40:04Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 7, 2019, 7:40pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/1 "2019-10-07T19:40:04Z")

</div>

I load RTPLAN, RTDOSE, RTSTRUCT, and RT image into Slicer and would like to export them as dicom files.

I can have RTDOSE, RTSTRUCT, and RT image exported, not RTPLAN. I look at the code RTPLAN node does not get checked in SlicerRT/DicomRtImportExport/Logic/vtkSlicerDicomRtImportExportModuleLogic.cxx. It only check:

```auto
// Get nodes for the different roles from the exportable list
  vtkMRMLScalarVolumeNode* doseNode = nullptr;
  vtkMRMLSegmentationNode* segmentationNode = nullptr;
  vtkMRMLScalarVolumeNode* imageNode = nullptr;

```

Correspondingly, only anatomical image, dose distribution image and structure can be set in SlicerRT/DicomRtImportExport/Logic/vtkSlicerDicomRtWriter.h:

```auto
  /// Set anatomical image to Plastimatch RT study for export
  void SetImage(const Plm_image::Pointer&);

  /// Set dose distribution image to Plastimatch RT study for export
  void SetDose(const Plm_image::Pointer&);

  /// Add structure as image data to Plastimatch RT study for export
  void AddStructure(UCharImageType::Pointer, const char* name, double* color);

```

If anyone has exported RTPLAN, could you share your code with me?

Thanks in advance.

---

<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:** [October 7, 2019, 8:49pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/2 "2019-10-07T20:49:51Z")

</div>

RT Plan export in SlicerRT has not been implemented unfortunately. We are currently writing a grant that will allow that, but it will be at least a year or two before it happens. If you or your lab has the capacity to start adding this feature I will be happy to help.

---

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 7, 2019, 9:20pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/3 "2019-10-07T21:20:34Z")

</div>

> [@cpinter](#):
>
> RT Plan export in SlicerRT has not been implemented unfortunately.

Thanks for the information.

I would like to start working on it. Currently, I am thinking how to convert vtkMRMLRTPlanNode object to Rtplan object. Then I can set it in the writer. If you have any information on it, please let me know.

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [October 8, 2019, 4:21pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/4 "2019-10-08T16:21:57Z")

</div>

> [@Guangshan\_Chen](#):
>
> I would like to start working on it. Currently, I am thinking how to convert vtkMRMLRTPlanNode object to Rtplan object. Then I can set it in the writer. If you have any information on it, please let me know.

Most of the plan information is lost upon import. Exporting a plan to DICOM could be done, but the resulting object would not be very useful.

Why do you want to export the RT Plan? How will you use it?

---

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 8, 2019, 5:22pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/5 "2019-10-08T17:22:36Z")

</div>

We want to deliver a RT plan so that the beams can be set up according to the plan.

---

<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:** [October 11, 2019, 8:14pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/6 "2019-10-11T20:14:57Z")

</div>

Can you describe your goal in a bit more detail?

In any case, you will need to add RTPLAN support in

1. The plugin:  
[SlicerRT/DicomRtImportExport/DicomRtImportExportPlugin.py at master · SlicerRt/SlicerRT · GitHub](https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/DicomRtImportExportPlugin.py#L81)
2. The writer: [SlicerRT/DicomRtImportExport/Logic/vtkSlicerDicomRtWriter.cxx at master · SlicerRt/SlicerRT · GitHub](https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/Logic/vtkSlicerDicomRtWriter.cxx#L100)
3. The import/export logic: [SlicerRT/DicomRtImportExport/Logic/vtkSlicerDicomRtImportExportModuleLogic.cxx at master · SlicerRt/SlicerRT · GitHub](https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/Logic/vtkSlicerDicomRtImportExportModuleLogic.cxx#L1966)
4. Figure out how to set the plan information in Plastimatch: [Files · master · plastimatch / plastimatch · GitLab](https://gitlab.com/plastimatch/plastimatch/blob/master/src/plastimatch/base/rt_study.h#L115)

All the links above are the corresponding parts for RT dose. The same needs to be done with the plan.

> [@gcsharp](#):
>
> but the resulting object would not be very useful.

What do you mean?

---

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 11, 2019, 9:01pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/7 "2019-10-11T21:01:42Z")

</div>

Hi cpinter,

My current goal is still vague. My idea is that if I create a RTPLAN in SlicerRT, I should be able to export out from Slicer and then reload it back into Slicer.

Thanks for pointing out the code needed to be changed.

I have successfully exported a RTPLAN dicom file yesterday. The following is how I implemented in [https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/Logic/vtkSlicerDicomRtImportExportModuleLogic.cxx](https://github.com/SlicerRt/SlicerRT/blob/master/DicomRtImportExport/Logic/vtkSlicerDicomRtImportExportModuleLogic.cxx#L1966)

```auto
// Convert input RTPlan to the format Plastimatch can use
  if (planNode) {
    std::cout << "chengs++: export RT study find RTPlanVolume node " << std::endl;
    Rtplan::Pointer plan = Rtplan::New();
    plan->rt_plan_label = "T ORL 1C";
    plan->rt_plan_name = "T ORL 1C";
    plan->rt_plan_date = "18850827";
    plan->rt_plan_time = "111111";

    plan->patient_position = "hfs"; //patient position metadata: one of {hfs,hfp,ffs,ffp}

    rtWriter->SetPlan(plan);
  }

```

Basically, it is just dummy Rtplan object.

However, the problem I face now is that I could not load the RTPLAN dicom file back with Slicer. Because Slicer think this file is scalar volume. Here is the error:

"  
Warning in DICOM plugin Scalar Volume when examining loadable 114120633: Unnamed Series: Reference image in series does not contain geometry information. Please use caution.

vtkITKArchetypeImageSeriesReader::ExecuteInformation: Cannot open /tmp/IRS-gchen/DICOMExportTemp\_20191011\_135248/RTPLAN/rtplan\_1.2.826.0.1.3680043.8.274.1.1.8323329.21835.1570819971.548083.dcm. ITK exception info: error in unknown: Could not create IO object for reading file /tmp/IRS-gchen/DICOMExportTemp\_20191011\_135248/RTPLAN/rtplan\_1.2.826.0.1.3680043.8.274.1.1.8323329.21835.1570819971.548083.dcm  
Tried to create one of the following:  
BMPImageIO  
BioRadImageIO  
DCMTKImageIO  
GDCMImageIO  
GiplImageIO  
JPEGImageIO  
LSMImageIO  
MGHImageIO  
MINCImageIO  
MRCImageIO  
MetaImageIO  
NiftiImageIO  
NrrdImageIO  
PNGImageIO  
StimulateImageIO  
TIFFImageIO  
VTKImageIO  
MRMLIDImageIO  
Bruker2dseqImageIO  
GE4ImageIO  
GE5ImageIO  
HDF5ImageIO  
JPEG2000ImageIO  
You probably failed to set a file suffix, or  
set the suffix to an unsupported type.  
"

I have not figure out the reason. If you have any suggestion, please let me know.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 11, 2019, 9:08pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/8 "2019-10-11T21:08:51Z")

</div>

![Screenshot_2019-10-11_16-06-08](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/6/069685a3067dadc0d89f58c356ded5e1f73b4ab2.png)

This is how it looks like after I imported the rtplan dicom file into Slicer. It shows the modality of the file is RTPLAN.

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [October 15, 2019, 9:05pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/9 "2019-10-15T21:05:38Z")

</div>

Unfortunately your code snippet doesn’t tell us much. Can you share the plan object you created?

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [October 15, 2019, 9:13pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/10 "2019-10-15T21:13:16Z")

</div>

> [@cpinter](#):
>
> > but the resulting object would not be very useful.
> 
> What do you mean?

The plan is not completely imported. Only the first control point is loaded, also things like beam energy, MU, etc. are not loaded. That’s why I feel it might not be useful to export such a plan.

---

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 16, 2019, 4:47pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/11 "2019-10-16T16:47:13Z")

</div>

Thanks for response. I found the reason. The RTplan exported is RTIonPlan. So it is not recognized as RT loadable. Here is the comments in DicomRtImportExport/Logic/vtkSlicerDicomRtImportExportModuleLogic.cxx:  
“”"  
/\* Not yet supported  
else if (sopClass == UID\_RTTreatmentSummaryRecordStorage)  
else if (sopClass == UID\_RTIonPlanStorage)  
else if (sopClass == UID\_RTIonBeamsTreatmentRecordStorage)  
\*/  
“”"  
By tacking down, I found a new read function is needed to read RTIonPlan in DCMTK/dcmrt/libsrc/drtplan.cc.

---

<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:** [October 16, 2019, 5:31pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/12 "2019-10-16T17:31:04Z")

</div>

We have an unfinished implementation for RT Ion Plan import, see progress here: [https://github.com/SlicerRt/SlicerRT/issues/25](https://github.com/SlicerRt/SlicerRT/issues/25)

It would probably not take too much time to finish it, but it is not high on the priority list. If you’d like to give it a shot, I am happy to prepare you a branch and give you pointers.

If your goal is to have a complete import/export ion plan wofkflow with Slicer, however, it could take significant effort due to the things @gcsharp mentions. Also see my [comment above](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/2).

---

<div class="post-metadata">

**Author:** ![gcsharp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/gcsharp/32/863_2.png) [@gcsharp](https://discourse.slicer.org/u/gcsharp)\
**Post date:** [October 16, 2019, 5:52pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/13 "2019-10-16T17:52:19Z")

</div>

Yes, indeed. Plastimatch is hard-coded to export a plan as an RT Ion Plan. You can see here:

[https://gitlab.com/plastimatch/plastimatch/blob/master/src/plastimatch/base/dcmtk\_rtplan.cxx](https://gitlab.com/plastimatch/plastimatch/blob/master/src/plastimatch/base/dcmtk_rtplan.cxx)

---

<div class="post-metadata">

**Author:** ![Guangshan\_Chen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/guangshan_chen/32/4832_2.png) [@Guangshan\_Chen](https://discourse.slicer.org/u/Guangshan_Chen)\
**Post date:** [October 18, 2019, 5:12pm UTC](https://discourse.slicer.org/t/slicerrt-could-not-export-rtplan/8698/14 "2019-10-18T17:12:26Z")

</div>

Thanks.  
For now, I would like to stop here and come back later. If you have any update upon it, please let me know.
