nii/
lib.rs

1//! Rust library for reading/writing NIfTI-1 (nii.gz) files, with SimpleITK/NiBabel-like APIs, native Rust support, and Python bindings for cross-language performance.
2//!
3//! If you have used SimpleITK/NiBabel, you will definitely love this and get started right away! 🕶
4//!
5//! ## 🎨Features
6//!
7//! - 🚀**Pure Rust Implementation**: Thanks to [nifti-rs](https://github.com/Enet4/nifti-rs), I/O speed is comparable to SimpleITK and slightly faster than NiBabel.
8//!
9//! - ✨ **Carefully Designed API**: *Super easy to use*, with no learning curve; enjoy a consistent experience in Rust as in Python. Ideal for developers familiar with ITK-style libraries.
10//!
11//! - 🛠️**Rust-Python bindings**: Write heavy operations in Rust and easily call them in Python, combining the performance of Rust with the flexibility of Python.
12//!
13//! ## 🔨Install
14//!
15//! For Rust projects, add the following to your `Cargo.toml`:
16//!
17//! ```toml
18//! [dependencies]
19//! nii-rs = "*"
20//! ```
21//! For Python, install via pip:
22//!
23//! ```sh
24//! pip install niirs
25//! ```
26//!
27//! ## 🥒Develop
28//!
29//! To start developing with nii-rs, use the following command:
30//!
31//! `maturin dev -r`
32//!
33//! ## 📘Examples
34//!
35//! For details, please refer to the [rust examples](examples/tutorial.rs) and [python examples](examples/tutorial.py)。
36//!
37//! ### 🦀Rust
38//!
39//! ```rust
40//! use nii;
41//!
42//! // read image
43//! let im = nii::read_image::<f32>("test.nii.gz");
44//!
45//! // get attrs, style same as SimpleITK
46//! let spacing: [f32; 3] = im.get_spacing();
47//! let origin: [f32; 3] = im.get_origin();
48//! let direction: [[f32; 3]; 3] = im.get_direction();
49//!
50//! // get affine, style same as nibabel
51//! let affine = im.get_affine();
52//!
53//! // get array, style same as SimpleITK, i.e.: [z, y, x]
54//! let arr: &Array3<f32> = im.ndarray();
55//!
56//! // write image
57//! nii::write_image(&im, "result.nii.gz")
58//! ```
59//!
60//! ## 🔒License
61//!
62//! Apache License 2.0 & MIT
63
64mod bind;
65mod image;
66mod utils;
67
68pub use image::*;