Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element (0029,0010) "Item length exceeds the bytes remaining in file" #223

Closed
hkroeger opened this issue Dec 18, 2023 · 5 comments
Closed

Comments

@hkroeger
Copy link

I wrote some code using VTK-Dicom to read CT scan data. I actually have two sources: one from a GE scanner and one from a Siemens scanner.

The GE data is read just fine.

When I use the same code to read the data from the Siemens scanner, I get the following errors below.

gdcmdump reads the file in question without errors and the problem seems to be related to the element labelled "(0029,0010) LO [SIEMENS CSA HEADER]".

Is there a known problem with this field? If so, is there any recommended workaround to read such data?

Thanks!

PS: I built the most recent commit b69e7ac of vtk-dicom

2023-12-18 09:48:34.057 (   0.345s) [        589FF640]     vtkDICOMParser.cxx:2457   ERR| vtkDICOMParser (0x7efb48003400): At byte offset 3272 in file "../CT-Daten_org/INST1": In Element (0029,0010), in Sequence (0000,0000) [Item 1]: Item length exceeds the bytes remaining in file.
2023-12-18 09:48:34.057 (   0.345s) [        589FF640]     vtkDICOMReader.cxx:2397   ERR| vtkDICOMReader (0x7efb489215c0): ERROR: In /home/hannes/Projekte/build-insight-Desktop_superbuild-Debug/src/addons/insight-bone/vtkdicom-prefix/src/vtkdicom/Source/vtkDICOMParser.cxx, line 2457
vtkDICOMParser (0x7efb48003400): At byte offset 3272 in file "../CT-Daten_org/INST1": In Element (0029,0010), in Sequence (0000,0000) [Item 1]: Item length exceeds the bytes remaining in file.


2023-12-18 09:48:34.057 (   0.345s) [        589FF640]     vtkDICOMParser.cxx:2457   ERR| vtkDICOMParser (0x7efb48003400): At byte offset 3404 in file "../CT-Daten_org/INST1": In Element (0000,0000): Item length exceeds the bytes remaining in file.
2023-12-18 09:48:34.057 (   0.345s) [        589FF640]     vtkDICOMReader.cxx:2397   ERR| vtkDICOMReader (0x7efb489215c0): ERROR: In /home/hannes/Projekte/build-insight-Desktop_superbuild-Debug/src/addons/insight-bone/vtkdicom-prefix/src/vtkdicom/Source/vtkDICOMParser.cxx, line 2457
vtkDICOMParser (0x7efb48003400): At byte offset 3404 in file "../CT-Daten_org/INST1": In Element (0000,0000): Item length exceeds the bytes remaining in file.
@hkroeger
Copy link
Author

Update:
I can read the DICOM files, if I convert them all using gdcmconv --remove-gl
The command line help says:
--remove-gl Remove group length (deprecated in DICOM 2008).

@dgobbi
Copy link
Owner

dgobbi commented Dec 18, 2023

Thanks for the report. There's nothing special about "(0029,0010) LO [SIEMENS CSA HEADER]", it just starts an important Siemens private group in the file. The part of the error that worries me is "in Sequence (0000,0000)", since no valid tag ever has the value (0000,0000).

Can you do a gdcmdump of the original file and send me the dump? I want to see where the group length elements and sequence elements are. Also, of course, be sure to XX out any sensitive information in the dump.

@hkroeger
Copy link
Author

hkroeger commented Dec 18, 2023

Thanks for the feedback!
No problem. Please find the first file of the series attached:
INST1.zip

@dgobbi
Copy link
Owner

dgobbi commented Dec 19, 2023

I found the problem in vtkDICOMParser.cxx and pushed a commit that should fix it (6a81888). Please try updating from the master branch and let me know if it works for you.

There was a bug with parsing files with an explicit VR transfer syntax that contained a sequence of defined length that had VR=UN. Here, the difficulty was the "ApplicationHeaderSequence". The bug caused an error to be thrown at the first element of the sequence, not because there was anything wrong with that element, but only because it was the first element in a sequence that was incorrectly parsed.

(0029,1140) UN (actually SQ) "ApplicationHeaderSequence"
  (0029,0010) LO "PrivateCreator" : [SIEMENS MEDCOM HEADER]

I'm re-attaching the DICOM file after XX-ing a few attributes and zeroing the image: INST1.zip

@hkroeger
Copy link
Author

Dear David,
thanks a lot for the prompt fix! I will try and let you know.
Regarding the scan data: it is the scan of a specimen for research. There is no real patient data in it.

@dgobbi dgobbi closed this as completed Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants