Skip to main content

niitrous

Fast DICOM-to-NIfTI conversion and neuroimaging file I/O in Rust. Rewrites dicom2nifti and the volumetric core of nibabel, with a Python API.

Status: all dicom2nifti conversion paths are ported. Anatomical, fMRI, and DTI series from Siemens, GE, Philips, and Hitachi (classic and enhanced multiframe, compressed and color) match dicom2nifti voxel-for-voxel on its test suite, including .bval / .bvec files for diffusion. Gantry-tilted and unevenly spaced series can be resampled to a regular grid (resample=True). See Compatibility.

Images: initial port of nibabel's volumetric core. Supports lazy and sliced reading and writing for NIfTI-1, NIfTI-2, Analyze / SPM99 / SPM2, and MGH / MGZ, along with orientation utilities and common image functions—verified against nibabel's test files. See Images.

Python API

import niitrous as nit

for series in nit.scan("study/"):            # list series (reads headers only)
    print(series.number, series.description_normalized, series.vendor, series.n_files)

volume = nit.read("study/t1/")               # load one series into memory
volume.data, volume.affine, volume.meta     # numpy array, 4x4 affine, all DICOM headers
volume.save("t1.nii.gz")                    # NIfTI plus t1.json sidecar
volume.bvals, volume.bvecs                  # diffusion series only (otherwise None)

report = nit.convert("study/", "out/", orientation="LAS", strict=False)
for result in report.failed:
    print(result.series.uid, result.error)

nit.convert("study/t1/", "sub-01_T1w.nii.gz")    # convert one series to an exact filename
  • src can be a directory, a file, or a list of either. Input files are read in place.
  • out can be an output directory (filenames follow output_naming) or a .nii / .nii.gz file path when src contains a single series. A file path is used verbatim: its extension determines compression, and any sidecar or .bval / .bvec files are written alongside it with the same stem.
  • Any setting can be passed to a call as a keyword argument, or applied to a block with with nit.settings.override(...). There is no global state to toggle.
  • convert never swallows errors: every series returns a result with .ok, .path, and .error. Errors include the legacy dicom2nifti code (.code) and the setting that disables the check (.setting).
  • convert(..., progress=True) prints a counter; pass a function to get progress(done, total) calls instead.
  • niitrous.compat provides drop-in dicom_series_to_nifti and convert_directory wrappers so you can migrate existing scripts by changing a single import.

Images

import niitrous as nit

img = nit.load("scan.nii.gz")                # reads header only; voxels load on demand
img.shape, img.dtype, img.affine, img.zooms, img.axcodes
img.header["descrip"], img.header.zooms, img.header.get_qform()

img.dataobj[..., 0]                         # reads only that volume, scaled
img.numpy()                                 # full array (stored dtype, or float64 if scaled)
img.numpy(scaled=False)                     # raw unscaled values
img.get_fdata(dtype="float32")              # float32 array, converted in a single pass

ras = img.reorient("RAS")                   # or img.as_closest_canonical()
ras.save("ras.nii.gz")
iso = img.resample(1.0, "cubic")            # 1 mm voxels; "nearest", "linear" (default) or "cubic"
seg = mask.resample((1, 1, 2.5), "linear", is_label=True)   # labels are never blended
nit.Image(array, affine).save("new.nii.gz", dtype="int16")   # automatically scaled to fit int16, matching nibabel
img.save("copy.mgz")                        # format inferred from the file extension
Extensions Format Notes
.nii NIfTI-1, NIfTI-2 Preserves header extensions as raw bytes; little- or big-endian
.hdr + .img NIfTI pair, Analyze 7.5, SPM99, SPM2 Analyze files read as SPM2 (matching nibabel); reads SPM affines from .mat files
.mgh, .mgz FreeSurfer MGH Preserves footer metadata (TR, flip angle, TE, TI, FOV)

