Add dictionary items in the standard DICOM dictionary

This examples illustrates how to add dictionary items to the ‘standard’ DICOM dictionary dynamically.


Note that this is not a recommended solution in general but it is useful as a demonstration or for in-house programs only, or to get around elements missing from pydicom’s DICOM dictionaries.

(1001, 1001) Private tag data                    UL: 42
(1001, 1002) Private tag data                    OB: '12345'
(1001, 1003) Private tag data                    UI:

# authors : Darcy Mason
#           Guillaume Lemaitre <>
# license : MIT

from pydicom.datadict import DicomDictionary, keyword_dict
from pydicom.dataset import Dataset


# Define items as (VR, VM, description, is_retired flag, keyword)
#   Leave is_retired flag blank.
new_dict_items = {
    0x10011001: ('UL', '1', "Test One", '', 'TestOne'),
    0x10011002: ('OB', '1', "Test Two", '', 'TestTwo'),
    0x10011003: ('UI', '1', "Test Three", '', 'TestThree'),

# Update the dictionary itself

# Update the reverse mapping from name to tag
new_names_dict = dict([(val[4], tag) for tag, val in

# Test that it is working
ds = Dataset()  # or could get one from dcmread, etc

ds.TestOne = 42
ds.TestTwo = '12345'
ds.TestThree = ''


Total running time of the script: ( 0 minutes 0.001 seconds)

Gallery generated by Sphinx-Gallery