rordenlab / dcm2niix

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

PhaseEncodingPolarityGE report incorrectly with GE PROGRES' REV_POL #674

Closed mr-jaemin closed 1 year ago

mr-jaemin commented 1 year ago

dcm2niix detect PhaseEncodingPolarityGE correctly either reading Rectilinear Phase Encode tag (0018, 9034) (27+ versions) or decoding the private UserDefineDataGE (0043,102A) here. Sample DICOM datasets & details are documented here. However, I found an exception. dcm2niix reports PhaseEncodingPolarityGE incorrect with the REV_POL series from GE diffusion Distortion Correction (PROGRES) feature.

GE PROGRES collects two sets of spin-echo images with opposite phase-encoding polarity. While the REV_POL (reverse polarity) images is internally collected & utilized for distortion correction, DICOM will not be generated by default. With CV rhdistcorr_ctrl +=16 change, including ABCD study, this REV_POL images will be saved as a separate series.

Despite of the correctly reported Rectilinear Phase Encode tag (0018, 9034) in the REV_POL, dcm2niix currently reports PhaseEncodingPolarityGE and PhaseEncodingDirection incorrectly including the development version (v1.0.20230127). I suspect this public tag information was overridden by the private tag (0043,102A). I would suggest that precedence should be given to Rectilinear Phase Encode tag (0018, 9034)

Sample dataset consists of 3 series from a single DTI scan with PROGRES: 05_DTI (Distortion Corrected) 510_ORIGDTI (UnCorrected Forward polarity) 511_REV_POLDTI (UnCorrected Reverse polarity)

511_REV_POL__DTI reports

(0018,9034) CS [REVERSE_LINEAR]                         #  14, 1 RectilinearPhaseEncodeReordering

But, dcm2niix reports incorrectly:

"PhaseEncodingPolarityGE": "Flipped",
"PhaseEncodingDirection": "j",

Both 510_ORIG_DTI and 05_DTI reports correctly

(0018,9034) CS [LINEAR]                                 #   6, 1 RectilinearPhaseEncodeReordering
"PhaseEncodingPolarityGE": "Flipped",
"PhaseEncodingDirection": "j",
neurolabusc commented 1 year ago

@mr-jaemin thanks. Please test latest commit to development branch and close if this resolves your issue.

mr-jaemin commented 1 year ago

@neurolabusc Thanks Chris! The commit implemented the precedence correctly. But, I realized that the original code implementation with the public tag Rectilinear Phase Encode tag(0018, 9034) was swapped:

https://github.com/rordenlab/dcm2niix/blob/865dab86761bbc73f89ea4df6a5655679af28a75/console/nii_dicom.cpp#L5613-L5622

LINEAR corresponds to PhaseEncodingPolarityGE = "Flipped" REVERSE_LINEAR corresponds to PhaseEncodingPolarityGE = "Unflipped"

as shown below:

Slide2

The code should be swapped as follows:

if (toupper(buffer[lPos]) == 'L')
    d.phaseEncodingGE = kGE_PHASE_ENCODING_POLARITY_FLIPPED;
if (toupper(buffer[lPos]) == 'R')
    d.phaseEncodingGE = kGE_PHASE_ENCODING_POLARITY_UNFLIPPED;
break;

We didn't realize this swap bug because the private tag previously overrides the public tag in a correct way until this commit.

neurolabusc commented 1 year ago

@mr-jaemin the current behavior seems consistent with both dcm2niix and dicm2nii for both GE and Siemens. For example, see this Siemens data dcm_qa_xa30. This usage has a long history, the main issue is to ensure that two scans with opposite polarity are given opposite signs.

Series 10 "SeriesDescription": "DWI_dir80_PA", "PhaseEncodingDirection": "j",

10PA

Series 17 "SeriesDescription": "DWI_dir80_AP", "PhaseEncodingDirection": "j-",

17AP
mr-jaemin commented 1 year ago

Please let me find the GE in-vivo datasets, demonstrating the behavior very soon.

-Prior to 27 version (like DV26), dcm2niix would be still accurate -But, 27+ version dataset with the public tag, after the above commit, the behavior has changed now (wrong).

mr-jaemin commented 1 year ago

