import nibabel as nib import numpy as np data = np.arange(4*4*3).reshape(4,4,3) new_image = nib.Nifti1Image(data, affine=np.eye(4))