# Issue with DICOM to Nifti Conversion

**URL:** <https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151>\
**Category:** Support\
**Tags:** dicom\
**Created:** [November 30, 2023, 8:14pm UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151 "2023-11-30T20:14:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shovon\_Ahmed](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shovon_ahmed/32/18805_2.png) [@Shovon\_Ahmed](https://discourse.slicer.org/u/Shovon_Ahmed)\
**Post date:** [November 30, 2023, 8:14pm UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151/1 "2023-11-30T20:14:50Z")

</div>

I am trying to convert Dicom files to Nifti. But after conversion, I see a huge change in intensity (2nd image). I have also tried SimpleITK library bias correction. But the outcomes are the same.

Would anyone explain why it happened and how to fix this?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/0/5046459c035ee79677237b73bcdeab81c64e2934.jpeg)  
Dicom

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/4/94b50c14b91ec9e89a99c36ad0a2008f06079358.jpeg)  
Nifti (after conversion)

---

<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:** [November 30, 2023, 9:26pm UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151/2 "2023-11-30T21:26:51Z")

</div>

DICOM files can contain window/level information to indicated how they should be displayed, but nii files do not have that, so viewers just guess how best to display. Try different window/level settings to confirm that the data was transferred correcty.

---

<div class="post-metadata">

**Author:** ![Shovon\_Ahmed](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shovon_ahmed/32/18805_2.png) [@Shovon\_Ahmed](https://discourse.slicer.org/u/Shovon_Ahmed)\
**Post date:** [December 9, 2023, 7:56am UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151/3 "2023-12-09T07:56:45Z")

</div>

I have tried to apply the same windowing and leveling using sitk while converting DICOM to NIFTI. But still, it doesn’t look the same. Any idea what would be the best conversion method to keep the visual information intact?

---

<div class="post-metadata">

**Author:** ![Chris\_Rorden](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chris_rorden/32/4073_2.png) [@Chris\_Rorden](https://discourse.slicer.org/u/Chris_Rorden)\
**Post date:** [December 27, 2023, 3:00pm UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151/4 "2023-12-27T15:00:56Z")

</div>

@pieper the [NIfTI header](https://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h) does provide `cal_min` and `cal_max`. While these NIfTI fields are not often used, they would provide you a mechanism to retain the DICOM [Window Center (0028,1050)](https://dicom.innolitics.com/ciods/digital-x-ray-image/dx-image/00281050) and [Window Width (0028,1051)](https://dicom.innolitics.com/ciods/nm-image/voi-lut/00281051) tags. Specifically:

```auto
 cal_min = WC - (WW/2)
 cal_max = WC + (WW/2)

```

@Shovon_Ahmed have you tried converting your DICOMs to NIfTI and loading the resulting NIfTI allows you apply the original window values? This would help you trouble shoot at what stage the problem is occurring. My first thought might be to make sure that the DICOM [Rescale intercept, (0028,1052), and rescale slope (0028,1053)](https://www.kitware.com/dicom-rescale-intercept-rescale-slope-and-itk/) have been correctly converted to the NIfTI scl\_inter and scl\_slope fields.

---

<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:** [December 27, 2023, 6:18pm UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151/5 "2023-12-27T18:18:09Z")

</div>

Thanks for the heads up on that @Chris_Rorden - perhaps we should add support for these cal\_min/max fields in our nifti readers and writers. It wouldn’t be a hard task if someone wants to take it on.

---

<div class="post-metadata">

**Author:** ![Shovon\_Ahmed](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shovon_ahmed/32/18805_2.png) [@Shovon\_Ahmed](https://discourse.slicer.org/u/Shovon_Ahmed)\
**Post date:** [December 31, 2023, 6:54am UTC](https://discourse.slicer.org/t/issue-with-dicom-to-nifti-conversion/33151/6 "2023-12-31T06:54:22Z")

</div>

Thank you @Chris_Rorden. Normalizing WW and WC gives the same visual result as DICOM.
