# Convert CT nifti file to DICOM using slicer.modules/createdicomseries

**URL:** <https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921>\
**Category:** Support\
**Tags:** dicom\
**Created:** [September 26, 2023, 11:45pm UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921 "2023-09-26T23:45:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeepaKrishnaswamy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/deepakrishnaswamy/32/8913_2.png) [@DeepaKrishnaswamy](https://discourse.slicer.org/u/DeepaKrishnaswamy)\
**Post date:** [September 26, 2023, 11:45pm UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/1 "2023-09-26T23:45:29Z")

</div>

Hi,

I am interested in converting the TotalSegmentator training dataset from NifTi to DICOM.

I’ve converted each CT NifTi file to a DICOM series using `slicer.modules.createdicomseries`, where I specified parameters including the inputVolume, dicomDirectory, patientID, studyID, seriesNumber, seriesDescription, and modality.

The converted DICOM files load successfully in Slicer. However, I then used `dciodvfy` from `dicom3tools` to verify that these converted DICOM files are valid. It displayed the following warnings/errors:

```auto
Warning - Value dubious for this VR - (0x0010,0x0010) PN Patient's Name PN [1] = <Anonymous> - Retired Person Name form
CTImage
Error - Missing attribute Type 2C Conditional Element=<Laterality> Module=<GeneralSeries>
Error - Missing attribute Type 2 Required Element=<KVP> Module=<CTImage>
Error - Missing attribute Type 2 Required Element=<AcquisitionNumber> Module=<CTImage>

```

Using the `slicer.modules.createdicomseries`, how do I specify these particular fields to create a valid DICOM file?

Thank you!

Deepa

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 27, 2023, 12:44am UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/2 "2023-09-27T00:44:39Z")

</div>

Hi @DeepaKrishnaswamy - this module was developed by some of our good friends at GE many years ago and I recall they only did the bare minimum to get their company’s workstation to recognize and show data generated from ITK/Slicer, so It’s not a surprise that the data isn’t perfect. The [code is here](https://github.com/Slicer/Slicer/tree/main/Modules/CLI/CreateDICOMSeries) if you want to have a look. It’s pretty hard coded but wouldn’t be hard to extend to fix these issues. It would just be exposing these tags as command line options following the existing pattern. It would be great if you or someone could try this.

Of course another, probably a bit easier but hacky, solution would be to write a pydicom script to patch the generated files to add these fields. Basically like the [DICOMPatcher](https://slicer.readthedocs.io/en/latest/user_guide/modules/dicompatcher.html).

I’ll bet you don’t know KVP for this data so there’s no way to make them perfect, but I guess you can make them as close as possible.

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [September 28, 2023, 12:37am UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/3 "2023-09-28T00:37:49Z")

</div>

For the sake of completeness, this is the same CT series that is in question for the OHIF issue here:

> <https://github.com/OHIF/Viewers/issues/3682>
>
> Hi, 
> 
> I have deployed my own viewer app using the https://github.com/ImagingDa…taCommons/Viewers master branch here. It has been working with no issues -- however now I have been working with a different set of files, and have encountered an issue. 
> 
> I have a nifti CT file that I converted to a DICOM series using the \`slicer.modules.createdicomseries\` module. I then converted the associated label nifti file to a DICOM SEG file using \`dcmqi\`. When I load these converted DICOM files into Slicer, they load with no visible issues: 
> 
> !\[image\](https://github.com/OHIF/Viewers/assets/59979551/d098a635-d21e-4c9a-aa31-7ad513b821a8)
> 
> However, when I view the same DICOM files in OHIF, the following occurs: 
> 
> https://github.com/OHIF/Viewers/assets/59979551/030a3aa7-4b3c-4663-8edf-aa9f381314ce
> 
> Here are the DICOM CT and SEG files in \[dropbox\](https://www.dropbox.com/scl/fi/0abgbrcbnijjr33hhud3l/OHIF\_converted\_ct\_and\_seg\_issue\_09\_27\_23.zip?rlkey=266d3fqxra1npvq6dpmcfz5am&dl=0). 
> 
> Thank you, 
> 
> Deepa
> 
> \### Steps to Reproduce
> 
> 1. Deployed my own viewer app using the https://github.com/ImagingDataCommons/Viewers master branch
> 2. Converted the CT nifti file to DICOM series using \`slicer.modules.createdicomseries\`
> 3. Converted the label nifti file to DICOM using \`dcmqi\`
> 4. Added DICOM files to a dataset and DICOM datastore and accessed in the deployed viewer
> 
> \### The current behavior
> 
> Currently, both the CT and SEG do not load properly: 
> 
> https://github.com/OHIF/Viewers/assets/59979551/030a3aa7-4b3c-4663-8edf-aa9f381314ce
> 
> \### The expected behavior
> 
> It should look something like this: 
> 
> !\[image\](https://github.com/OHIF/Viewers/assets/59979551/d098a635-d21e-4c9a-aa31-7ad513b821a8)
> 
> \### OS
> 
> Windows 10 
> 
> \### Node version
> 
> I'm not sure 
> 
> \### Browser
> 
> Chrome 116.0.5845.188

---

<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 28, 2023, 2:37am UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/4 "2023-09-28T02:37:46Z")

</div>

None of the validation errors explain the completely garbled output in OHIF viewer. Is there any other DICOM viewer that has trouble loading and displaying this CT properly?

---

<div class="post-metadata">

**Author:** ![DeepaKrishnaswamy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/deepakrishnaswamy/32/8913_2.png) [@DeepaKrishnaswamy](https://discourse.slicer.org/u/DeepaKrishnaswamy)\
**Post date:** [September 29, 2023, 8:21pm UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/5 "2023-09-29T20:21:33Z")

</div>

Hi @lassoan, I tried viewing these DICOM files in ITK-Snap, ImageJ, and the Mango viewer. I didn’t encounter any issues with these packages.

---

<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 30, 2023, 4:19am UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/6 "2023-09-30T04:19:45Z")

</div>

If none of those software had any issues with the image then most likely the problem is in OHIF. Report the error to them and attach the image that OHIF does not load correctly.

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [October 1, 2023, 3:01am UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/7 "2023-10-01T03:01:30Z")

</div>

We reviewed this example with @David_Clunie, and he noticed that the slices have rather unusual for a typical DICOM resolution (since the original DICOM data was resampled and cropped prior to creating the source NIfTIs), resulting in an odd number of pixels in a frame, which may trigger a bug in OHIF v2. We will investigate this further with the OHIF team, and will try to make sure this is fixed for OHIF v3.

---

<div class="post-metadata">

**Author:** ![joshy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshy/32/70346_2.png) [@joshy](https://discourse.slicer.org/u/joshy)\
**Post date:** [May 8, 2024, 3:47pm UTC](https://discourse.slicer.org/t/convert-ct-nifti-file-to-dicom-using-slicer-modules-createdicomseries/31921/8 "2024-05-08T15:47:01Z")

</div>

Hi @DeepaKrishnaswamy,  
can you share how you converted the NifTi to DICOM?  
Thx and with best regards,  
Joshy
