Site icon R-bloggers

writeNIfTI() is fully compatible with FSLView

[This article was first published on dcemri, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
With the NIfTI-1 header extensions the world is your oyster.  We decided that one use for such a capability is to keep an audit trail of all operations performed on the image data volume.  This is a key feature in the dcemriS4 package.  There are three main components to a NIfTI-1 header extension: esize, ecode and edata.  At first we arbitrarily set ecode = 1002 and further developed the software.  Turns out, FSLView is quite strict about the numbers used in ecode and it failed to accept our NIfTI-1 header extensions saved from R.  Looking at the file nifti1_io.h, the following ecodes have been defined:



Advice from the FSL team (thanks: Matt Webster and Dave Flitney) was for us to use ecode = 6 (ASCII) since the audit trail is text in XML format.  Now one can produce an example data volume



We now have a file “img_nifti.nii.gz” that is available to us and using a utility in FSL we can investigate the attributes of this file

% $FSLDIR/bin/fslhd img_nifti | grep 'vox_offset'

vox_offset     1168


and reading the file back into R allows us to interrogate the ecode via its S4 slot


To leave a comment for the author, please follow the link and comment on their blog: dcemri.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.