3

I have lots of .nii file. I want to know how to convert .nii file to .nii.gz file?

Thanks

3
  • to convert? or to rename? Commented Mar 28, 2016 at 22:24
  • @MendiBarel, to convert!
    – Angelababy
    Commented Mar 28, 2016 at 22:44
  • .gz means gzip.... simply zip up the file?
    – rayryeng
    Commented Mar 28, 2016 at 23:25

2 Answers 2

2

As far as I know, there is nothing special about zipping NIfTI files. In MATLAB, you could simply do:

gzip('niftifilename.nii') % this will return niftifilename.nii.gz
gzip('*.nii') % for multiple nii files to create one .nii.gz

To work with the file again, you can unzip it, using gunzip. I've tried this on my Mac (don't know if this will work on Windows).

Typically, they are volume data, and hence take up a fair bit of disk space. Zipping it is purely for reducing the size of the file, and should not modify data.

0

You can simply do:

gzip({'*.nii'},outputdir)

Which will zip all your nii files into a nii.gz and place it into outputdir.

From the documentation:

To gzip all .m and .mat files in the current directory and store the results in the directory archive, type:

gzip({'.m','.mat'},'archive')

Not the answer you're looking for? Browse other questions tagged or ask your own question.