import SimpleITK as sitk
from matplotlib import pyplot as plt
def showNii(img):
for i in range(img.shape[0]):
plt.imshow(img[i,:,:],cmap='gray')
plt.show()
itk_img = sitk.ReadImage('F:\\BraTs learning\\brats2021\\BraTS2021_00495\\BraTS2021_00495_flair.nii')
#img = sitk.GetArrayFromImage(sitk.ReadImage(itk_img))
img = sitk.GetArrayFromImage(itk_img)
print(img.shape) # (155, 240, 240) 表示各个维度的切片数量
showNii(img) #显示nii图片