我在Nifti文件(.ii.gz)中有3D数组,我想将其保存为3D numpy数组。我使用Nibabel将Numpy转换为Nifti1。我可以反其道而行吗?
答案 0 :(得分:5)
来自nipy
import numpy as np
import nibabel as nib
img = nib.load(example_filename)
a = np.array(img.dataobj)
答案 1 :(得分:0)
您也可以这样做:
import numpy as np
import nibabel as nib
img_nifti = nib.load(filepath)
img = img_nifti.get_data()