Ruby NIfTI is a pure-ruby library for handling NIfTI data in Ruby. NIfTI (Neuroimaging Informatics Technology Initiative) is an image format designed primarily for storing and analyzing MRI & PET imaging data.
Ruby NIfTI currently only supports basic access to NIfTI files, including
basic and extended header information, as well as image information. There are a ton of good NIfTI libraries and RUBY NIfTI doesn’t try to replace them, but instead we wrote this to provide a decent [we hope] Ruby interface, and allow for easier creation of NIfTI header extensions.
Ruby isn’t seen as a quantitative scripting language yet (Python is more well known, and PyNifti is more mature than NumericalRuby / NArray) so I don’t know how widely this will be used, but you never know.
gem install nifti
require "nifti"obj = NIFTI::NObject.new("some_file.nii")puts obj.header['sform_code_descr']
=> "NIFTI_XFORM_SCANNER_ANAT"
image = obj.get_imageimage = obj.get_image_narrayRuby NIfTI is highly derivative of the very good Ruby DICOM library, from which all of the design and most of the code has been cold-heartedly stolen. Many thanks to Chris Lervag – this wouldn’t exist without his examples.
Author: Erik Kastman