TransWikia.com

How can I create .nii (nifti) file from 3D Numpy array

Data Science Asked by Eren Kallikci on August 1, 2021

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

One Answer

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")

Answered by Tallys Prado on August 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP