import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pylab as plt
import nibabel as nib
from nibabel import nifti1
from nibabel.viewers import OrthoSlicer3D
example_filename = 'H:Project/nnUNet-1-masterDATASET/nnUNet_raw/nnUNet_raw_dataTask88_KneeimagesTr/Knee_001.nii.gz'
img = nib.load(example_filename)
print(img)
print(img.header['db_name']) # 输出头信息
width, height, queue = img.dataobj.shape
OrthoSlicer3D(img.dataobj).show()
拖动鼠标可查看像素值和位置信息



