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

Segmentation fault with odd element length #775

Closed
xf4j opened this issue Jan 9, 2024 · 3 comments
Closed

Segmentation fault with odd element length #775

xf4j opened this issue Jan 9, 2024 · 3 comments

Comments

@xf4j
Copy link

xf4j commented Jan 9, 2024

When running "dcm2niix ~/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261", it shows an error with the following log. I tried with different dcm2niix arguments but the error was the same.

Compression will be faster with 'pigz' installed http://macappstore.org/pigz/
Chris Rorden's dcm2niiX version v1.0.20231111 (JP2:OpenJPEG) (JP-LS:CharLS) Clang15.0.0 x86-64 (64-bit MacOS)
Found 276 DICOM file(s)
Illegal DICOM tag 0069,005b (odd element length -4587521): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477593.597542.dcm
Illegal DICOM tag ffda,ffca (odd element length -3080285): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477601.475800.dcm
Illegal DICOM tag fff0,ffdd (odd element length 2359355): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477595.186512.dcm
Assuming final tag is Pixel Data (7fe0,0010) (issue 639)
Assuming final tag is Pixel Data (7fe0,0010) (issue 639)
Assuming final tag is Pixel Data (7fe0,0010) (issue 639)
Illegal DICOM tag fc89,fc6b (odd element length -63964073): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477581.401854.dcm
Assuming final tag is Pixel Data (7fe0,0010) (issue 639)
Illegal DICOM tag ffa8,ffba (odd element length -14090429): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477601.475791.dcm
Illegal DICOM tag fc44,fc36 (odd element length -62718873): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477577.894328.dcm
Illegal DICOM tag 001c,ffdd (odd element length -4718723): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477595.186507.dcm
Illegal DICOM tag fc6b,fc9b (odd element length -59114383): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477586.747558.dcm
Illegal DICOM tag 0042,004d (odd element length -3407915): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477593.597541.dcm
Illegal DICOM tag ffdd,0013 (odd element length 393195): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477595.186505.dcm
Illegal DICOM tag ff81,ff76 (odd element length -1245247): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477601.867695.dcm
Illegal DICOM tag ff93,ff5f (odd element length -4849723): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477601.837115.dcm
Illegal DICOM tag ffa6,ffa8 (odd element length -12058721): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477601.475793.dcm
Illegal DICOM tag ffcb,ffaa (odd element length -32178367): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477588.248646.dcm
Illegal DICOM tag fc5d,fc85 (odd element length -59114383): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477581.401842.dcm
Illegal DICOM tag 0052,0040 (odd element length 8912967): /Users/xuefeng/Downloads/1.2.392.200036.9116.2.6.1.37.2430222242.1668477554.629261/1.2.392.200036.9116.2.6.1.37.2430222242.1668477576.168972.dcm
Assuming final tag is Pixel Data (7fe0,0010) (issue 639)
Segmentation fault: 11

Version:
Chris Rorden's dcm2niiX version v1.0.20231111 (JP2:OpenJPEG) (JP-LS:CharLS) Clang15.0.0 x86-64 (64-bit MacOS)
v1.0.20231111

Error happens on both MacOS and Linux (Ubuntu 20.04), same dcm2niix version.

This DICOM series can be downloaded from https://drive.google.com/file/d/10D85yRRp18_QIdf93l3n3kaC0mNUggQ1/view?usp=sharing

Thank you very much!

@neurolabusc
Copy link
Collaborator

neurolabusc commented Jan 9, 2024

This is a limitation with your DICOM images, not with dcm2niix. You can verify this by using another tool like dcmdump:

dcmdump 1.2.392.200036.9116.2.6.1.37.2430222242.1668477601.867704.dcm > 704.txt  
W: Found element (0029,e131) with VR UN and undefined length, reading a sequence with transfer syntax LittleEndianImplicit (CP-246)

The issue is that an anonymization tool was not aware that the private tag 2005,140f is a Philips Private SQ. Perhaps the input image was saved as implicit VRs which can obscure this fact for tools that do not contain a complete DICOM dictionary.

I can think of two solutions:

  1. Check the provenance of the DICOM images, and convert the original images prior to the data corruption. I would strongly prefer this option, as this will have access to additional tags that have been anonymized.
  2. Clone the dcm2niix repository and change one line of code, and recompile dcm2niix. This will now convert your corrupted images, but it may feel with original Philips data and the corrupted files may be missing other details.

If you want to pursue option 2, you would change:

