3
$\begingroup$

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

$\endgroup$
1

1 Answer 1

3
$\begingroup$

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")
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.