Convert hdr/img to nii fromat

I am using iSEG2017 data. but the data is in .hdr/.img format. where as the code I am trying to run on it is accepting .nii. how to get around this problem.


1 Like

If you have FSL installed you can convert a .hdr/.img pair to a .nii image using
fslchfiletype NIFTI fmri.hdr
If your .hdr/.img pair is in NIfTI format you will be all set. However, be aware that the /hdr/.img pair was also used for the older Analyze format that did not include a spatial transform. If your data is Analyze format, the spatial alignment of the results images may be incorrect. You can check the input images with fslhd to look at this.


I also find C3D from ITK-SNAP to be helpful. Sometimes it works where fslchfiletype fails and vice versa.

And just to add one more option, in Python:

import nibabel as nb
fname = '<file name>.img'  
img = nb.load(fname), fname.replace('.img', '.nii'))

Again, you’ll want to check orientation, but assuming it is a valid Analyze (or two-part NIfTI) file, it should just work. (If not, you can submit a bug report at


Thanks all for your replies .