All formats support .gz and .zst compression (plus .bz2 when reading). File format is detected from file contents, not the extension.

  • Lazy loading. load() only reads the header. img.dataobj is an ArrayProxy; indexing it with integers, slices, or ... reads only the required bytes from uncompressed files and niitrous-written gzip files. Other compressed files are decompressed only up to the last byte needed.
  • Results stay in Rust. The image reorient() or resample() returns keeps its voxels in Rust and passes them to the next operation or to save() without copying. They become a NumPy array the first time you ask (.numpy(), .dataobj, .get_fdata()), and the image keeps that array from then on. An image built from your own array is copied once per operation.
  • No forced float64. Unscaled data stays in its on-disk dtype. Scaling, byte-swapping, and float conversion happen in a single parallel pass.
  • Saving. Loaded files are saved as-is, preserving their original dtype and scaling. New arrays are written in their current dtype unless you pass dtype=, which computes slope and intercept the same way nibabel does (except whole-number floats that fit are stored unscaled). Cross-format saves convert headers automatically: nit.load("a.nii").save("a.mgz").
  • Headers. Create headers with nit.Header("nifti1" | "nifti2" | "analyze" | "spm99" | "spm2" | "mgh"), access fields by standard names, serialize with header.to_bytes(), or convert formats with header.convert(format). Unknown header bytes are preserved on round-trip.
  • Orientation. niitrous.orient has nibabel's io_orientation, aff2axcodes, axcodes2ornt, ornt_transform, apply_orientation, and inv_ornt_aff.
  • Functions. nit.squeeze, nit.concat, nit.four_to_three.
  • Threads. Reading, decompressing and writing use one thread per core. img.numpy(threads=4), img.get_fdata(threads=4) and img.save(path, threads=4) limit one call; nit.set_threads(4) limits every call that does not say, DICOM conversion included (nit.set_threads(0) undoes it, nit.get_threads() reports it).
  • A converted DICOM series becomes an image with volume.to_image().

niitrous has its own API rather than being a drop-in replacement for nibabel, though we kept matching names where it made sense. The same functionality is available in Rust via the niitrous-io crate: Image::load, ArrayProxy::read_slice, orient, funcs. Thread limits are WriteOptions::threads, pool::set_threads and pool::install.

Resampling

Image.resample(spacing, interpolation="linear", is_label=False) resamples to new voxel sizes in mm (one number, or one per axis), in Rust on all cores. It follows ITK's ResampleImageFilter and is checked against SimpleITK.

  • Grid: the axes and the position of voxel 0 are kept; each axis gets round(n * old / new) voxels. Axes whose size does not change are left alone, and the volumes of a 4D image are resampled one by one.
  • Interpolation: "nearest", "linear", or "cubic", an interpolating cubic B-spline like sitkBSpline. The voxel type is kept; integers are rounded and kept in range (ITK truncates).
  • Labels: with is_label=True, linear and cubic weight each label by the interpolation kernel and keep the heaviest, so boundaries are smooth and no new value appears. Linear gives what sitkLabelLinear gives; cubic uses the wider B-spline kernel and lands close to sitkLabelGaussian. On an exact tie the lower label wins.
  • Scaled files: a file that stores integers with a scaling (most CT) reads as float64, and so does its resampled image. Pass save(path, dtype=img.dtype) to write the original type again; niitrous resample does this itself.
  • Limits: honours nit.set_threads. A grid too large for memory is an error.
  • Edges: when upsampling, positions up to half a voxel past the last voxel centre take the edge value, where ITK writes zeros.

Color, complex and 64-bit integer images are refused. Resampling onto another image's grid, and smoothing before downsampling, are not included.

Settings

Default settings live in ~/.config/niitrous/settings.json (or $NIITROUS_CONFIG, or $XDG_CONFIG_HOME/niitrous/settings.json). Generate a config file populated with all defaults:

niitrous config init

You only need to include the settings you want to override. Precedence (lowest to highest): built-in defaults, config file, settings.override(...), and call arguments.

Validation

Setting Default Description
strict true Set to false to disable all validate_* checks
validate_slicecount true Reject series with fewer than 4 slices
validate_orientation true Require all slices to be parallel
validate_orthogonal true Reject gantry-tilted volumes
validate_slice_increment true Require constant slice spacing
validate_instance_number false Require instance numbers to follow slice position
validate_multiframe_implicit true Reject implicit-VR enhanced DICOM
read_force false Read files that lack a DICOM preamble

Geometry & Resampling

Setting Default Description
orientation "RAS" "RAS" (RAS+), "LAS" (dicom2nifti default), or "native" (as acquired)
resample false Resample tilted or unevenly spaced 3D volumes to a regular grid (requires disabling validate_orthogonal / validate_slice_increment)
resample_padding 0 Fill value for resampled voxels outside the original volume
resample_spline_order 0 Interpolation order: 0 (nearest), 1 (linear), or 3 (cubic)

