Skip to content Skip to sidebar Skip to footer

Medical Imaging Data - How To Convert .raw/mhd To Nifti/nii

Is there a way in Python or any other language to convert .raw/mhd image data to Nifti/nii? I can load the .raw/mhd file in python via SimpleITK as in this post: Reading *.mhd/*.ra

Solution 1:

You should be able to just do in with SimpleITK. You would do something like this:

import SimpleITK as sitk

img = sitk.ReadImage("input.mhd")
sitk.WriteImage(img, "output.nii")

If you don't have SimpleITK in python, installing it as follows:

pip install SimpleITK

SimpleITK does its best effort of preserving all header information, although it's not perfect. Hopefully the voxel dimensions will be preserved.


Post a Comment for "Medical Imaging Data - How To Convert .raw/mhd To Nifti/nii"