3

I have a prediction numpy array. How can I make a .nii or .nii.gz mask file from the array?

Eren Kallikci
  • 31
  • 1
  • 2

1 Answers1

3

You can this using nibabel:

import nibabel as nb

ni_img = nib.Nifti1Image(numpy_array, affine=np.eye(4))
nib.save(ni_img, "dicom_volume_image.nii")
Stephen Rauch
  • 1,783
  • 11
  • 21
  • 34