Output & Compression

Setting Default Description
narrow_dtype true Store voxels in the smallest type that holds every value exactly (e.g. CT as int16 rather than float64); false keeps dicom2nifti's type
integer_scaling true Write data that DICOM rescaling made fractional (Philips MR, PET) as the stored integers with scl_slope / scl_inter, when one slope and intercept fit every slice; false writes floats
compression "gzip" "gzip" (.nii.gz), "zstd" (.nii.zst; unsupported by FSL/SPM), or "none" (.nii)
gzip_level 6 Gzip compression level, 1 (fastest) to 9 (smallest)
gzip_indexed true Write independent gzip members for parallel/random-access reads in niitrous (standard .gz for other tools); false writes one stream
zstd_level 3 Zstandard compression level, 1 (fastest) to 22 (smallest)
output_naming "{series_number}_{series_description_normalized}" Filename template (without extension)

Sidecar & Runtime

Setting Default Description
sidecar true Write a JSON sidecar next to each NIfTI file
sidecar_per_instance true Include header tags that vary across slices
sidecar_exclude [] DICOM keywords or (GGGG,EEEE) tags to omit
sidecar_deidentify false Strip common patient identifiers
reference_dicom false Write a header-only reference .dcm (no pixel data, new SOP Instance UID) next to each NIfTI. sidecar_deidentify drops the same direct identifiers as in the sidecar; dates, UIDs and private elements remain
on_error "skip" "skip" failed series or "raise" immediately
threads 0 Worker threads (0 = nit.set_threads, else one per CPU core)
log_level "warning" off, error, warning, info, or debug

Naming placeholders: series_number, series_description_normalized, series_description_legacy, series_uid, protocol_name, sequence_name, modality.

Filenames

series_description_normalized converts spaces to underscores, strips accents, lowercases text, and removes punctuation—matching dicom2nifti, except periods are preserved (Body Ax 1.0 becomes body_ax_1.0 instead of body_ax_10). It is also available as nit.normalize_name().

Sidecar

{
  "niitrous": { "version": "0.1.0", "vendor": "siemens", "orientation": "RAS", "shape": [256, 256, 180], "n_files": 180, "source": "study/t1" },
  "series_description_normalized": "body_ax_1.0",
  "dicom": { "SeriesDescription": "Body Ax 1.0", "(0019,100C)": 1000 },
  "dicom_per_instance": { "InstanceNumber": [1, 2, 3] }
}

dicom contains every header element shared across the series, and dicom_per_instance contains those that vary, one entry per slice in slice-position order. Pixel data is omitted, and large binary elements are summarized. The same dictionary is exposed on Volume.meta.

Sidecars include patient identifiers by default. Enabling sidecar_deidentify removes common direct identifiers (name, ID, birth date, physicians, institution), but it is not full DICOM PS3.15 de-identification—dates, UIDs, and private elements remain.

Command line

niitrous scan study/
niitrous convert study/ out/ --orientation LAS --set gzip_level=1
niitrous convert study/t1/ sub-01_T1w.nii.gz
niitrous info scan.nii.gz --header
niitrous resample t1.nii.gz t1_iso.nii.gz --spacing 1 --interpolation cubic
niitrous resample seg.nii.gz seg_iso.nii.gz --spacing 1,1,2.5 --label

resample keeps the file's stored voxel type and NIfTI orientation codes, and writes with the compression in your settings file.

niitrous config show

Benchmarks

All timings are best of 3 runs on an 18-core Apple M5 Pro.

DICOM Conversion (vs. dicom2nifti 2.6.2)

Time to convert a single series to a LAS .nii.gz file. The first row is a synthetic 300-slice volume; the rest come from dicom2nifti's test suite, where small series amplify fixed overhead.

