DWI phase encoding

Hello all,

I am relatively new to DWI data, but am familiar with T1/2 anatomical data using slicer, spm, and fsl. I have just converted animal (pig) DWI DICOMs into NifTI format using dcm2niix, which also produced a bval, bvec, and JSON files for me. I am wanting to preprocess this DWI data to correct for distortions where possible before I brain mask the data.

My question is this - is there a way to tell just by looking at the DWI dataset (DICOM or NifTI) if the data was acquired as a single-direction encoding dataset or multi-direction? There are 186 DICOM images per DWI dataset, and 46 images per ADC, FA, COLFA, and TRACE datasets. There is 1 image in a TENSOR folder. The images were acquired on a Siemens 3T Trio machine. In one of the animals there are two datasets, but I believe one is axial and one is sagittal slices.

My sense is that since there is no obvious paired dataset, I only have a single-direction encoding dataset. Can you tell the direction of encoding just by looking at the image on fsleyes? For me the distortion appears to be in the ap direction, so I am thinking of running dwifslpreproc input.nii output.nii -rpe_none -pe_dir ap -fslgrad bvec bval.

Any input would be much appreciated!


I’m pretty sure that’ll be a yes, but the specifics depend on exactly what you mean by ‘single-direction encoding’. You could be talking about the direction of the diffusion-encoding gradients, the phase-encoding direction, or the slice encoding direction. I’m guessing you’re talking about the phase-encoding direction…?

On a Siemens system, that should be recorded, and you should be able to see the information in the JSON file. Looking at the images, if you can’t tell much difference between the two datasets, then they’ll most likely have been acquired with the same phase-encoding direction. If the brains (and more specifically the distortions) look broadly symmetrical, then the phase-encoding direction is probably AP (or PA – for the purposes of eddy/dwifslpreproc either of these will produce the same result).

But more to the point: if you’re going to use the -rpe_none option, I’m pretty sure you don’t need to know that information – though I note the docs strongly suggest you do (@rsmith might be able to shed some light on this). I have a feeling the -pe_dir option is optional in that case.

Welcome @jxc!

Unless you’re using an exotic Siemens DWI WIP, if there’s a single DICOM folder containing DWIs, there’s a single phase encoding direction. Modification of the phase encoding direction during a single sequence execution isn’t possible with the commonly used sequences.

You should also be able to tell based on simply the number of files generated by dcm2niix. Each JSON file can only encode one phase encoding direction (currently), so if all of the DWI data are stored in a single NIfTI 4D series, then you have only one phase encoding direction.

Do however check the raw data in case there is an additional DWI or spin-echo EPI sequence where only b=0 volumes were acquired for the purpose of susceptibility field estimation. Depending on the sequence used, these may not be reported as DWIs, even if they’re intended to be utilised alongside the DWIs.

… if you’re going to use the -rpe_none option, I’m pretty sure you don’t need to know that information …

No, it’s still compulsory for dwifslpreproc even for -rpe_none. From memory the eddy current correction can be off if your phase encoding axis is wrong.

Alternatively you can do an mrconvert -json_import to convert to .mif, then run dwifslpreproc with -rpe_header, and it will figure out what to do.


Thank you for the replies @rsmith and @jdtournier,

It helped to understand that each folder contains one phase encoding direction. It also helped to understand that the bvec gradient directions is something different, because that is what was confusing me originally. I thought I had to extract different gradient direction images from the DWI stack to use this function. There was actually a second folder of 186 DICOMs phase encoded in a different direction from the first, but not in the anti-parallel direction. With a bit of trial and error I was able to deduce these directions from the JSON files and use the -rpe_header option. Thanks again for pointing me in the right direction! Next time, I will know exactly what to ask the technician to run for the image acquisition, since I think the blip up and blip down would be better for distortion correction.

Dear Mrtrix experts,

I just want to confirm that I understood this correctly (in order to implement dwifslpreproc correctly.)

In the dicom images I have "phaseEncodingDirection" : "j-" and I have a single phase encoding direction.So,

  • In dwifslpreproc I should specify -rpe_none and -pe_dir AP?
  • Does it make a difference if I specify -pe_dir as AP or PA? I understand from the response above that both will produce the same output.
  • Would it be safer to set -pe_dir j-?

Thank you in advance,

Hi Ane,

If the phase encoding direction can be identified from the originating DICOMs, then you could simply use -rpe_header, and dwifslpreproc will sort out the requisite information.

If you really want to use the manual controls, then -pe_dir AP and -pe_dir j- should be equivalent. Indeed if you use the -pe_dir option, but what you specify does not match what is already available within the image header, then dwifslpreproc should issue you with a warning.

We believe that in cases like this, the results should be unaffected by erroneously flipping the phase encoding direction, specifically because of how FSL’s eddy works. This is however not guaranteed to be the case, particularly in the future; e.g. there could be some more explicit model for the manifestation of eddy current distortions depending on the diffusion gradient orientation and the phase encoding direction, in which case this suggestion would be invalidated. If you doubt this, you could indeed simply perform the test.


Thank you for the explanation! Will take that into account in the future!