python中的DICOM切片顺序
我有一个关于切片订购的问题: 我有大约80张髋关节的照片,但没有从脚到头或头到脚的排列 有没有办法把它们按预定顺序排列python中的DICOM切片顺序,python,matplotlib,slice,dicom,pydicom,Python,Matplotlib,Slice,Dicom,Pydicom,我有一个关于切片订购的问题: 我有大约80张髋关节的照片,但没有从脚到头或头到脚的排列 有没有办法把它们按预定顺序排列 # pixel aspects, assuming all slices are the same ps = slices[0].PixelSpacing ss = slices[0].SliceThickness ax_aspect = ps[1]/ps[0] sag_aspect = ps[1]/ss cor_aspect = ss/ps[0] # create 3D
# pixel aspects, assuming all slices are the same
ps = slices[0].PixelSpacing
ss = slices[0].SliceThickness
ax_aspect = ps[1]/ps[0]
sag_aspect = ps[1]/ss
cor_aspect = ss/ps[0]
# create 3D array
img_shape = list(slices[0].pixel_array.shape)
img_shape.append(len(ct_images))
print(img_shape)
img3d = np.zeros(img_shape)
# fill 3D array with the images from the files
for i, s in enumerate(slices):
img2d = s.pixel_array
img3d[:, :, i] = img2d
# plot 3 orthogonal slices
a1 = plt.subplot(2,2,1)
plt.imshow(img3d[:,:,img_shape[2]//2])
a1.set_aspect(ax_aspect)
a2 = plt.subplot(2,2,3)
plt.imshow(img3d[:,img_shape[1]//2,:])
a2.set_aspect(sag_aspect)
a3 = plt.subplot(2,2,2)
plt.imshow(img3d[img_shape[0]//2,:,:].T)
a3.set_aspect(cor_aspect)
plt.show()
SOP类UID为CT图像存储
这是代码,这些是结果的图片
slices=sorted(slices,key=lambda x:x.ImagePositionPatient[2])
可能是您想要的,这取决于您的SOP类UID是什么