0

I need to add the corresponding text keys of tags to pydicom so it can read them from a DICOM file. So far I have been able to add the entries to the DICOM file using the add_new() method. However, I still have to read these values using the hexa codes.

I have checked the documentation, and there is a method called add_private_dict_entries for this. However, I cannot seem to find this method in pydicom. I have followed exactly as in the example:

from pydicom import Dataset
toing_dicom_attr = {
                0x270f03e9: ('SH', 1, 'Was Viewed By TOINGTOING'),
                0x270f03ea: ('SH', 1, 'At Least One toing toing'),
            }
add_private_dict_entries("TOINGSCOMPANY", toing_dicom_attr)

However I get the following Error:

NameError: name 'add_private_dict_entries' is not defined

I have also tried using pydicom.datadict.add_private_dict_entries() but it does not work. How can I get my private attributes to be readable by my pydicom installation.

Thank you in advance.

Community
  • 1
  • 1
toing_toing
  • 2,334
  • 1
  • 37
  • 79
  • 1
    The documentation you linked is in the "dev" branch, i.e. not in a released version, only in the repository. Which version of pydicom are you using? – darcymason May 11 '19 at 21:37
  • Thank you for pointing this out, I was indeed using the dev documentation. This is the correct link: https://pydicom.github.io/pydicom/stable/api_ref.html#module-pydicom.datadict . This method is not available in stable yet. It makes sense now. I use the latest stable version – toing_toing May 14 '19 at 08:18

2 Answers2

1

You did not import add_private_dict_entries correctly:

from pydicom import Dataset
from pydicom.datadict import add_private_dict_entries


toing_dicom_attr = {
                0x270f03e9: ('SH', 1, 'Was Viewed By TOINGTOING'),
                0x270f03ea: ('SH', 1, 'At Least One toing toing'),
            }
add_private_dict_entries("TOINGSCOMPANY", toing_dicom_attr)

would work.

UdiE
  • 11
  • 2