美文网首页
读取显示医学图像dcm格式2019-10-13

读取显示医学图像dcm格式2019-10-13

作者: 一只大南瓜 | 来源:发表于2019-10-13 21:17 被阅读0次

文件夹内所有数据的读取

import os.path
import re
filepath = 'D:/datasets/Soft-tissue-Sarcoma/STS_004/09-30-1999-RIGHT THIGH C-81525/601-CLARKE CALFAXT1 RT - RESEARCH-86077'
for info in os.listdir(filepath):
   file_name = os.path.join('%s\%s' % (filepath, info))
   ds = pydicom.read_file(file_name)
   # print(ds.dir("pat"))   #查看dcm文件的所有词段
   pix = ds.pixel_array
   # pylab.imshow(ds.pixel_array, cmap=pylab.cm.bone)
   # pylab.show()

dcm文件中包含患者信息的字段,可以通过dir查看DICOM文件有什么信息,可以通过字典返回相关的值。(本人没运行)

import json
def loadFileInformation(filename):
    information = {}
    ds = dicom.read_file(filename)
    information['PatientID'] = ds.PatientID
    information['PatientName'] = ds.PatientName
    information['PatientBirthDate'] = ds.PatientBirthDate
    information['PatientSex'] = ds.PatientSex
    information['StudyID'] = ds.StudyID
    information['StudyDate'] = ds.StudyDate
    information['StudyTime'] = ds.StudyTime
    information['InstitutionName'] = ds.InstitutionName
    information['Manufacturer'] = ds.Manufacturer
    print dir(ds)
    print type(information)
    return information

a=loadFileInformation('AT0001_100225002.DCM')
print a

参考:https://www.cnblogs.com/dhanchor/p/7193472.html

相关文章

网友评论

      本文标题:读取显示医学图像dcm格式2019-10-13

      本文链接:https://www.haomeiwen.com/subject/sbvkmctx.html