Expand description
NIfTI file I/O for WASM
Provides functions to load and save NIfTI files from/to byte arrays, suitable for use in WebAssembly where filesystem access is not available.
Structs§
- Nifti
Data - NIfTI data loaded from bytes
- QForm 🔒
- NIfTI-1’s quaternion (“qform”) description of a voxel→world transform — method 2 in the spec.
Constants§
- NIFTI_
XYZT_ UNITS xyzt_unitsfor every file this crate writes:NIFTI_UNITS_MM | NIFTI_UNITS_SEC.
Functions§
- affine_
from_ 🔒quatern - Rebuild the voxel→world affine a reader derives from a qform — the spec’s
nifti_quatern_to_mat44.pixdimispixdim[1..=3]as it appears in the header. - encode_
nifti 🔒 - Encode
volumes(eachnx*ny*nzvalues, x fastest) as an uncompressed NIfTI-1 file, 3D (four_d = false, exactly one volume) or 4D (dim[4] = volumes.len()). Both writers share this, so they cannot disagree on the header: float32 data, unit scaling, sform plus a matching qform where one exists, andNIFTI_XYZT_UNITS. - get_
affine 🔒 - Get affine transformation matrix from header
- get_
header_ 🔒info - Get header info for diagnostics
- gzip 🔒
- is_gzip 🔒
- Check if bytes are gzip compressed
- load_
itk_ geometry - The image geometry ITK (ITK 5.3, as in ANTs 2.4.3) reads from a NIfTI file’s header
(
ItkGeometry::from_nifti_header), for ports whose output depends on it (n4_bias_correction). Supports .nii and .nii.gz bytes. - load_
nifti - Load a NIfTI file from bytes
- load_
nifti_ 4d - Load a 4D NIfTI file from bytes (for multi-echo data)
- qform_
for 🔒 - The qform to write alongside an sform, or
Nonewhen no quaternion reproduces the affine. - quatern_
from_ 🔒affine - Decompose a row-major voxel→world affine into its quaternion form, following the NIfTI-1
spec’s
nifti_mat44_to_quatern. - read_
itk_ geometry_ file load_itk_geometryof a file.- read_
nifti_ dims - Read only the dimensions from a NIfTI file header without loading volume data.
- read_
nifti_ file - Read a NIfTI file from a filesystem path
- save_
nifti - Save data as NIfTI bytes
- save_
nifti_ 4d - Save several 3D volumes on one grid as a single uncompressed 4D NIfTI file.
- save_
nifti_ 4d_ gz save_nifti_4d, gzipped (.nii.gz).- save_
nifti_ 4d_ to_ file - Save several 3D volumes as one 4D NIfTI file (see
save_nifti_4d). - save_
nifti_ gz - Save data as gzipped NIfTI bytes (.nii.gz)
- save_
nifti_ to_ file - Save NIfTI data to a file
Type Aliases§
- Nifti4d
- A loaded 4D volume:
(data, (nx, ny, nz, nt), (vsx, vsy, vsz), affine).