def add_dict_entries(new_entries_dict): """Update pydicom's DICOM dictionary with new non-private entries. Parameters ---------- new_entries_dict : dict Dictionary of form: {tag: (VR, VM, description, is_retired, keyword),...} where parameters are as described in add_dict_entry Raises ------ ValueError If one of the entries is a private tag. See Also -------- add_dict_entry Simpler function to add a single entry to the dictionary. Examples -------- >>> from pydicom import Dataset >>> new_dict_items = { ... 0x10021001: ('UL', '1', "Test One", '', 'TestOne'), ... 0x10021002: ('DS', '3', "Test Two", '', 'TestTwo'), ... } >>> add_dict_entries(new_dict_items) >>> ds = Dataset() >>> ds.TestOne = 'test' >>> ds.TestTwo = ['1', '2', '3'] >>> add_dict_entry(0x10021001, "UL", "TestOne", "Test One") >>> ds = Dataset() >>> ds.TestOne = 'test' """ if any([BaseTag(tag).is_private for tag in new_entries_dict]): raise ValueError( 'Private tags cannot be added using "add_dict_entries" - ' 'use "add_private_dict_entries" instead') # Update the dictionary itself DicomDictionary.update(new_entries_dict) # Update the reverse mapping from name to tag new_names_dict = dict([(val[4], tag) for tag, val in new_entries_dict.items()]) keyword_dict.update(new_names_dict)
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 add_dict_entries( new_entries_dict: Dict[int, Tuple[str, str, str, str, str]] ) -> None: """Update the DICOM dictionary with new non-private entries. Parameters ---------- new_entries_dict : dict :class:`dict` of form: ``{tag: (VR, VM, description, is_retired, keyword), ...}`` where parameters are as described in :func:`add_dict_entry`. Raises ------ ValueError If one of the entries is a private tag. See Also -------- add_dict_entry Add a single entry to the dictionary. Examples -------- >>> from pydicom import Dataset >>> new_dict_items = { ... 0x10021001: ('UL', '1', "Test One", '', 'TestOne'), ... 0x10021002: ('DS', '3', "Test Two", '', 'TestTwo'), ... } >>> add_dict_entries(new_dict_items) >>> ds = Dataset() >>> ds.TestOne = 'test' >>> ds.TestTwo = ['1', '2', '3'] """ if any([BaseTag(tag).is_private for tag in new_entries_dict]): raise ValueError( 'Private tags cannot be added using "add_dict_entries" - ' 'use "add_private_dict_entries" instead') # Update the dictionary itself DicomDictionary.update(new_entries_dict) # Update the reverse mapping from name to tag keyword_dict.update({val[4]: tag for tag, val in new_entries_dict.items()})
def add_dict_entries(new_entries_dict): """Update pydicom's DICOM dictionary with new entries. Parameters ---------- new_entries_dict : dict Dictionary of form: {tag: (VR, VM, description, is_retired, keyword),...} where parameters are as described in add_dict_entry See Also -------- add_dict_entry Simpler function to add a single entry to the dictionary. Examples -------- >>> from pydicom import Dataset >>> new_dict_items = { ... 0x10011001: ('UL', '1', "Test One", '', 'TestOne'), ... 0x10011002: ('DS', '3', "Test Two", '', 'TestTwo'), ... } >>> add_dict_entries(new_dict_items) >>> ds = Dataset() >>> ds.TestOne = 'test' >>> ds.TestTwo = ['1', '2', '3'] >>> add_dict_entry(0x10011001, "UL", "TestOne", "Test One") >>> ds = Dataset() >>> ds.TestOne = 'test' """ # Update the dictionary itself DicomDictionary.update(new_entries_dict) # Update the reverse mapping from name to tag new_names_dict = dict([(val[4], tag) for tag, val in new_entries_dict.items()]) keyword_dict.update(new_names_dict)
def add_dict_entries(new_entries_dict): """Update pydicom's DICOM dictionary with new entries. Parameters ---------- new_entries_dict : dict Dictionary of form: {tag: (VR, VM, description, is_retired, keyword),...} where parameters are as described in add_dict_entry See Also -------- add_dict_entry Simpler function to add a single entry to the dictionary. Examples -------- >>> new_dict_items = { 0x10011001: ('UL', '1', "Test One", '', 'TestOne'), 0x10011002: ('DS', '3', "Test Two", '', 'TestTwo'), } >>> add_dict_entries(new_dict_items) >>> ds = Dataset() >>> ds.TestOne = 'test' >>> ds.TestTwo = ['1', '2', '3'] add_dict_entry(0x10011001, "UL", "TestOne", "Test One") >>> ds = Dataset() >>> ds.TestOne = 'test' """ # Update the dictionary itself DicomDictionary.update(new_entries_dict) # Update the reverse mapping from name to tag new_names_dict = dict([(val[4], tag) for tag, val in new_entries_dict.items()]) keyword_dict.update(new_names_dict)
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
def get_dictionary_items(): return DicomDictionary.items()
def get_dicom_tag_for_name(name): for key, value in DicomDictionary.items(): if name == value[4]: return hex(int(key)) return None
DicomDictionary.update({ 0x00000000: ('UL', '1', "CommandGroupLength", ''), 0x00000002: ('UI', '1', "Affected SOP class", ''), 0x00000003: ('UI', '1', "RequestedSOPClassUID", ''), 0x00000100: ('US', '1', "CommandField", ''), 0x00000110: ('US', '1', "MessageID", ''), 0x00000120: ('US', '1', "MessageIDBeingRespondedTo", ''), 0x00000600: ('AE', '1', "MoveDestination", ''), 0x00000700: ('US', '1', "Priority", ''), 0x00000800: ('US', '1', "DataSetType", ''), 0x00000900: ('US', '1', "Status", ''), 0x00000901: ('AT', '1', "OffendingElement", ''), 0x00000902: ('LO', '1', "ErrorComment", ''), 0x00000903: ('US', '1', "ErrorID", ''), 0x00001000: ('UI', '1', " AffectedSOPInstanceUID", ''), 0x00001001: ('UI', '1', "RequestedSOPInstanceUID", ''), 0x00001002: ('US', '1', "EventTypeID", ''), 0x00001005: ('AT', '1', "AttributeIdentifierList", ''), 0x00001008: ('US', '1', "ActionTypeID", ''), 0x00001020: ('US', '1', "NumberOfRemainingSuboperations", ''), 0x00001021: ('US', '1', "NumberOfCompletedSuboperations", ''), 0x00001022: ('US', '1', "NumberOfFailedSuboperations", ''), 0x00001023: ('US', '1', "NumberOfWarningSuboperations", ''), 0x00001030: ('AE', '1', "MoveOriginatorApplicationEntityTitle", ''), 0x00001031: ('US', '1', "MoveOriginatorMessageID", ''), })