Here are the visual demonstration using DV26 and RX29 datasets with two dcm2niix versions (v1.0.20230201 and v1.0.20220915):

dMRI_PA: "SoftwareVersions": "29\LX\RX29.1_R01_2111.a", with the public tag (0018,9034) CS [LINEAR] "ConversionSoftwareVersion": "v1.0.20230201", "PhaseEncodingDirection": "j-" (wrong) "ConversionSoftwareVersion": "v1.0.20220915", "PhaseEncodingDirection": "j", (correct)

Screen Shot 2023-02-02 at 12 55 00 PM

dMRI_AP: "SoftwareVersions": "29\LX\RX29.1_R01_2111.a", with the public tag (0018,9034) CS [REVERSE_LINEAR] "ConversionSoftwareVersion": "v1.0.20230201", "PhaseEncodingDirection": "j" (wrong) "ConversionSoftwareVersion": "v1.0.20220915", "PhaseEncodingDirection": "j-", (correct)

Screen Shot 2023-02-02 at 12 55 07 PM

dMRI_PA "SoftwareVersions": "27\LX\MR Software release:DV26.0_R06_2132.a", without the public tag "ConversionSoftwareVersion": "v1.0.20230201", "PhaseEncodingDirection": "j" (correct) "ConversionSoftwareVersion": "v1.0.20220915", "PhaseEncodingDirection": "j", (correct)

Screen Shot 2023-02-02 at 1 17 36 PM

dMRI_AP "SoftwareVersions": "27\LX\MR Software release:DV26.0_R06_2132.a", without the public tag "ConversionSoftwareVersion": "v1.0.20230201", "PhaseEncodingDirection": "j-" (correct) "ConversionSoftwareVersion": "v1.0.20220915", "PhaseEncodingDirection": "j-", (correct)

Screen Shot 2023-02-02 at 1 17 43 PM

mr-jaemin commented 1 year ago

@mr-jaemin the current behavior seems consistent with both dcm2niix and dicm2nii for both GE and Siemens.

@neurolabusc Could you please confirm that your GE dataset was with version 26 or older? In other word, the Rectilinear Phase Encode tag (0018, 9034) doesn't exist. If so, this makes sense.

mharms commented 1 year ago

@mr-jaemin : I find it interesting that your first set of images for "dMRI_PA" show a region of pronounced frontal compression in the sagittal view. That's not what I'd expect for a "PA" polarity scan.

Also, I'm curious if you know if Linear and Reverse_Linear in (0018,9034) are actually defined by the DICOM standard? i.e., as a practical matter, can one vendor's coordinate system be such that Linear for them is Reverse_Linear for another?

mr-jaemin commented 1 year ago

@mharms Agreed that images look different. A pair of images with opposite phase encoding polarity (AP/PA or pepolar=0,1 for GE) were collected on the same subject within a single exam. For this thread, let's keep it simple.

Regarding the (0018, 9034), that's a good question. I can find this:

Rectilinear phase encode reordering. Defined Terms: LINEAR CENTRIC SEGMENTED REVERSE_LINEAR REVERSE_CENTRIC

I can't comment on the DICOM standard or other vendors. However, for GE systems, this tag is well-defined with the CV pepolar in diffusion EPI only since 27 version or later such that: peopolar = 0 --> LINEAR peopolar = 1 --> REVERSE_LINEAR as summarized in the above slide.

mr-jaemin commented 1 year ago

Also, in dcm2niix, the tag is currently utilized for GE only as shown in the above code.

mr-jaemin commented 1 year ago

I wanted to add additional images (clinical DWI images, not DTI) with typical PA/AP distortion:

40005_ORIG_Ax_DWI_fwd_hi_res (PA) (0018,9034) CS [LINEAR] Screen Shot 2023-02-02 at 4 21 18 PM

40006_ORIG_Ax_DWI_rev_hi_res (AP) (0018,9034) CS [REVERSE_LINEAR] Screen Shot 2023-02-02 at 4 21 26 PM

mr-jaemin commented 1 year ago

The latest commit/merge resolved the fix. I have confirmed the following GE phase encoding polarity testing datasets:

"ConversionSoftwareVersion": "v1.0.20230201"