Importing DX image with malformed tag causes error

Issue #1006 resolved
David Platten created an issue

The error below comes up in the task_admin page when OpenREM tries to import data from a particular Siemens radiographic room. It helpfully suggests changing the pydicom config to change the error to a warning by setting "pydicom.config.convert_wrong_length_to_UN = True".

Traceback (most recent call last): File "E:\venv311\Lib\site-packages\pydicom\dataelem.py", line 859, in DataElement_from_raw value = convert_value(vr, raw, encoding) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\values.py", line 771, in convert_value return converter(byte_string, is_little_endian, num_format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\values.py", line 389, in convert_numbers raise BytesLengthException( pydicom.errors.BytesLengthException: Expected total bytes to be an even multiple of bytes per value. Instead received b'\x00\x00' with length 2 and struct format 'f' which corresponds to bytes per value of 4. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\venv311\Lib\site-packages\pydicom\tag.py", line 28, in tag_in_exception yield File "E:\venv311\Lib\site-packages\pydicom\dataset.py", line 2389, in walk data_element = self[tag] ~~^^^^^ File "E:\venv311\Lib\site-packages\pydicom\dataset.py", line 939, in __getitem__ self[tag] = DataElement_from_raw(elem, character_set, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\dataelem.py", line 872, in DataElement_from_raw raise BytesLengthException( pydicom.errors.BytesLengthException: Expected total bytes to be an even multiple of bytes per value. Instead received b'\x00\x00' with length 2 and struct format 'f' which corresponds to bytes per value of 4. This occurred while trying to parse (0021, 100c) according to VR 'FL'. To replace this error with a warning set pydicom.config.convert_wrong_length_to_UN = True. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "e:\openrem-src\openrem\remapp\tools\background.py", line 148, in run_as_task func(*args, **kwargs) File "e:\openrem-src\openrem\remapp\extractors\dx.py", line 947, in dx except ValueError as err: ^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\dataset.py", line 551, in decode self.walk(decode_callback, recursive=False) File "E:\venv311\Lib\site-packages\pydicom\dataset.py", line 2388, in walk with tag_in_exception(tag): File "c:\Program Files\Python311\Lib\contextlib.py", line 155, in __exit__ self.gen.throw(typ, value, traceback) File "E:\venv311\Lib\site-packages\pydicom\tag.py", line 32, in tag_in_exception raise type(exc)(msg) from exc pydicom.errors.BytesLengthException: With tag (0021, 100c) got exception: Expected total bytes to be an even multiple of bytes per value. Instead received b'\x00\x00' with length 2 and struct format 'f' which corresponds to bytes per value of 4. This occurred while trying to parse (0021, 100c) according to VR 'FL'. To replace this error with a warning set pydicom.config.convert_wrong_length_to_UN = True. Traceback (most recent call last): File "E:\venv311\Lib\site-packages\pydicom\dataelem.py", line 859, in DataElement_from_raw value = convert_value(vr, raw, encoding) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\values.py", line 771, in convert_value return converter(byte_string, is_little_endian, num_format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\values.py", line 389, in convert_numbers raise BytesLengthException( pydicom.errors.BytesLengthException: Expected total bytes to be an even multiple of bytes per value. Instead received b'\x00\x00' with length 2 and struct format 'f' which corresponds to bytes per value of 4. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\venv311\Lib\site-packages\pydicom\tag.py", line 28, in tag_in_exception yield File "E:\venv311\Lib\site-packages\pydicom\dataset.py", line 2389, in walk data_element = self[tag] ~~^^^^^ File "E:\venv311\Lib\site-packages\pydicom\dataset.py", line 939, in __getitem__ self[tag] = DataElement_from_raw(elem, character_set, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\venv311\Lib\site-packages\pydicom\dataelem.py", line 872, in DataElement_from_raw raise BytesLengthException( pydicom.errors.BytesLengthException: Expected total bytes to be an even multiple of bytes per value. Instead received b'\x00\x00' with length 2 and struct format 'f' which corresponds to bytes per value of 4. This occurred while trying to parse (0021, 100c) according to VR 'FL'. To replace this error with a warning set pydicom.config.convert_wrong_length_to_UN = True.

Comments (6)

  1. David Platten reporter

    Changing the pydicom config in the radiographic extractor to throw a warning rather than an error if a tag is the wrong length. Refs issue #1006

    → <<cset 4ef284b5ef82>>

  2. David Platten reporter

    Merged in issue1006importingDXimageWithMalformedTagCausesError (pull request #591)

    Changing the pydicom config in the radiographic extractor to throw a warning rather than an error if a tag is the wrong length. Refs issue #1006

    Approved-by: Ed McDonagh

    Fixes issue #1006

    → <<cset 0e366bd6b2a2>>

  3. David Platten reporter

    Merged in issue1006importingDXimageWithMalformedTagCausesError (pull request #591)

    Changing the pydicom config in the radiographic extractor to throw a warning rather than an error if a tag is the wrong length. Refs issue #1006

    Approved-by: Ed McDonagh

    Fixes issue #1006

    → <<cset 0e366bd6b2a2>>

  4. Log in to comment