Convert between nii.gz and nii

7,535 views
Skip to first unread message

thomas.nickson

unread,
Mar 7, 2014, 11:28:29 AM3/7/14
to nipy...@googlegroups.com
Hey,

Are there any tools that can change between nii.gz and nii. I want to use some stuff that's in spm but I'd prefer to save space getting output in nii.gz where possible. Is there an intermediary that allows me to pipe in the nii.gz and nii out the other end to stick in the spm stuff?

Thanks,

Tom

Michael Waskom

unread,
Mar 7, 2014, 11:54:46 AM3/7/14
to nipy...@googlegroups.com
I usually use the Freesurfer command mri_convert todo this (mri_convert foo.nii.gz foo.nii), which has a Nipype interface called MRIConvert.

But if you don't have Freesurfer installed, I'm sure there are other interfaces in Nipype that will do this, or you could just write a little Function interface that makes a system call to gunzip.

Johnson, Hans J

unread,
Mar 7, 2014, 11:58:36 AM3/7/14
to nipy...@googlegroups.com
I think that the system call to unzip is the safest mechanism.  It would be lossless.  Convering with MRIConvert, or any of the other possible tools will only convert the parts of the nii.gz file that are known to that particular tool.

In particular, proprietary nifti extensions would be last.

With that stated, it “probably” does not affect you since your nifti files are “probably” simple and the conversions would be fine.

Hans

--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.

Cindee Madison

unread,
Mar 7, 2014, 12:01:22 PM3/7/14
to nipy...@googlegroups.com
This is a gzipped file

gunzip <file> 
on most unix systems will work
to rezip
gzip <file>
--
Cindee Madison
Jagust Lab
UC Berkeley
cin...@berkeley.edu

Cindee Madison

unread,
Mar 7, 2014, 12:01:59 PM3/7/14
to nipy...@googlegroups.com
and note...

The format is the same, just a matter of file compression

thomas.nickson

unread,
Mar 10, 2014, 9:41:12 AM3/10/14
to nipy...@googlegroups.com, cin...@berkeley.edu
I think it's just a case of how to put this in to a pipeline easily though.

Satrajit Ghosh

unread,
Mar 10, 2014, 10:03:02 AM3/10/14
to nipy-user, Cindee Madison
hi tom,

nothing that does this automatically. a few options:

1. write a generic function that handles this case

2. gzip (create), gunzip (use):
https://github.com/nipy/nipype/blob/db81db1b5a5073d4e1e9793eb846fac4a1f476b5/nipype/algorithms/misc.py#L710 

3. add the functionality to the spm baseclass itself

4. (rare but they do exist in clusters) the filesystem hardware themselves do compression.

perhaps the gunzip from 2 is sufficient for your needs at this point.

cheers,

satra

Reply all
Reply to author
Forward
0 new messages