Skip to main content

save_nifti_4d

Function save_nifti_4d 

Source
pub fn save_nifti_4d(
    volumes: &[&[f64]],
    dims: (usize, usize, usize),
    voxel_size: (f64, f64, f64),
    affine: &[f64; 16],
) -> Result<Vec<u8>, String>
Expand description

Save several 3D volumes on one grid as a single uncompressed 4D NIfTI file.

Each of volumes holds nx*ny*nz values in Fortran order (x fastest) and becomes one entry along the fourth axis, in order. The header is the 3D writer’s — same datatype, scaling, sform/qform and units — with dim[0] = 4, dim[4] = volumes.len() and pixdim[4] = 1, even for a single volume. Reading the result back with load_nifti_4d gives the volumes concatenated in the same order.