Dwipreproc - register fieldmap to dwi, other questions


Dear experts,

I would like to discuss several aspect of preprocessing of my dwi data and dwipreproc script internals:

Some of my DWI data are acquired only at one phase encoding direction. However, I also have 2 additional series of epi B=0 only data acquired at both AP and PA directions. These are with different voxel sizes that main DWI series.

I was thinking to achieve distortion correction by resampling the additional B=0 series to resolution of main DWI and use them with -rpe_pair option. I was looking to the dwipreproc code how this functionality is implemented and it seems that there is no registration of -rpe_pair series to main DWI done to correct for possible subject movement.

The user guide of eddy says in context of --field option (but I think that this also applies for this case):


“If the first volume input to topup is the same as the first volume in --imain to eddy, the fieldmap will automatically be in the reference space of eddy. When using the --field option the user is responsible for making sure the fieldmap is registered to the eddy data.”

So it seems to me that if the -rpe_pair option is used, the first volume of the first file of -rpe_pair has to be identical to the first volume of main DWI, otherwise it would not work correctly in case of subject movement.

Could you please comment on?

I also tried to do the processing by hand by fullfilling the “identical volume” condition I mentioned in previous paragraph. But this time I am not sure how to correctly use dwidenoise tool in combination with eddy. I can use dwidenoise only for main DWI data, since additional AP-PA B=0 series has to be resampled first (due to different voxel size wrt main dwi) and dwidenoise cannot be used before resampling due to low number of volumes (three for each direction). Therefore, I concatenated resampled B=0 AP and PA series (without dwidenoise) with main DWI (with dwidenoise) to one volume and processed by eddy, together with output of topup done on B=0 AP and PA series. However, I am not sure if it is not the problem for eddy to process data with varying noise level. What do you think?

In other my data, I also have DWI only at one phase encoding direction. But, this time, I have gradient echo-based fieldmap. Do you plan to incorporate also this type of distortion correction to dwipreproc script?

In https://github.com/BIDS-Apps/MRtrix3_connectome repository I noticed the -rpe_header and -topup_images options of dwipreproc script. However, I did not find any of these parameters in current dwipreproc code in mrtrix3 repository. Where they came from and what is their significance?



Dwipreproc and inter-protocol motion

Hi Antonin (and all),

This dwipreproc script is going to be the death of me :-/

  1. Need to split into two halves:

    1. Theoretically, it’s possible to estimate the inhomogeneity field based on one set of images (with certain FoV, bandwidth, voxel size, phase encoding directions, etc.), and use that estimated field to correct the inhomogeneity distortions present in a DWI series with its own set of parameters. It requires accurately specifying the EPI total readout time for each volume in addition to the phase encoding direction. However the current version of dwipreproc is designed purely as a ‘friendly’ front-end for using FSL’s topup and eddy, handling only the most frequent use cases. If the script were to support user input for specifying any arbitrary acquisition design, then its interface would be no less complicated than that of topup and eddy themselves, and it would therefore no longer serve a purpose. So right at this moment, my recommendation in this use case would be to bypass the dwipreproc script and work with topup and eddy directly. This type of use case will however hopefully be made easier with the coming updates to dwipreproc

    2. The FSL documentation in this area was quite light when I first developed the dwipreproc script (or more accurately, its ancestors). My (perhaps mistaken) impression at the time was that all topup outputs would be used by eddy; that includes not only the inhomogeneity field and motion parameters, but also the output corrected volume; therefore eddy would handle any misalignment between the DWI volumes input to eddy, and the topup-corrected image volume relative to which the inhomogeneity field is defined. If this is not the case, and eddy assumes that the inhomogeneity field is intrinsically aligned to either the first volume or the first b=0 volume in the input series (not 100% clear from that user guide excerpt), then this is absolutely something that needs to be addressed in dwipreproc.

  2. This is probably a question for the FSL forum rather than here. Given variation in noise would only be between b=0 volumes, and not between volumes within b!=0 shells, I wouldn’t expect the GP predictor to be biased, so my intuition is that it should be fine; but don’t trust me.

  3. Yes, I would like to add support for this at some point, even though I very much encourage acquisition of reversed-phase-encode images rather than field maps. Partly I want to make the BIDS apps applicable to a wider range of input data, and partly we have a number of historical cohorts that would be nice to process. The re-write of dwipreproc in the coming update will in fact simplify implementation of such, and therefore make it more likely to (eventually) happen.

  4. These options (well, -topup_images has been renamed to -se_epi) are only available in the coming updated version of dwipreproc. Their functionality, usage, and relationship to existing options, will be explained between the script help page and new documentation tutorial page (links to previews of the coming updates for anyone interested).



Dear Rob,

I very much appreciate your efforts. I have already also spent many days on this :frowning: and more and more vote for acquiring the DWI data as recommended. However, the acquisition is not always in my hands and I have to handle also some older data.

I think that definitely this is not handled in eddy.
I have communicated with Jesper Andersson from FSL group and his recommendation in situation where the reverse phase-encoding b=0 data for inhomogeneity field estimation in topup do not originate from the main DWI volume (and possibly are of different geometry) is following:

  1. Upsample the additional b0 that was acquired with a blip-direction opposite to the dwi:s to the same resolution as the dwi:s.
  2. Create a 4D file containing the first b0 from the dwi and the upsampled additional b0, in that order.
  3. Make an acqparams.txt file. Now is is very important to get the readout-times right since they are potentially different for the two volumes.
  4. Run topup as usual.
  5. Run eddy. The index.txt will be all ones. Don’t include the additional b0.

The prerequisite is that the TE (i.e. T2 contrast between DWI and additional b=0 volumes) does not differ too much.

This assure the field estimated by topup is in register with DWI input to eddy.



OK, thanks for the additional info. I’ll need to think long and hard about how best to deal with this issue in the script, since there’s a lot of different acquisition scenarios to consider.

For now, the main scenario that users should be critical of is cases where you acquire e.g. a b=0 image with A>>P, a b=0 image with P>>A, then all of the DWIs with A>>P: if there’s substantial subject motion between the first A>>P b=0 image and the start of the DWIs, the inhomogeneity correction may be wrong. For data not yet processed, if the A>>P b=0 image has the same TE / voxel grid / bandwidth as the DWIs, it may be preferable to discard this volume, extract the first b=0 volume from the DWIs using mrconvert, and use that as the first input image to the -rpe_pair option.