示例#1
0
文件: tags.py 项目: johnliu123/deid
def get_tag(field):
    '''get_tag will return a dictionary with tag indexed by field. For each entry,
    a dictionary lookup is included with VR,  
    :name: the keyword to get tag for, eg "PatientIdentityRemoved"
    '''
    found = [{
        key: value
    } for key, value in DicomDictionary.items() if value[4] == field]
    tags = dict()
    if len(found) > 0:

        # (VR, VM, Name, Retired, Keyword
        found = found[0]  # shouldn't ever have length > 1
        tag = Tag(list(found)[0])
        VR, VM, longName, retired, keyword = found[tag]

        manifest = {
            "tag": tag,
            "VR": VR,
            "VM": VM,
            "keyword": keyword,
            "name": longName
        }

        tags[field] = manifest
    return tags
 def get_matches(self, search_str):
     """
     Get matching tags in a pydicom._dicom_dict.DicomDictionary format
     :param search_str: a string for partial keyword of hex-tag match
     :return: partial matches
     :rtype: dict
     """
     if search_str:
         search_str = remove_non_alphanumeric(search_str).lower()
         return {tag: entry for tag, entry in DicomDictionary.items()
                 if search_str in entry[4].lower() or  # keyword match
                 search_str in remove_non_alphanumeric(str(self.int_to_tag(tag)))}  # hex tag match
     else:
         return DicomDictionary
示例#3
0
def get_dictionary_items():
    return DicomDictionary.items()
示例#4
0
def get_dicom_tag_for_name(name):
    for key, value in DicomDictionary.items():
        if name == value[4]:
            return hex(int(key))
    return None