io.write_nifti

Contents

io.write_nifti#

bartorch.io.write_nifti()#

Write an image as a NIfTI file, and its timings as a BIDS sidecar.

Parameters:
  • path (str) – .nii or .nii.gz.

  • image (torch.Tensor or numpy.ndarray) – (*leading, z, y, x) or (y, x), real or complex; leading axes become the fourth NIfTI dimension, one after another.

  • affine (torch.Tensor or numpy.ndarray) – (4, 4), from voxel indices (x, y, z) to RAS millimetres; it is stored as both the sform and the qform.

  • timings (dict, default=None) – echo_time, inversion_time, repetition_time in milliseconds and flip_angle in degrees, each a number or one per volume, written beside the image as a JSON sidecar in BIDS units.

Returns:

The image file.

Return type:

pathlib.Path