Convert nrrd to nii.gz

Hello there!

For a special use case, I need all my data in nii.gz format. Right now, I have 200+ CT-Volumes plus segmentations both stores in .nrrd data format. I could open each of those volumes/segmentations in 3D slicer manually and store them as nii.gz, but I am looking for a way to script that problem, so I don’t have to do it 200 times.

Since I am a newbie to that topic, I do not know where to start and I was wondering if you have any good ideas/known libraries/ways to script that problem within 3D slicer or outside 3D slicer.

Thanks in advance!

These scripts were written for diffusion images but should work for other volumes.

dcm2niix should also work.

1 Like

Really easy to do in Python with SimpleITK.

import SimpleITK as sitk

img = sitk.ReadImage("your_image.nrrd")
sitk.WriteImage(img, "your_image.nii.gz")

fin

3 Likes