# Exporting Sequences as Dicoms does not work

**URL:** <https://discourse.slicer.org/t/exporting-sequences-as-dicoms-does-not-work/18935>\
**Category:** Support\
**Tags:** dicom, sequences\
**Created:** [July 27, 2021, 2:19am UTC](https://discourse.slicer.org/t/exporting-sequences-as-dicoms-does-not-work/18935 "2021-07-27T02:19:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shehab](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@shehab](https://discourse.slicer.org/u/shehab)\
**Post date:** [July 27, 2021, 2:19am UTC](https://discourse.slicer.org/t/exporting-sequences-as-dicoms-does-not-work/18935/1 "2021-07-27T02:19:05Z")

</div>

Operating system: Windows 10  
Slicer version: 4.13.0-2021-07-22  
Expected behavior:  
Generation of 768 dicoms after I export the sequence with the VolumeSequence option selected  
Actual behavior:  
Either a message stating “Error occured in exporter” pops up, or after a bit of gimmicking it says export successful and it exports nothing.  
Background:  
I am using the sequence registration extension to register 2D+t perfusion studies (generic rigid transformation). The registration process goes quite smoothly and rapidly, however, whenever I try to export it always ends up failing. The sequence replay of the registration checks out and the result registered, so its not an issue with registration or the sequence; its just the exporting. I would like to avoid exporting every frame of the sequence as separate volume.

---

<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:** [July 27, 2021, 6:20pm UTC](https://discourse.slicer.org/t/exporting-sequences-as-dicoms-does-not-work/18935/2 "2021-07-27T18:20:45Z")

</div>

We don’t have a DICOM exporter for volume sequences, but you can easily write a simple Python script for this. All you need to do is to iterate through the sequence and export each volume as it is done in the [scalar volume exporter](https://github.com/Slicer/Slicer/blob/2d1e1d819a8cf410b025e8f4c523280860b5c736/Modules/Scripted/DICOMLib/DICOMExportScalarVolume.py#L98-L163).

If you share your final script with us then we can turn it into a DICOM exporter plugin that can be used via GUI.

---

<div class="post-metadata">

**Author:** ![shehab](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@shehab](https://discourse.slicer.org/u/shehab)\
**Post date:** [August 1, 2021, 4:42am UTC](https://discourse.slicer.org/t/exporting-sequences-as-dicoms-does-not-work/18935/3 "2021-08-01T04:42:47Z")

</div>

I tried to take on coding the DicomVolumeSequence script like you told me in your answer to my question, but first I tried debugging the existing DicomVolumeSequencePlugin in here: [Sequences/DicomVolumeSequencePlugin.py at master · SlicerRt/Sequences · GitHub](https://github.com/SlicerRt/Sequences/blob/master/DicomVolumeSequencePlugin/DicomVolumeSequencePlugin.py).

I found the source of the errors: DICOMExportScalarVolume.py expects the tags dictionary to contain Patient Birth Date and Patient Sex, which weren’t provided by the DicomVolumeSequence tag dictionary. I just wrote 2 lines of code to get those parameters into the DicomVolumeSequence tag dictionary.

The second error was with the datetimefromDicom method, which always seemed to raise the Oserror unless I formatted my inputs perfectly so I commented the else raises out. I don’t think this is a correct solution but it worked for my case so I didn’t really care too much.

In total I commented lines 121,122,146 and 147 out, and added lines 195 and 196 as:  
tags[‘Patient Birth Date’] = exportable.tag(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientBirthDateTagName())  
tags[‘Patient Sex’] = exportable.tag(slicer.vtkMRMLSubjectHierarchyConstants.GetDICOMPatientSexTagName())

---

<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:** [September 14, 2021, 7:46pm UTC](https://discourse.slicer.org/t/exporting-sequences-as-dicoms-does-not-work/18935/4 "2021-09-14T19:46:44Z")

</div>

Thank you @shehab.  
@CJohnson submitted these suggested changes in a [pull request](https://github.com/Slicer/Slicer/pull/5853) that has now been merged into Slicer master.