Series dicom2nifti (ms) niitrous (ms) Speedup
synthetic 300×512×512 1653.1 181.8 9.1×
siemens/dti/001 (mosaic) 107.6 13.3 8.1×
hitachi/anatomical/001 11.7 1.5 8.0×
ge/dti/002 28.8 3.9 7.5×
philips/anatomical/002 245.2 37.0 6.6×
sirona_multiframe/anatomical/001 78.5 12.4 6.3×
philips/dti/002 76.3 13.4 5.7×
siemens/anatomical/001 20.1 6.1 3.3×
generic/compressed_j2k/001 30.7 12.1 2.5×
philips_enhanced/anatomical/001 32.5 15.6 2.1×
philips_enhanced/fmri/001 15.2 9.5 1.6×

Across all 47 convertible test series, niitrous is 1.6× to 8.1× faster (enhanced multiframe Philips files see the smallest gains).

uv run python bench/bench_vs_legacy.py --repeat 3 --synthetic 300

Thread Scaling

Same conversion with niitrous capped via threads (default: all cores). Threads parallelize work both within a single series and across multiple series.

Configuration 1 series (300×512×512) vs. dicom2nifti 16 series (60×512×512) vs. dicom2nifti
dicom2nifti 1652.5 ms — 5301.9 ms —
niitrous (1 thread) 1513.3 ms 1.1× 4998.0 ms 1.1×
niitrous (2 threads) 802.9 ms 2.1× 2634.7 ms 2.0×
niitrous (4 threads) 446.3 ms 3.7× 1391.0 ms 3.8×
niitrous (8 threads) 273.0 ms 6.1× 799.7 ms 6.6×
niitrous (16 threads) 181.8 ms 9.1× 547.2 ms 9.7×

On a single thread, niitrous is only slightly faster because it defaults to gzip level 6 while dicom2nifti uses level 1. Beyond one thread, it scales nearly linearly: 16 threads are 8.3×–9.1× faster than a single thread.

uv run python bench/bench_vs_legacy.py --scaling --threads 1,2,4,8,16

File Size & Compression Level

Output .nii.gz size and conversion time for three synthetic 300×512×512 series of 16-bit pixels (157.3 MB uncompressed) on all cores.

  • Phantom is CT-like (noisy tissue ellipse in constant air)

  • Walk is a per-row random walk with no flat regions.

Tool & Level Phantom Size (% raw) Phantom Time Walk Size (% raw) Walk Time
dicom2nifti (level 1) 29.1 MB (18.5%) 1082.9 ms 59.7 MB (37.9%) 1696.0 ms
niitrous, level 1 42.1 MB (26.8%) 65.1 ms 94.8 MB (60.3%) 80.4 ms
niitrous, level 6 (default) 28.0 MB (17.8%) 93.1 ms 51.5 MB (32.7%) 173.6 ms
niitrous, level 9 27.6 MB (17.5%) 186.1 ms 56.5 MB (35.9%) 271.3 ms
  • CT is the phantom as scanners store CT: unsigned pixels with RescaleIntercept −1024, which dicom2nifti (via pydicom) writes as float64. niitrous stores it as int16 (narrow_dtype, on by default).
Tool & Level CT Size (% raw) CT Time Output Type
dicom2nifti (level 1) 50.3 MB (32.0%) 2393.1 ms float64
niitrous, level 1 42.1 MB (26.8%) 103.5 ms int16
niitrous, level 6 (default) 28.0 MB (17.8%) 129.8 ms int16
niitrous, level 9 27.6 MB (17.5%) 226.5 ms int16
niitrous, narrow_dtype=False 37.5 MB (23.8%) 309.3 ms float64

"Raw" is the 16-bit pixel data in the DICOM files (157.3 MB).

At the default level, niitrous files are 4% to 14% smaller than dicom2nifti's for the same int16 data, and 44% smaller for rescaled CT, which dicom2nifti widens to float64. Level 1 behaves differently in the two tools: niitrous uses zlib-rs, which trades compression ratio for speed at level 1 and produces ~50% larger files than standard zlib. Level 9 takes twice as long as level 6 with little or no size savings.

uv run python bench/bench_vs_legacy.py --sizes

Image I/O (vs. nibabel 5)

Reading and writing a 256×256×160×4 int16 image (80 MiB), warm page cache. Speedups are relative to nibabel 5.

File Layout Whole Array As float32 One Slice Save
.nii 1.7 ms* 4.4 ms (3×) 0.1 ms (4×) 95 ms (1×)
.nii.gz (standard) 48 ms (1.1×) 52 ms (1.2×) 47 ms (1.4×) 177 ms (2.5×)
.nii.gz (niitrous) 6.7 ms (8×) 9.2 ms (7×) 1.8 ms (39×) 174 ms (2.5×)
.nii.zst 57 ms (1.1×) 60 ms (1.2×) 53 ms (1.1×) 119 ms (2.3×)

