AttributeError: Dataset does not have attribute 'TransferSyntaxUID'.

1,026 views
Skip to first unread message

elena....@medimsight.com

unread,
Apr 11, 2014, 6:42:33 AM4/11/14
to pyd...@googlegroups.com
Hi all,

I am using pytho-dicom library (version 0.9.8) to obtain some metadata information from dicom files and I have the following error:

import dicom
dcmmeta = dicom.read("XXXX.dcm")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/dicom/filereader.py", line 625, in read_file
    force=force)
  File "/usr/local/lib/python2.7/dist-packages/dicom/filereader.py", line 538, in read_partial
    transfer_syntax = file_meta_dataset.TransferSyntaxUID
  File "/usr/local/lib/python2.7/dist-packages/dicom/dataset.py", line 248, in __getattr__
    "'{0:s}'.".format(name))
AttributeError: Dataset does not have attribute 'TransferSyntaxUID'.

When I open the date with Osirix, I can see this field: "TransferSyntaxUID 0002,0010, 1.2.840.10008.1.2.1" 

Any suggestions?

Regards,






Darcy Mason

unread,
Apr 11, 2014, 5:49:28 PM4/11/14
to pyd...@googlegroups.com
Hi,
Pydicom keeps the "file meta" dataset separate from the main dataset.
The transfer syntax UID is available (using your variable names)at dcmmeta.file_meta.TransferSyntaxUID

-Darcy

elena....@medimsight.com

unread,
Apr 14, 2014, 10:01:00 AM4/14/14
to pyd...@googlegroups.com
Hi Darcy,

I can't read the file_meta because dcmmeta = dicom.read_file("XXXX.dcm") fails with the following error:  AttributeError: Dataset does not have attribute 'TransferSyntaxUID'.

How could I solve this error?

Elena

Jonathan Suever

unread,
Apr 14, 2014, 10:17:04 AM4/14/14
to pyd...@googlegroups.com
Hello Elena, 

Is there any chance you can upload an anonymized version of the image (you should be able to anonymize with Osirix). Also be sure to double check that pydicom still can't read the file after it is anonymized.

-Jonathan


--
You received this message because you are subscribed to the Google Groups "pydicom" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydicom+u...@googlegroups.com.
To post to this group, send email to pyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/pydicom.
For more options, visit https://groups.google.com/d/optout.

elena....@medimsight.com

unread,
Apr 14, 2014, 10:59:34 AM4/14/14
to pyd...@googlegroups.com
Hello Jonathan,

I have imported the original data to Osirix and then I have exported them. Now, pydicom can read the file. 

Thanks for your help.

Elena

Jonathan Suever

unread,
Apr 14, 2014, 11:00:41 AM4/14/14
to pyd...@googlegroups.com
What is the source of these images? My guess would be that they do not explicitly state a transfer syntax but Osirix assumes a default value. Curious how/if we should handle this with pydicom.

-Jonathan

Darcy Mason

unread,
Apr 14, 2014, 9:16:34 PM4/14/14
to pyd...@googlegroups.com
Ah, I see I did not read the original post carefully enough. Sorry about that Elena.

If Jonathan's guess is right, I think pydicom should not fail that way. Perhaps we can add an extra check, or catch this exception and proceed with the default transfer syntax.

Darcy

To unsubscribe from this group and stop receiving emails from it, send an email to pydicom+unsubscribe@googlegroups.com.

Javier González González-Zabaleta

unread,
May 5, 2016, 10:46:00 AM5/5/16
to pydicom
Hello,

Same problem. The images were self-generated and exported using pixelmed. The value is not in the header but other tools read it, probably what Jonathan says about default values is right.

Any idea abut how to solve in the meantime?

Best!

Darcy Mason

unread,
May 5, 2016, 2:00:41 PM5/5/16
to pydicom

On Thursday, May 5, 2016 at 10:46:00 AM UTC-4, Javier González González-Zabaleta wrote:
Hello,

Same problem. The images were self-generated and exported using pixelmed. The value is not in the header but other tools read it, probably what Jonathan says about default values is right.

Any idea abut how to solve in the meantime?



Hi Javier,
Just a very quick reply, I don't have time at the moment to investigate properly: there's no obvious workaround that I can think of without modifying pydicom code.  However, I think a fairly simple edit should fix it (untested):
in filereader.py, read_partial(), if the line:

if preamble:
   ...

is changed to:

if preamble and 'TransferSyntaxUID' in file_meta_dataset:

Then I think that should do it.

-Darcy

Darcy Mason

unread,
May 5, 2016, 2:08:36 PM5/5/16
to pydicom
Well, I see that my previous answer won't work because file_meta_dataset doesn't exist at that point.  But If it is checked right after file_meta_dataset is assigned, then a similar thing can be accomplished;  the variable for implicit VR and little endian have already been set, so an extra if statement at the block at the beginning could be used to just do nothing.   

I'll have to actually generate some code and run it to come up with a proper answer.

-Darcy

Darcy Mason

unread,
May 8, 2016, 8:50:37 PM5/8/16
to pydicom
Checked in some code which I believe handles this problem. You could update to the latest repository code, or simply copy the few lines in that link (it should show a diff from previous code) for how to update your current version of pydicom.

Please let me know if there are any problems.
Darcy
Reply all
Reply to author
Forward
0 new messages