import pydicom as dicom
import os
import cv2
import numpy as np
import lxml.etree as etree
import pydicom
from PIL import Image
from skimage.draw import polygon
from matplotlib.pyplot import plot as plt
# 这个函数输入的是xml的路径,返回的是读取的坐标# 这里获得的坐标是所有层的,但只读取了单个病理医生标注的第一个结节,后面的全都不读,要是想要读的话可以改一下代码defxml_reader(path):
anno ={
}
xmlns ='{http://www.nih.gov}'
tree = etree.parse(path)# for ann in tree.findall('./Annotation'):assert tree.findall(xmlns +'ResponseHeader')!=[],'{}.has no ResponseHeader'.format(path)
Res = tree.findall(xmlns +'ResponseHeader')[0]# anno['SeriesInstanceUid'] = Res.findall(xmlns + 'SeriesInstanceUid')[0].text# anno['StudyInstanceUID'] = Res.findall(xmlns + 'StudyInstanceUID')[0].text# anno['session'] = []if tree.findall