-1

I'm trying to find the value of several tags using pydicom. For some reason only certain tags work while others do not. Below is a traceback explaining my problem. Can anyone see a way around the int() base 16 problem?

>>> ds['0x18','0x21'].value
'SP'
>>> ds['0x18','13x14'].value
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/space/jazz/1/users/gwarner/anaconda/lib/python2.7/site-packages/pydicom-0.9.9-py2.7.egg/dicom/dataset.py", line 276, in __getitem__
tag = Tag(key)
  File "/space/jazz/1/users/gwarner/anaconda/lib/python2.7/site-packages/pydicom-0.9.9-py2.7.egg/dicom/tag.py", line 27, in Tag
arg = (int(arg[0], 16), int(arg[1], 16))
ValueError: invalid literal for int() with base 16: '13x14'
Suever
  • 64,497
  • 14
  • 82
  • 101
G Warner
  • 1,309
  • 1
  • 15
  • 27
  • The problem is that '13x14' is not a valid hex representation of a number but every other value you have is hex so where did the 13x14 come from – PyNEwbie Jun 10 '16 at 19:10
  • I have never used pydicom but the message is clear that it is expecting an integer value – PyNEwbie Jun 10 '16 at 19:10

1 Answers1

0

'13x14' is not a valid representation of base 16 number.

In python, base 16 numbers are represented with '0x' as prefix and then the number in base 16.

For example:

0x0, 0x1, 0x001, 0x235, 0xA5F, ..., are all valid base 16 number representations.


This:

ds['0x18','13x14'].value

Could be, for example, this:

ds['0x18','0x14'].value

And it should execute fine.

Božo Stojković
  • 2,893
  • 1
  • 27
  • 52