#standard #parser #nifti #neuroimaging


Rust implementation of the NIfTI file format

10 releases (6 breaking)

0.7.0 Feb 22, 2019
0.6.0 Oct 17, 2018
0.5.1 Sep 4, 2018
0.5.0 Feb 18, 2018
0.1.0 May 25, 2017

#34 in Parser implementations

Download history 22/week @ 2018-12-20 1/week @ 2018-12-27 33/week @ 2019-01-03 52/week @ 2019-01-10 43/week @ 2019-01-17 95/week @ 2019-01-24 61/week @ 2019-01-31 78/week @ 2019-02-07 5/week @ 2019-02-14 90/week @ 2019-02-21 63/week @ 2019-02-28 6/week @ 2019-03-07 24/week @ 2019-03-14 297/week @ 2019-03-21 59/week @ 2019-03-28

302 downloads per month
Used in 1 crate


2.5K SLoC

NIFTI-rs   Latest Version Build Status dependency status

This library is a pure Rust implementation for reading files in the NIfTI format (more specifically NIfTI-1.1).


use nifti::{NiftiObject, InMemNiftiObject, NiftiVolume};

let obj = InMemNiftiObject::from_file("myvolume.nii.gz")?;
// use obj
let header = obj.header();
let volume = obj.volume();
let dims = volume.dim();

The library will automatically look for the respective volume when specifying just the header file:

use nifti::{NiftiObject, InMemNiftiObject};

let obj = InMemNiftiObject::from_file("myvolume.hdr.gz")?;

With the "ndarray_volumes" feature enabled, you can also convert a volume to an ndarray::Array and work from there:

let volume = obj.into_volume().into_ndarray::<f32>();


This library should hopefully fulfil a good number of use cases. However, it still is a bit far from a complete solution. In particular, future versions should be able to:

  • Write NIFTI files;
  • Provide a more elegant volume API;
  • Handle more kinds of volumes;
  • Provide a real spatial-temporal interpretation of the volume (rather than just voxel-indexed);
  • Maybe add support for NIFTI-2?

There are no deadlines for these features, so your help is much appreciated. Consider filing an issue in case something is missing for your use case to work. Pull requests are also welcome.


Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~69K SLoC