rordenlab / dcm2niix

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

Converting Siemens phase difference images changes image scaling #406

Closed jaystock closed 4 years ago

jaystock commented 4 years ago

Hello -- thank you for providing dcm2niix to the community, it is extremely fast and very useful!

I wanted to ask about an issue I'm having converting Siemens B0 field map phase difference images from DICOM to NIFTI. I am running dcm2niix with this syntax:

dcm2niix -b n -o output_folder dicom_folder

The usual scaling in Siemens phase difference images maps [-pi, pi] onto [0, 4096], which is easy to rescale into physical units. However the range I get in my converted NIFTI volumes is different. It seems to have a range like [-8192, 4096], which does not make sense to me. I'm not sure how to scale this back into meaningful units like [-pi, pi]. Usually I then scale the image into Hz by using knowledge of the delta_TE used in the acquisition.

neurolabusc commented 4 years ago

@jaystock dcm2niix will convert DICOM data losslessly. Therefore, this behavior is outside the remit of the tool. However, I would be interested in the answer. You can find a field map from the Siemens Prisma E11 at my center here. This sample follows the convention I have seen: the raw data is in the range 0..4095 (12-bit), with the scl_slope = 2.0 and scl_inter = -4096 yielding values of -4096..4094. A common trick is to assume the full range is -pi..pi. You can see this by viewing the header (using dcmdump or gdcmdump):

(0028,0103) US 0           #   2, 1 PixelRepresentation, 1 signed, 0 unsigned
(0028,0100) US 16          #   2, 1 BitsAllocated
(0028,0101) US 12          #   2, 1 BitsStored
(0028,1052) DS [-4096]     #   6, 1 RescaleIntercept
(0028,1053) DS [2]         #   2, 1 RescaleSlope