uint32_t array[array_size] = {0x2005 + (uint32_t(0x140F) << 16), 0x0008 + (uint32_t(0x1111) << 16), 0x0008 + (uint32_t(0x1115) << 16), 0x0008 + (uint32_t(0x1140) << 16), 0x0008 + (uint32_t(0x1199) << 16), 0x0008 + (uint32_t(0x2218) << 16), 0x0008 + (uint32_t(0x9092) << 16), 0x0018 + (uint32_t(0x9006) << 16), 0x0018 + (uint32_t(0x9042) << 16), 0x0018 + (uint32_t(0x9045) << 16), 0x0018 + (uint32_t(0x9049) << 16), 0x0018 + (uint32_t(0x9112) << 16), 0x0018 + (uint32_t(0x9114) << 16), 0x0018 + (uint32_t(0x9115) << 16), 0x0018 + (uint32_t(0x9117) << 16), 0x0018 + (uint32_t(0x9119) << 16), 0x0018 + (uint32_t(0x9125) << 16), 0x0018 + (uint32_t(0x9152) << 16), 0x0018 + (uint32_t(0x9176) << 16), 0x0018 + (uint32_t(0x9226) << 16), 0x0018 + (uint32_t(0x9239) << 16), 0x0020 + (uint32_t(0x9071) << 16), 0x0020 + (uint32_t(0x9111) << 16), 0x0020 + (uint32_t(0x9113) << 16), 0x0020 + (uint32_t(0x9116) << 16), 0x0020 + (uint32_t(0x9221) << 16), 0x0020 + (uint32_t(0x9222) << 16), 0x0028 + (uint32_t(0x9110) << 16), 0x0028 + (uint32_t(0x9132) << 16), 0x0028 + (uint32_t(0x9145) << 16), 0x0040 + (uint32_t(0x0260) << 16), 0x0040 + (uint32_t(0x0555) << 16), 0x0040 + (uint32_t(0xa170) << 16), 0x5200 + (uint32_t(0x9229) << 16), 0x5200 + (uint32_t(0x9230) << 16)};

to read:

uint32_t array[array_size] = {0x0008 + (uint32_t(0x1111) << 16), 0x0008 + (uint32_t(0x1115) << 16), 0x0008 + (uint32_t(0x1140) << 16), 0x0008 + (uint32_t(0x1199) << 16), 0x0008 + (uint32_t(0x2218) << 16), 0x0008 + (uint32_t(0x9092) << 16), 0x0018 + (uint32_t(0x9006) << 16), 0x0018 + (uint32_t(0x9042) << 16), 0x0018 + (uint32_t(0x9045) << 16), 0x0018 + (uint32_t(0x9049) << 16), 0x0018 + (uint32_t(0x9112) << 16), 0x0018 + (uint32_t(0x9114) << 16), 0x0018 + (uint32_t(0x9115) << 16), 0x0018 + (uint32_t(0x9117) << 16), 0x0018 + (uint32_t(0x9119) << 16), 0x0018 + (uint32_t(0x9125) << 16), 0x0018 + (uint32_t(0x9152) << 16), 0x0018 + (uint32_t(0x9176) << 16), 0x0018 + (uint32_t(0x9226) << 16), 0x0018 + (uint32_t(0x9239) << 16), 0x0020 + (uint32_t(0x9071) << 16), 0x0020 + (uint32_t(0x9111) << 16), 0x0020 + (uint32_t(0x9113) << 16), 0x0020 + (uint32_t(0x9116) << 16), 0x0020 + (uint32_t(0x9221) << 16), 0x0020 + (uint32_t(0x9222) << 16), 0x0028 + (uint32_t(0x9110) << 16), 0x0028 + (uint32_t(0x9132) << 16), 0x0028 + (uint32_t(0x9145) << 16), 0x0040 + (uint32_t(0x0260) << 16), 0x0040 + (uint32_t(0x0555) << 16), 0x0040 + (uint32_t(0xa170) << 16), 0x5200 + (uint32_t(0x9229) << 16), 0x5200 + (uint32_t(0x9230) << 16)};

neurolabusc added a commit that referenced this issue Jan 9, 2024
@neurolabusc
Copy link
Collaborator

I have made a commit to the development branch so it will convert your images. This is based on the fact that your data is from Canon (nee Toshiba) rather than Philips. It does seem like the data includes a lot of stripped and retired tags, so I do still encourage you to ensure conversion with a image direct from the instrument.

@xf4j
Copy link
Author

xf4j commented Jan 9, 2024

Thank you.

@xf4j xf4j closed this as completed Jan 10, 2024
yarikoptic added a commit to neurodebian/dcm2niix that referenced this issue Apr 29, 2024
* tag 'v1.0.20240202': (135 commits)
  Update submodules
  Refactor (rordenlab#791)
  gantry tilt tolerance (rordenlab#791)
  GE step description (rordenlab#790)
  PatientOrient -> Patient Position (rordenlab#786)
  Prevent shell expansion (rordenlab#789)
  Replace presumably accidental bitwise AND operations
  Update JasPer API calls for compatibility with newer versions of the library
  Update divest logic, reducing duplication and supporting new mode of operation
  Fix PhaseEncodingDirectionDisplayed for GE
  Update date
  GE Diffusion issue rordenlab#777 minor
  GE Diffusion issue rordenlab#777
  Kludge for issue 775 (rordenlab#775)
  add docstrings
  better python wrapper I/O
  issue 769: Mildly relax the check for bvec components > 1.
  PRs (rordenlab#745; rordenlab#768)
  Edge cases (rordenlab#763, rordenlab#749)
  Code spell
  ...
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