*nibabel memory-maps uncompressed .nii files (0.6 ms); niitrous reads them into memory.

Standard gzip files are a single stream, which can only be decompressed on one core (row 2, where libdeflate gives a small speedup). By contrast, niitrous writes gzip as independent, indexed members—still a valid .gz file to other tools—so it can decompress in parallel across all cores and only read the members a slice touches (row 3).

uv run python bench/bench_io.py

Resampling (vs. SimpleITK 2.5.8)

A 256×256×160 int16 volume with 1×1×2.5 mm voxels, already in memory, both libraries on all cores.

New spacing (mm) Mode niitrous SimpleITK Speedup
1 × 1 × 1 nearest 1.8 ms 6.7 ms 3.8×
linear 2.7 ms 9.1 ms 3.4×
cubic 39 ms 824 ms 21×
0.7 × 0.7 × 1.25 nearest 1.9 ms 10 ms 5.4×
linear 6.3 ms 20 ms 3.2×
cubic 47 ms 1515 ms 32×
1.5 × 1.5 × 1.5 nearest 0.9 ms 2.3 ms 2.4×
linear 2.4 ms 3.3 ms 1.4×
cubic 45 ms 463 ms 10×
2 × 2 × 5 nearest 0.6 ms 0.7 ms 1.2×
linear 0.9 ms 0.7 ms 0.9×
cubic 43 ms 276 ms 6.4×

The niitrous times include copying the NumPy array into Rust (about 0.5 ms here), which is what is left of the gap in the last linear row.

Linear and cubic results match SimpleITK to within 0.0005 on float32 data (rounding error). Nearest is identical except where a position falls exactly half-way between two voxels, where rounding error decides in both libraries.

Labels: the same grid as uint8 with 24 ellipsoids, resampled to 0.7×0.7×1.25 mm. Each cell is the share of voxels with the same label as the SimpleITK interpolator, and the mean Dice over labels.

niitrous, is_label=True Time vs. NearestNeighbor (10 ms) vs. LabelLinear (684 ms) vs. LabelGaussian (2247 ms)
nearest 2.1 ms 99.976%, Dice 0.9990 99.633%, Dice 0.9814 99.579%, Dice 0.9718
linear 34 ms 99.635%, Dice 0.9816 99.992%, Dice 0.9996 99.804%, Dice 0.9840
cubic 319 ms 99.588%, Dice 0.9745 99.852%, Dice 0.9886 99.896%, Dice 0.9926
uv sync --group bench
uv run python bench/bench_resample.py

Development

Requires a Rust toolchain and uv. Run uv sync to build the Rust extension into .venv and install dev dependencies, then run tests and lints:

uv sync
uv run pytest
cargo test
cargo clippy --workspace --all-targets -- -D warnings

Repository Layout

Path Description
crates/niitrous-io DICOM-independent image I/O layer (NIfTI, Analyze, MGH, compression, lazy proxies, orientations, resampling). Pure Rust except optional zstd and libdeflate features
crates/niitrous-core Pure-Rust DICOM conversion engine built on niitrous-io
crates/niitrous-cli niitrous CLI (library + binary)
crates/niitrous-py PyO3 extension module (niitrous._core)
python/niitrous Python package: public API, result types, and exceptions
tests Pytest suite, including parity tests against dicom2nifti and nibabel
bench Benchmarks against dicom2nifti and nibabel
legacy/dicom2nifti Reference implementation and test data (not tracked in git)

Parity Tests, Benchmarks & Cargo Features

Parity tests and benchmarks require the dicom2nifti reference checkout and the bench dependency group:

git clone https://github.com/icometrix/dicom2nifti legacy/dicom2nifti
uv sync --group bench

The codecs Cargo feature adds JPEG 2000 (OpenJPEG) and JPEG-LS (CharLS) decoding, which build from C/C++ source and require a C++ compiler. The zstd feature adds Zstandard support, and libdeflate speeds up reading standard gzip files; both build from C source. Python wheels are built with all three; for the Rust crates, pass --features codecs,zstd,libdeflate.