I have two ideas:

  1. Try visually inspecting the DICOM images with a DICOM viewer (for MacOS, I like Horos) - you should see the same intensity values as the NIfTI images created by dcm2niix. I would see if the values -8192 values are only observed outside the object being imaged, where phase can not be calculated (e.g. in the air surrounding your object). In other words, are the extreme values outside the brain mask? This would mimic the convention for CT DICOMs, where values outside the imaged cylinder are filled with impossible values for Hounsfield units (and SPM's tendency to put not-a-number values in voxels outside the brain).
  2. Have you contacted your Siemens Research Collaboration Manager? Their role is to help you resolve these issues. I sure the rest of the community would be interested in their response.
neurolabusc commented 4 years ago

@jaystock I am closing this issue, as it sounds like dcm2niix is faithfully converting a Siemens field map. Please do report if you work out what is happening with these images.

jaystock commented 4 years ago

Chris,

I wanted to follow up to ask your advice on this issue since I haven’t been able to figure out the scaling.

https://www.dropbox.com/sh/xz3ydq7gyq6jjqw/AACc0TWqvKXWmTSPn0fYf4oYa?dl=0

At the above link I have shared my Siemens field map magnitude image (DICOM #0002) and the phase difference image (DICOM #0003) which has the normal scaling of [-pi, pi] onto the DICOM range [0, 4096]. I’m also attaching the NIFTI that I get from dcm2niix when I process DICOM #0003. The scaling goes down to less than -20,000, which I’m at a loss to explain. I’m attaching the dialog below that dcm2niix generates when I call it.

The syntax I use to call dcm2niix is as follows:

~/mri/mgh/matlab/dcm2niix/dcm2niix -b n -o ./nifti/target_dicom_folder

I also had a random question: Is it possible to process multi-echo DICOMs and output a single NIFTI file instead of outputting NIFTIs for e1, e2, etc.? Working with a single NIFTI makes file management a lot easier for my applications.

Thank you for any feedback or advice you can lend on this! I appreciate your time and your attention to this issue.

--- Jason

=============================================== Compression will be faster with 'pigz' installed http://macappstore.org/pigz/ Chris Rorden's dcm2niiX version v1.0.20200331 (JP2:OpenJPEG) (JP-LS:CharLS) Clang8.1.0 (64-bit MacOS) Found 75 DICOM file(s) Convert 75 DICOM as ./nifti/GRE_FIELD_75SLI_BASELINE_SIEMENS_0003_gre_field_75SLI_baseline_siemens_20200713193605_3_e2_phb (128x128x75x1) Conversion required 0.051041 seconds (0.050893 for core code).

From: Chris Rorden notifications@github.com Reply-To: rordenlab/dcm2niix reply@reply.github.com Date: Friday, July 10, 2020 at 7:32 AM To: rordenlab/dcm2niix dcm2niix@noreply.github.com Cc: jaystock jaystock@nmr.mgh.harvard.edu, Mention mention@noreply.github.com Subject: Re: [rordenlab/dcm2niix] Converting Siemens phase difference images changes image scaling (#406) {Disarmed}

    External Email - Use Caution

Closed #406https://github.com/rordenlab/dcm2niix/issues/406.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rordenlab/dcm2niix/issues/406#event-3533512579, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGCOLGY7CGJLKDPQJF3HJQTR2333VANCNFSM4ORCGTDA. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/rordenlab/dcm2niix/issues/406#event-3533512579", "url": "https://github.com/rordenlab/dcm2niix/issues/406#event-3533512579", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.

neurolabusc commented 4 years ago
  1. I can not replicate your problem. When I convert your image with the command
$dcm2niix -b n -f %s -o ~/Neuro/issue406 ~/Neuro/issue406
Chris Rorden's dcm2niiX version v1.0.20200331  (JP2:OpenJPEG) (JP-LS:CharLS) Clang11.0.0 (64-bit MacOS)
Found 225 DICOM file(s)
Convert 75 DICOM as /Users/chris/Neuro/issue406/3_e2_phb (128x128x75x1)
Slices not stacked: echo varies (TE 2.69, 5.15; echo 1, 2). Use 'merge 2D slices' option to force stacking
Convert 75 DICOM as /Users/chris/Neuro/issue406/2_e1b (128x128x75x1)
Convert 75 DICOM as /Users/chris/Neuro/issue406/2_e2b (128x128x75x1)
Conversion required 0.338223 seconds (0.175867 for core code).

And view the image intensity range with Matlab I get the expected range:

fnm = '/Users/chris/Neuro/issue406/3_e2_ph.nii';
hdr = spm_vol(fnm);
img = spm_read_vols(hdr);
fprintf('min..max %g..%g\n', min(img(:)), max(img(:)));
min..max -4096..4094

This image has an unscaled range of 0..4095 (12-bit ADC), with a scl_slope = 2.0 and scl_inter = -4096.

I am not sure what happened with the NIfTI file you provided. What version of dcm2niix are you running? Your command line option looks unusual. If you explicitly include an out put folder (-o), I would still include an input folder. If you want the output saved to the input folder, omit the -o option. I doubt this explains your issue, I would either write:

 ~/mri/mgh/matlab/dcm2niix/dcm2niix -b n -o /path/to/outdir /path/to/indir

or

 ~/mri/mgh/matlab/dcm2niix/dcm2niix -b n /path/to/inoutdir

Looking at the header reveals that either a non-standard (e.g. MGH specific) version of dcm2niix was used to create your NIfTI image or some other tool has manipulated this image. The clue is that the xyzt_units report NIFTI_UNITS_MSEC, where following the BIDS specification standard dcm2niix always uses NIFTI_UNITS_SEC.

  1. dcm2niix creates NIfTI images to the BIDS standard which explicitly states Multi-echo data MUST be split into one file per echo. There are many ways a user might want their data saved, but the goal of dcm2niix is to deliver consistent behavior, so I have chosen the BIDS standard as a reference. If you want to stack your echoes into a single file you could try one of these options:
    • Force images with varying parameters to be merged with the -m y parameter. I would generally discourage this, as images may be merged across other properties.
    • Use fslmerge, 3dTcat or a Matlab script to concatenate your volumes.
    • Use dicm2nii with Matlab. This does stack echoes by default, and being Matlab based is easy to script for unique functions.
    • Make a fork of dcm2niix and tune it for your desired behavior.