In the method _write_file_meta_info, there is a "b" prefix for 'OB' in line 259, which is perhaps wrong and should just be a str:
if Tag((2, 1)) not in meta_dataset:
meta_dataset.add_new((2, 1), b'OB', b"\0\1") # file meta information version
This will later fail in write_data_element when
if in_py3:
fp.write(bytes(VR, default_encoding))
... tries to convert VR to bytes but it has to be a string. Therefore my assumption is that b'OB' should not be prefixed. I am pretty sure you can decide if I am right or not without me making a minimal program that shows this error. But if you want me to, just give me a shout.
Version info:
Python 3.4 on OS X on latest hg tip (changeset: 326:98b641dc8823)
Here is the code that I use to create the file_meta for the dicom file from scratch.
file_meta = dicom.dataset.Dataset()
file_meta.SourceApplicationEntityTitle = __file__
file_meta.ImplementationVersionName = "0.1.2"
# Secondary image storge
file_meta.MediaStorageSOPClassUID = "1.2.840.10008.5.1.4.1.1.7"
# Todo: Fixme: The next two would require to get an official ID that
# can be used to derive an own UID for this software.
file_meta.MediaStorageSOPInstanceUID = \
"1.2.826.0.1.3680043.8.498.13215509892738242775390658"
# # UID for this specific version of the software
file_meta.ImplementationClassUID = \
"1.2.826.0.1.3680043.8.498.132155098927382427736600651"
and here is where I create the DS and set some values...
From samueljo...@gmail.com on April 12, 2014 13:52:26
In the method
_write_file_meta_info
, there is a "b" prefix for 'OB' in line 259, which is perhaps wrong and should just be a str:This will later fail in
write_data_element
when... tries to convert
VR
to bytes but it has to be a string. Therefore my assumption is thatb'OB'
should not be prefixed. I am pretty sure you can decide if I am right or not without me making a minimal program that shows this error. But if you want me to, just give me a shout.Version info: Python 3.4 on OS X on latest hg tip (changeset: 326:98b641dc8823)
Here is the code that I use to create the
file_meta
for the dicom file from scratch.and here is where I create the DS and set some values...
and finally write the file
I am sure, I could remove some stuff that is duplicate (for example the preamble), but I think this is somewhat unrelated.
Thanks for pydicom.
Original issue: http://code.google.com/p/pydicom/issues/detail?id=141