dicom-rs icon indicating copy to clipboard operation
dicom-rs copied to clipboard

UnexpectedTag tag: Tag(0x0002, 0x0002) on missing File Meta Group Length

Open ademyanchuk opened this issue 4 years ago • 5 comments

Hi, thanks for your work. I have above-mentioned issue while trying to open dummy dicom file (created for test purposes with pydicom). Script to create is exactly as in docs. I checked it was already discussed in issue #28 and sorted out in pr #29. I am still quite new to rust. Can you please shed some light on how I can figure out the problem?

ademyanchuk avatar Oct 15 '21 10:10 ademyanchuk

Hello @ademyanchuk, thank you for reporting!

In this particular case, the error was raised because the generated file's meta information header does not contain a Group Length (0002,0000) element. The current implementation expects one to appear before any other DICOM element in the file.

Changing the Python script to add the group length would make the file readable through the latest version of DICOM-rs. One quick way to do this is to save the file with the write_like_original parameter set to False.

ds.save_as(filename_little_endian, write_like_original=False)

To the best of my knowledge, a fully compliant DICOM file should always provide the meta information group length here. Still, it would certainly be nice for DICOM-rs to be able to handle reading files without one, especially since other DICOM tools may also have such a safeguard.

Enet4 avatar Oct 15 '21 11:10 Enet4

Thanks a lot :) Have a great day @Enet4

ademyanchuk avatar Oct 15 '21 11:10 ademyanchuk

Glad that this got you unstuck! I will keep this issue to track the possibility of making file reading resilient to files without a file meta information group length. External contributions are welcome as well.

Enet4 avatar Oct 15 '21 11:10 Enet4

I would love to contribute. I am just started to learn rust and feeling like my skills wouldn't be enough for now!

ademyanchuk avatar Oct 15 '21 11:10 ademyanchuk

Though, i will try and take a l deeper look into library coffee, if i can figure out the way to handle this.

ademyanchuk avatar Oct 15 '21 11:10 ademyanchuk