#imaging #3d #resampling #nifti #nibabel

nifti_processing

nibabel like 3d resampling functions for Nifti-rs

1 unstable release

0.1.0 Apr 2, 2023

#14 in #resample

Download history 1/week @ 2023-11-10 4/week @ 2023-11-17 2/week @ 2023-11-24 6/week @ 2023-12-01 1/week @ 2023-12-15 2/week @ 2023-12-22 1/week @ 2024-01-19 3/week @ 2024-01-26 31/week @ 2024-02-02 3/week @ 2024-02-09 45/week @ 2024-02-16

82 downloads per month

MIT/Apache

22KB
445 lines

NIFTI-Processing-rs

This library is designed as an extension of the NIFTI-rs library, adding 3D resampling support. This library is closely modeled after the NiBabel processing module, hence the name.

Features

The resample_to_output and resample_from_to functions with nearest neighbor and trilinear resampling are implemented.

Limitations

  • Minimal error checking; Will be extended.
  • Minimal unit tests; Will be extended.
  • Please also consult the issue tracker.

Requirements

The nalgebra_affine and ndarray_volumes features of NIFTI-rs are required.

Example

Load a Nifti image file with NIFTI-rs and resample the volume to a grid spacing of 1 mm:

use nifti::{NiftiObject, ReaderOptions, NiftiVolume};
use use nifti_processing::{resample_to_output, sampler};

let obj = ReaderOptions::new().read_file("myvolume.nii.gz")?;
let header = obj.header();
let affine = header.get_affine();
let volume = obj.volume();
let im = volume.into_ndarray::<f32>()?;

let nn = sampler::NearestNeighbor::default();
let (resampled_im, resampled_affine) = resample_to_output(&im, &affine, &[1.0,1.0,1.0], nn)

See also the examples directory.

License

Licensed under either of

at your option.

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

Dependencies

~4MB
~83K SLoC