I have 3D array in Nifti file (.ii.gz) and I want to save it as a 3D numpy array. I used Nibabel to convert Numpy to Nifti1. Can I do the opposite?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
From nipy
import numpy as np
import nibabel as nib
img = nib.load(example_filename)
a = np.array(img.dataobj)
回答2:
You can also do this:
import numpy as np
import nibabel as nib
img_nifti = nib.load(filepath)
img = img_nifti.get_data()