Open GoogleCodeExporter opened 8 years ago
I tried it on a few of the standard pydicom test files without getting an
error. So, if you can provide a file, that would certainly help.
Original comment by darcymason@gmail.com
on 16 Feb 2011 at 3:23
Thanks for trying. So it is a file-specific thing.
I attach a sample file with which I observe the problem.
It should be a fairly standard GE MRI file.
Original comment by DaniN...@gmail.com
on 16 Feb 2011 at 10:16
Attachments:
I got this error too:
d_ds = copy.deepcopy( ds)
File "/usr/lib64/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib64/python2.6/copy.py", line 335, in _reconstruct
y[key] = value
File "/usr/local/lib/python2.6/site-packages/pydicom-0.9.5-py2.6.egg/dicom/dataset.py", line 497, in __setitem__
data_element.private_creator = self[private_creator_tag].value
AttributeError: 'RawDataElement' object has no attribute 'private_creator'
I have Siemens DICOM files with MR spectroscopy data (and a lot of private
tags).
My system: openSUSE 11.3, 64bit, Python 2.6.5, dicom.__version__ '0.9.5'
It would be fine, if there is a solution for this error.
Best regards,
Rupert Kolb
Original comment by rupert.k...@uni-tuebingen.de
on 25 Oct 2011 at 4:24
It may take a while, but I am looking at converting RawDataElements immediately
after reading, which should solve this and a few other issues.
Original comment by darcymason@gmail.com
on 27 Oct 2011 at 12:30
I came across a similar issue doing the following:
import dicom
ds = dicom.ReadFile('image.dcm')
# Retrieves a private group
sub_dataset = ds.group_dataset(25)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dicom/dataset.py", line 284, in group_dataset
[(tag,data_element) for tag,data_element in self.items() if tag.group==group]
File "dicom/dataset.py", line 546, in update
self[Tag(key)] = value
File "dicom/dataset.py", line 522, in __setitem__
data_element.private_creator = self[private_creator_tag].value
AttributeError: 'RawDataElement' object has no attribute 'private_creator'
The error is due to the fact that group_dataset() and copy.deepcopy() both
require the creation of a new dataset and then they copy over the data. For
private fields, many times the data is a RawDataElement and therefore when you
attempt copy it it fails due to the fact that the __setitem__ method of
data_element assumes that the input is a DataElement (has the private_creator
function).
A temporary fix can be achieved by simply checking to see if it is a
RawDataElement rather than a DataElement and if so, convert it using
dicom.dataelem.DataElement_from_raw
I have attached a diff file (referencing 0.9.6 - Nov. 11, 2011) as well as the
replacement dataset.py file
Using this fix, I was able to avoid both the crash stated above as well as my
own.
Original comment by Suever@gmail.com
on 9 Dec 2011 at 9:54
Attachments:
Suever, thanks for this. I've been holding off waiting on the bigger fix I
mentioned, but I think it is time just to make it work for now. Your change
does that nicely. Will push to the repository.
And since you mentioned the copy/deepcopy issue, I have some code in draft for
that. In that case, I think the raw elements should be copied as is, to be true
to python's usual behaviour for copy/deepcopy. Your change is compatible, as my
copy code avoids calling __setitem__.
Original comment by darcymason@gmail.com
on 10 Dec 2011 at 1:01
Pushed Suever's fix to repository (revision 3dd6a7142207), but keeping the
issue open to look into overall better handling of raw data elements (either
immediate conversion after reading file, or copying them as is without invoking
conversion to regular DataElement).
Original comment by darcymason@gmail.com
on 10 Dec 2011 at 1:24
Original issue reported on code.google.com by
DaniN...@gmail.com
on 15 Feb 2011 at 8:42