rordenlab / dcm2niix

dcm2nii DICOM to NIfTI converter: compiled versions available from NITRC
https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage
Other
870 stars 229 forks source link

Converting DICOMs with odd element length #713

Closed adriamm98 closed 1 year ago

adriamm98 commented 1 year ago

We have been running your command with no problems for a while and it has been really useful, so first of all thanks for your work. Nevertheless, lately we have been encountering an issue when trying to convert some specific files; the error message is the following: Illegal DICOM tag ac4d,82fd (odd element length 9577) From what we've found so far it seems to be an issue when trying to handle DICOMs where the data is compressed, leading to odd lengths. The data is not corrupted tho, for 3D Slicer is able to read it and python is aswell as long as some extra libraries are installed. Going through the documentation of your command we have not found any flag that could solve the issue, is there any? And if not, is that something you may include in future versions? Thanks in advance

adriamm98 commented 1 year ago

In case that's useful, the file we are trying to process has the following syntax: 1.2.840.113704

neurolabusc commented 1 year ago

1.2.840.113704 is not a valid transfer syntax . By definition, DICOM objects must have an even length, so either your file is corrupted or dcm2niix is confused with a previous tag. I can not provide much more insight unless you share a smaple with my institutional email. You might find that running dcm2niix in its most verbose mode (dcm2niix -v 2 /path/to/DICOMs) provides clues on its ability to decode your data.

neurolabusc commented 1 year ago

@adriamm98 these are very unusual images, as they are both compressed and include image icons. The DICOM standard requires icons to use the same transfer syntax as the main image, but this rule was violated by the popular GEIIS system. dcm2niix includes a lot of kludges to handle both GEIIS corrupted images and the consequences of other tools to handle these. While I suspect your images are legal, handling legal images would impact conversion of several popular public repositories. In general, I would suggest icons should never be embedded into DICOMs, as they create larger files that are slower to transmit.

An alternative is to use gdcmconv to convert your images to raw images, e.g. gdcmconv -w in.dcm out.dcm - this retains your icon, but both the icon and image data are correctly uncompressed. If you do this, dcm2niix will handle your images.

neurolabusc commented 1 year ago

The latest commit to the development branch (v1.0.20230609) should handle your files, which include a compressed icon along with compressed image data. I do think your images are valid DICOMs. However, dcm2niix has several kludges to handle invalid images with GEIIS icons as well as GEIIS files that have been mangled. I hope my solution handles valid as well as invalid cases without unintended consequences.

You can get compiled artifacts or compile this yourself:

git clone --branch development https://github.com/rordenlab/dcm2niix.git
cd dcm2niix/console
make
./dcm2niix ....

@captainnova it might be worth ensuring this commit still works with Anomalous ADNI Datasets.

adriamm98 commented 1 year ago

Dear Chris, Thank you a lot! You're amazing. I'll try to apply this and let you know if there are any problems. Best,

Adrià

Missatge de Chris Rorden @.***> del dia ds., 10 de juny 2023 a les 22:23:

The latest commit to the development branch (v1.0.20230609) should handle your files, which include a compressed icon along with compressed image data. I do think your images are valid DICOMs. However, dcm2niix has several kludges to handle invalid images with GEIIS icons as well as GEIIS files that have been mangled. I hope my solution handles valid as well as invalid cases without unintended consequences.

You can get compiled artifacts https://ci.appveyor.com/project/neurolabusc/dcm2niix or compile this yourself:

git clone --branch development https://github.com/rordenlab/dcm2niix.git cd dcm2niix/console make ./dcm2niix ....

@captainnova https://github.com/captainnova it might be worth ensuring this commit still works with Anomalous ADNI Datasets https://github.com/rordenlab/dcm2niix/issues/416.

— Reply to this email directly, view it on GitHub https://github.com/rordenlab/dcm2niix/issues/713#issuecomment-1585805121, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR4YIWOGMCPSVAAIBYPDX63XKTJVPANCNFSM6AAAAAAYVJM624 . You are receiving this because you were mentioned.Message ID: @.***>

captainnova commented 1 year ago

@captainnova it might be worth ensuring this commit still works with Anomalous ADNI Datasets.

@neurolabusc, the latest development commit works with 019_S_4293 20180615 901 (fMRI, with -m y) and 941_S_4036 20181120 (T1w, from #514)

However, the other examples listed in #416, 006_S_6441 - 2019-08-19 006_S_6277 - 2018-03-28 006_S_6243 - 2019-04-01 (fMRIs only for each) are no longer straightforward to test, since their fMRIs were so anomalous that they have been purged. If I stashed a copy, I've forgotten where it is. I could try asking for a quarantined copy from LONI, but since they are not expected to work with anything it does not seem worthwhile.