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!

BayesianMonk
  • 540
  • 7
  • 23

1 Answers1

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)
darcymason
  • 1,223
  • 6
  • 9