1

Is it possible to create a Tag (pydicom.tag.Tag) only from its name? For instance, 'Rows' is associated to (0028,0010). Creating a Tag for it would be:

tag=pydicom.tag.Tag(0x28,0x10)

I would like to create the same tag from its name, like

tag=pydicom.tag.Tag('Rows')

which is not working.

Does anyone know if it is possible to do it? Or equivalently, is there a function to find the number of a tag from its name?

Thanks!

1 Answer 1

7

Update: As of pydicom 1.3, can now create a Tag instance using the keyword, e.g.

>>> from pydicom.tag import Tag
>>> Tag("Rows")
(0028, 0010)

Original answer:

In the DICOM standard, the tag 'name' is properly called a 'keyword'. The tag_for_keyword method in pydicom.datadict that does what you are asking:

>>> from pydicom.datadict import tag_for_keyword
>>> from pydicom.tag import Tag
>>> tag_for_keyword("Rows")  # just as a number, not a Tag instance
2621456
>>> tag = Tag(tag_for_keyword("Rows"))
>>> tag
(0028, 0010)
1
  • Thanks a lot, this is exactly what I was looking for! Commented Mar 15, 2019 at 11:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.