Exporting Sequences as Dicoms does not work

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.

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.

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

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.

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())

Thank you @shehab.
@CJohnson submitted these suggested changes in a pull request that has now been merged into Slicer master.