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.
Thanks
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.
Thanks
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)
nb.save(img, 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 https://github.com/nipy/nibabel/issues/)
Thanks all for your replies .
cheers
In this option, does the .nii file also include the info from the hdr file? Thanks in advance!
Yes. The NIfTI format is just <hdr><offset bytes><img>
where <offset bytes>
is some number of zero-bytes needed to get the starting index of <img>
to be a multiple of 16
I used this code to convert iSeg-2017 https://iseg2017.web.unc.edu/
The output images have problem
I want to convert .hdr/img to nii
MANAGED BY INCF