pydicom.datadict.add_dict_entry

pydicom.datadict.add_dict_entry(tag: int, VR: str, keyword: str, description: str, VM: str = '1', is_retired: str = '') None[source]

Update the DICOM dictionary with a new non-private entry.

Parameters
  • tag (int) – The tag number for the new dictionary entry.

  • VR (str) – DICOM value representation.

  • description (str) – The descriptive name used in printing the entry. Often the same as the keyword, but with spaces between words.

  • VM (str, optional) – DICOM value multiplicity. If not specified, then '1' is used.

  • is_retired (str, optional) – Usually leave as blank string (default). Set to 'Retired' if is a retired data element.

Raises

ValueError – If the tag is a private tag.

Notes

Does not permanently update the dictionary, but only during run-time. Will replace an existing entry if the tag already exists in the dictionary.

See also

pydicom.examples.add_dict_entry

Example file which shows how to use this function

add_dict_entries

Update multiple values at once.

Examples

>>> from pydicom import Dataset
>>> add_dict_entry(0x10021001, "UL", "TestOne", "Test One")
>>> add_dict_entry(0x10021002, "DS", "TestTwo", "Test Two", VM='3')
>>> ds = Dataset()
>>> ds.TestOne = 'test'
>>> ds.TestTwo = ['1', '2', '3']