import SimpleITK as sitk
path = 'nii全路径'
nii_obj = sitk.GetArrayFromImage(sitk.ReadImage(path)) #shape为(c,h,w),c为所有slice的数量
import nibable as nil
nii_obj = nil.load(path)
data_obj = nii_obj.dataobj #shape为 w,h,c
data_obj = np.transpose(data_obj,(2,1,0)) #shape为(c,h,w),c为所有slice的数量
速度对比: nibable比simpleitk快
加载18*512*512的图像,SimpleITK耗时:0.1018986701965332 s nibable加载+维度变换耗时: 0.09411430358886719 s
过去已逝,未来太远,只争今朝