#! /usr/bin/python
# -*- coding: utf-8 -*-
# Author: Joker
# Copyright (c) 2019 OpenString. All rights reserved.
from openstring.util import DcmUtil, FileUtil
def getDcmTreeDist(dcmDir):
DcmTreeList = {}
filePathList = FileUtil.listAllFilePath(dcmDir)
for filePath in filePathList:
type = DcmUtil.getDicomType(filePath)
if (type != None and type in ['CT', 'RTSTRUCT', 'RTDOSE', 'RTPLAN']):
# 获取基本信息
dcmData = DcmUtil.getDicomData(filePath)
PatientID = dcmData.get('PatientID')
SOPInstanceUID = dcmData.get('SOPInstanceUID')
# 归类存储
if (DcmTreeList.get(PatientID) == None):
DcmTreeList[PatientID] = {'CT': {}, 'RTSTRUCT': {}, 'RTDOSE': {}, 'RTPLAN': {}}
DcmTreeList[PatientID][type][SOPInstanceUID] = filePath
return DcmTreeList