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
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