def main():
# Read the example RT structure and RT dose files
# The testdata was downloaded from the dicompyler website as testdata.zip
# Obtain the structures and DVHs from the DICOM data
rtssfile = 'testdata/rtss.dcm'
rtdosefile = 'testdata/rtdose.dcm'
RTss = dicomparser.DicomParser(rtssfile)
#RTdose = dicomparser.DicomParser("testdata/rtdose.dcm")
RTstructures = RTss.GetStructures()
# Generate the calculated DVHs
calcdvhs = {}
for key, structure in RTstructures.iteritems():
calcdvhs[key] = dvhcalc.get_dvh(rtssfile, rtdosefile, key)
if (key in calcdvhs) and (len(calcdvhs[key].counts) and calcdvhs[key].counts[0]!=0):
print ('DVH found for ' + structure['name'])
pl.plot(calcdvhs[key].counts * 100/calcdvhs[key].counts[0],
color=dvhcalc.np.array(structure['color'], dtype=float) / 255,
label=structure['name'],
linestyle='dashed')
#else:
# print("%d: no DVH"%key)
pl.xlabel('Distance (cm)')
pl.ylabel('Percentage Volume')
pl.legend(loc=7, borderaxespad=-5)
pl.setp(pl.gca().get_legend().get_texts(), fontsize='x-small')
pl.savefig('testdata/dvh.png', dpi = 75)
评论列表
文章目录