Releasing

Versions live in the root Cargo.toml: workspace.package.version, and the three niitrous-* entries under workspace.dependencies, which must match it. The Python package takes its version from there.

  1. Bump the version, merge to main, and tag the commit vX.Y.Z.
  2. Pushing the tag runs .github/workflows/release.yml: it builds wheels for Linux, macOS and Windows plus a source distribution, uploads them to PyPI, and publishes niitrous-io, niitrous-core and niitrous-cli to crates.io.

Both uploads use trusted publishing, so no tokens are stored. One-time setup:

  • PyPI: add a pending publisher for niitrous naming this repository, the workflow release.yml and the environment pypi.

  • crates.io: trusted publishing can only be configured for a crate that exists, so publish the first version by hand, then add the repository, release.yml and the environment crates-io as a trusted publisher on each crate:

    cargo publish -p niitrous-io -p niitrous-core -p niitrous-cli
    

Running the workflow by hand (without a tag) builds everything and publishes nothing.

Compatibility

dicom2nifti

Known differences from dicom2nifti:

  • Orientation: Output is RAS+ by default. dicom2nifti writes LAS; pass orientation="LAS" (or use niitrous.compat) for matching voxel order and affine.
  • Data type: Voxels are stored in the smallest type that holds every value exactly (narrow_dtype). dicom2nifti keeps pydicom's float64 for any series with RescaleSlope/Intercept, so a typical CT is int16 here and float64 there, at a quarter of the size. niitrous.compat and narrow_dtype=False keep dicom2nifti's type.
  • Fractional scaling: When rescaling gives fractions (Philips MR, PET) and one slope and intercept apply to every slice, the file holds the original integers with scl_slope / scl_inter, as scanners and dcm2niix store them; dicom2nifti writes float64 or float32. NIfTI-1 keeps the slope as float32, so values read back can differ from dicom2nifti's in about the 8th significant digit. Volume.data in memory is unchanged. niitrous.compat and integer_scaling=False write floats.
  • Enhanced Philips anatomical: Written as 3D rather than 4D with a trailing length-1 time axis.
  • Compression: Defaults to gzip level 6 (vs. nibabel's level 1) with indexed multi-member gzip (gzip_indexed=True); see File Size & Compression Level.
  • GE implicit-VR 4D: Writes .bval / .bvec files only when a b-value is non-zero (dicom2nifti misreads the b-value and writes them for fMRI too).
  • Resampling: Keeps voxels lying on the outer faces of the input volume (dicom2nifti inconsistently pads some depending on floating-point rounding). Resampling a 4D series or an enhanced multiframe file with uneven slice spacing raises an error instead of silently skipping resampling.

Quirks preserved from dicom2nifti:

  • Siemens mosaic pixels are not rescaled (RescaleSlope/RescaleIntercept are ignored).
  • Philips diffusion series drop the trailing volume when its b-value is zero (Philips appends a derived image there), b-values are truncated to whole numbers, and gradient directions are written as stored.
  • Siemens gradient directions (.bvec) are computed along the acquired image axes with the phase axis reversed, and are not changed when the volume is reoriented. This works for axial acquisitions written as LAS or RAS (FSL reads the same .bvec for both), but verify them for other orientations.

nibabel

Tests compare against nibabel on its bundled test files and cross-verify round-trips in both directions.

Area niitrous-io Status Notes
Affines & quaternions affine.rs Done Core subset of affines.py and quaternions.py
Data types & casting dtype.rs, header/mod.rs Done Excludes float16, float128, and bit types
Compression compress/ Done Gzip, indexed gzip, zstd, and bz2 (read)
Filenames & scaling filename.rs, scaling.rs Done Slope/intercept scaling (float32 factors)
Lazy array proxies proxy.rs Done Optimized slicing for ints, slices, and ...; other indices read full array
NIfTI-1 & NIfTI-2 header/nifti.rs, formats/nifti.rs Done Single files & pairs; dim_info/intent/slice-timing exposed as raw fields
NIfTI extensions extension.rs Partial Raw bytes round-tripped; no DICOM or JSON decoding
Analyze, SPM99, SPM2 header/analyze.rs, formats/analyze.rs Done Reads MATLAB v4 .mat files (what nibabel writes); ignores v5
FreeSurfer MGH / MGZ header/mgh.rs, formats/mgh.rs Done Tags after the footer are not preserved
Load/save & Image formats/mod.rs, image.rs Done Single Image type; format detected from content
Orientations & funcs orient.rs, funcs.rs Done 4×4 affines; squeeze, concat, four_to_three
Resampling resample.rs Partial B-spline affine_transform; Image.resample to new voxel sizes (not in nibabel)
Header battery runners — Not ported Headers are fixed on load without diagnostic reports

Future formats not yet started: GIFTI, CIFTI-2 (its NIfTI-2 files load with XML kept as raw extension bytes), FreeSurfer surfaces/annotations/morphometry, streamlines (TRK/TCK), MINC 1/2, PAR/REC, AFNI BRIK/HEAD, ECAT, and nicom.

Known differences from nibabel:

  • Uses a single Image class and Header class for all formats, exposed via a format property.
  • img.numpy() and np.asarray(img.dataobj) agree with nibabel; there is no array cache, so each call reads the file. Keep the array, or call img.load_data().
  • Loaded headers preserve vox_offset, scl_slope, and scl_inter as stored on disk (nibabel clears them).
  • Re-saving an unmodified image preserves its on-disk values and scaling exactly (nibabel rescales).
  • save(dtype=...) stores whole-number floats that fit the integer type exactly; nibabel always scales floats to the full integer range.
  • Uncompressed files are read into memory rather than memory-mapped, because the Rust crates forbid unsafe code.
  • SPM .mat files in MATLAB v5 format are not read; the affine then comes from the header's voxel sizes and origin.
  • Image.reorient does not update NIfTI dim_info (frequency, phase, and slice axes).

License

MIT. niitrous is derived from dicom2nifti, © icometrix NV, also MIT.

Metadata

Release files for niitrous 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for niitrous 0.1.1
File Size Uploaded Provenance Actions
niitrous-0.1.1.tar.gz 270.3 kB Without provenance Details for niitrous-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for niitrous 0.1.1
File Actions
niitrous-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for niitrous-0.1.1-cp310-abi3-win_amd64.whl
niitrous-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for niitrous-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
niitrous-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for niitrous-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
niitrous-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for niitrous-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
niitrous-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for niitrous-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 15.3 MB

Release files / niitrous-0.1.1.tar.gz

Download URL niitrous-0.1.1.tar.gz
Size 270.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5b961cdec89564d3925d58ed012a3fe4a16f580aa429e39b445117b378b7fe12
BLAKE2b-256 checksum
How to use checksums
2bd50b5fe51b60f57de3ddadccb827f20ce98053bf83325c8209a5d651faa491
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / niitrous-0.1.1-cp310-abi3-win_amd64.whl

Download URL niitrous-0.1.1-cp310-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9fb1da11bae03af4f452d7550a6a58498052430c8f0332cc8b284ca23e6b9191
BLAKE2b-256 checksum
How to use checksums
8800ad405f74c1e53e046ee0e65393df73e22873fb9ebbe222c043fd82eee733
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / niitrous-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL niitrous-0.1.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 3.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c97dceea6050ee74a50393eeae750b8dfbf490689d251e58797ad86effa4651f
BLAKE2b-256 checksum
How to use checksums
e5f9750dc38acaa4ccc89b6a1f09ccb3e1af935aa90e49b4d1b0285367e70fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / niitrous-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL niitrous-0.1.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
551ca282b2d8eae8bf69c93a1105ed36962c0a8cf335d02f9f6b80a5f02e4aee
BLAKE2b-256 checksum
How to use checksums
56b16e848117b063e2d452589e3c1f9998df9620fbc2d1753ef5b4b1e7a7b1fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / niitrous-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL niitrous-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f355e76b2f2da2e8363c2e2c13dfd04839dae67b732b2c74f6e988b348487717
BLAKE2b-256 checksum
How to use checksums
a87a5ff65272ab3797bafe05fde191202e80b9227761100b0f0208f6f970fb78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / niitrous-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL niitrous-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1d253da1f577160087db86e8d1f7765580b8e1e6a4a640ae335aadd534e41d37
BLAKE2b-256 checksum
How to use checksums
53950b999de2e57797cdb63dd8c381ad43b4d22b0eded99a5a1c96a03b2a32b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for niitrous 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

6 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page