questions > Changing NIfTI format using dcm2niix
Showing 1-4 of 4 posts
Display:
Results per page:
Jan 31, 2017  11:01 AM | Pravesh Parekh - National Institute of Mental Health and Neurosciences
Changing NIfTI format using dcm2niix
Dear Prof. Rorden and others,

I wanted to check if there is any way to use the newer dcm2niix to convert between NIfTI formats? I would like to convert some of the compressed files (.nii.gz) to .nii and use them for SPM analysis...should I be using dcm2nii for the same or is there any alternate using dcm2niix?


Many thanks for the help


Regards
Pravesh
Jan 31, 2017  01:01 PM | TVASurg TVASurg
RE: Changing NIfTI format using dcm2niix
You could probably just use 7zip (http://www.7-zip.org/) to uncompress the nii.gz file - this should give you the nii file you want.
Jan 31, 2017  02:01 PM | Chris Rorden
RE: Changing NIfTI format using dcm2niix
As TVASurg notes, you can use a generalized compression tool (7zip, gz) to convert between .nii <-> .nii.gz files. My personal favorite is pigz, which uses multiple threads to accelerate compression, decompression

To decompress .nii.gz file so .nii you would do this
  pigz -d *.gz
And to compress .nii files to .nii.gz you would do this
  pigz *.nii

Note one handy feature of pigz is that it replaces the original files, rather than making copies. Therefore if you start with the file myFilename.nii and use "pigz myFilename.nii" the result is that "myFilename.nii.gz" will be created and "myFilename.nii" will be deleted. This is helpful if you are a FSL user, as it refuses to distinguish between these two images. In other words, myFilename.nii and myFilename.nii.gz should not exist in the same folder if you use FSL, as it will be unsure which image to use.
Jan 31, 2017  02:01 PM | Pravesh Parekh - National Institute of Mental Health and Neurosciences
RE: Changing NIfTI format using dcm2niix
Thank you TVASurg and Prof. Rorden! Thanks also for the heads up about that feature of pigz. I think I will go ahead with pigz!


Regards
Pravesh

 
Originally posted by Chris Rorden:
As TVASurg notes, you can use a generalized compression tool (7zip, gz) to convert between .nii <-> .nii.gz files. My personal favorite is pigz, which uses multiple threads to accelerate compression, decompression

To decompress .nii.gz file so .nii you would do this
  pigz -d *.gz
And to compress .nii files to .nii.gz you would do this
  pigz *.nii

Note one handy feature of pigz is that it replaces the original files, rather than making copies. Therefore if you start with the file myFilename.nii and use "pigz myFilename.nii" the result is that "myFilename.nii.gz" will be created and "myFilename.nii" will be deleted. This is helpful if you are a FSL user, as it refuses to distinguish between these two images. In other words, myFilename.nii and myFilename.nii.gz should not exist in the same folder if you use FSL, as it will be unsure which image to use.