Dcm2niix does not extract the tag 'PhaseEncodingDirection' for fieldmaps

Hi everyone,

Summary of what happened:

I am trying to convert DICOM data for generating fieldmaps to BIDS using dcm2niix. We acquired two Spin Echo EPI scans with opposite phase encoding direction.
When I run dcm2niix everything runs smoothly except that in the accompanying json file the tag PhaseEncodingDirection is missing. The data is collected with the Siemens scanner Prisma.

Command used:

command in the terminal (raised via matlabs function system())
dcm2niix -f “%f_%p” -p n -z n -ba n -o “DestinationFolderNifti” “SourceFolderDICOM”’

Version:

dxm2niix: v1.0.20220720
Ubuntu 20.04.5 LTS

Further information:

Thanks to this forum I could run the following code snippets to find out more about the phaseEncodingDirection:
First (@effigies in Problem with new version of fmriprep (See update below): error while running processing of fieldmaps):


import nibabel as nb
from glob import glob


for fname in glob("**/*.nii", recursive=True):
	img = nb.load(fname)
	axcodes = ''.join(nb.aff2axcodes(img.affine))
	print(axcodes)
	freq, phase, slc = img.header.get_dim_info()
	print(f"{fname:70s}\tOrientation:{axcodes}\t\tPE-Axis:{axcodes[phase] if phase is not None else None}")

For both of the fieldmaps I get the output:
Orientation:PSL PE-Axis:P

Second (@dewarren in Determining BIDS PhaseEncodingDirection from DICOM):

import pydicom
import nibabel.nicom.csareader as csareader

rowcol_to_niftidim = {'COL': 'i', 'ROW': 'j'}
pedp_to_sign = {0: '-', 1: ''} 

def get_bids_phase_encoding_direction(dicom_path):
    """Return BIDS PhaseEncodingDirection string (i, j, k, i-, j-, k-) for DICOM at dicom_path.

    NOTE: work-in-progress
    """ 
    dcm = pydicom.read_file(dicom_path)
    inplane_pe_dir = dcm[int('00181312', 16)].value
    csa_str = dcm[int('00291010', 16)].value
    csa_tr = csareader.read(csa_str)
    pedp = csa_tr['tags']['PhaseEncodingDirectionPositive']['items'][0]
    ij = rowcol_to_niftidim[inplane_pe_dir]
    sign = pedp_to_sign[pedp]
    return '{}{}'.format(ij, sign)

Out = get_bids_phase_encoding_direction('/misc/data_nas04/VMatten/01_NameOfExperiment/RawData/DICOM/sub-AVR031/ses-01/WISNEFO20230131A_AVR031/AVR_20230131_202048_245000/FMAP_ACQ-DISTORT_DIR-PA_E00_M_0004/WISNEFO20230131A.MR.AVR.0004.0005.2023.01.31.22.03.10.952791.150813856.IMA')
print(Out)

Here I receive ‘j’ for both. As far as I understand dcm2niix ROW does not always relate to ‘j’ (see also PhaseEncodingDirection in .json file - #2 by Chris_Rorden).
Since my images are recorded sagittaly, I guess it should be ‘i’. However, this script outputs also the sign of the encoding. For both images I receive positive encoding, although we reversed the phase encoding direction for one of the images.

2 Questions:

  1. Why is dcm2niix not creating the tag PhaseEncodingDirection? (If requested I can share the DICOM data as well as the output of dcm2niix.)
  2. How can I retrieve the json tag PhaseEncodingDirection correctly? Or is the PhaseEncodingDirection indeed identical for both fieldmaps (although we did check the settings in the scanner as far as we could)?
    Thank you!

Best,
Gwen

I have sent you a personal message. Is your Prisma running VE11 or XA30, and if the latter are you exporting data as enhanced or in interoperability mode? The XA30 is new and has been quickly evolving, you can always try the development version of dcm2niix by visiting AppVeyer, selecting your operating system, and downloading the artifacts.