pydicom : Dataset does not have attribute 'TransferSyntaxUID'

2.2k views Asked by At

Hi I'm suffering from reading DICOM files with pydicom

This post is different from pydicom 'Dataset' object has no attribute 'TransferSyntaxUID'

Here's my code

import dicom
dicom.read_file(file,force=True)

this causes an error

        AttributeError                            Traceback (most recent call last)
    <ipython-input-32-a32aef2d2178> in <module>()
    ----> 1 dicom.read_file(raw_path + pat_lst[0] + '\\' + pat_dcm_lst[0],force=True)

    D:\Program Files\Anaconda2\lib\site-packages\dicom\filereader.pyc in read_file(fp, defer_size, stop_before_pixels, force)
        612     try:
        613         dataset = read_partial(fp, stop_when, defer_size=defer_size,
    --> 614                                force=force)
        615     finally:
        616         if not caller_owns_file:

    D:\Program Files\Anaconda2\lib\site-packages\dicom\filereader.pyc in read_partial(fileobj, stop_when, defer_size, force)
        520     if preamble:
        521         file_meta_dataset = _read_file_meta_info(fileobj)
    --> 522         transfer_syntax = file_meta_dataset.TransferSyntaxUID
        523         if transfer_syntax == dicom.UID.ImplicitVRLittleEndian:
        524             pass

    D:\Program Files\Anaconda2\lib\site-packages\dicom\dataset.pyc in __getattr__(self, name)
        254         if tag not in self:
        255             raise AttributeError("Dataset does not have attribute "
    --> 256                                  "'{0:s}'.".format(name))
        257         else:  # do have that dicom data_element
        258             return self[tag].value

    AttributeError: Dataset does not have attribute 'TransferSyntaxUID'.

I think something goes wrong when anonymizing. I wanna know why this occurs.

Is deleting TransferSyntaxUID related with DICOM standard?

And, I can read through MATLAB, VTK, ITK but pydicom

So now what I'm trying to do is set TransferSyntaxUID manually via SimpleITK and read again via pydicom.

I'll let you know when this works

Thanks in advance

2

There are 2 answers

0
darcymason On

The pydicom repository has an update which is tolerant of a missing transfer syntax. As a workaround until the next release, you could modify a couple of lines in filereader.py as shown here

2
zivy On

From my understanding of the DICOM standard it appears that Transfer Syntax UID (0002,0010) is a mandatory tag. It is a type 1 tag which indicates it is required.

While this is what the standard says, libraries are likely able to read such files even with this tag missing. I am guessing this is because the standard also defines a default transfer syntax.

With regard to setting values with SimpleITK, that should definitely work. Also, if you need to verify that your files comply with the standard you can use David Clunie's dicom3tools, specifically dciodvfy and dcdump.