Dwiextract error during dwifslpreproc (dwiextract: [ERROR] No dwi volumes present)


I’m getting an unexpected error during the dwifslpreproc script. My DWI data have 3 shells (B=0,1000,2000) acquired in the AP phase-encoding direction, including one B=0 volume. I have two additional B=0 volume acquired with AP and PA phase-encoding directions (but with a shorter TR than my main DWI sequence).
When I run dwifslpreproc with option -rpe_pair and -se_epi, I get the following dwiextract error after topup has completed:

eddy correction / susceptibility distortion correction / motion compensation (requires FSL 6.0)
dwifslpreproc DWI_degibbs.mif DWI_corrected.mif -rpe_pair -pe_dir ap -readout_time 0.04438 -se_epi B0_degibbs.mif -eddy_options “–slm=linear --repol --data_is_shelled” -info

Command: mrconvert /media/user/SharedDisk/data/PTD/PTD03/DWI/DWI_degibbs.mif /media/user/SharedDisk/data/PTD/PTD03/DWI/dwifslpreproc-tmp-SCL5ON/dwi.mif -json_export /media/user/SharedDisk/data/PTD/PTD03/DWI/dwifslpreproc-tmp-SCL5ON/dwi.json
mrconvert: [ 0%] copying from “/media/use…D/PTD03/DWI/DWI_degibbs.mif” to "/media/use… mrconvert: [100%] copying from “/media/use…D/PTD03/DWI/DWI_degibbs.mif” to “/media/use…lpreproc-tmp-SCL5ON/dwi.mif”
dwifslpreproc: Loading header for image file ‘/media/user/SharedDisk/data/PTD/PTD03/DWI/B0_degibbs.mif’
Command: mrconvert /media/user/SharedDisk/data/PTD/PTD03/DWI/B0_degibbs.mif /media/user/SharedDisk/data/PTD/PTD03/DWI/dwifslpreproc-tmp-SCL5ON/se_epi.mif

dwifslpreproc: Changing to scratch directory (/media/user/SharedDisk/data/PTD/PTD03/DWI/dwifslpreproc-tmp-SCL5ON/)
dwifslpreproc: Loading header for image file ‘dwi.mif’
dwifslpreproc: Loading header for image file ‘se_epi.mif’
dwifslpreproc: Command: ‘/home/user/matlab/mrtrix3/bin/mrinfo dwi.mif -shell_indices’ (piping data to local storage)
dwifslpreproc: Result: …
dwifslpreproc: Command: ‘/home/user/matlab/mrtrix3/bin/mrinfo dwi.mif -shell_bvalues’ (piping data to local storage)
dwifslpreproc: Result: 0 1000.02 2000.04
dwifslpreproc: First b=0 volume in input DWIs is volume index 64; this will be permuted to be the first volume (index 0) when eddy is run
Command: mrinfo dwi.mif -export_grad_mrtrix grad.b
Command: mrconvert se_epi.mif topup_in.nii -strides -1,+2,+3,+4 -export_pe_table topup_datain.txt
mrconvert: [100%] copying from “se_epi.mif” to “topup_in.nii”
Command: topup --imain=topup_in.nii --datain=topup_datain.txt --out=field --fout=field_map.nii --config=/usr/local/fsl/etc/flirtsch/b02b0.cnf --verbose
dwifslpreproc: Output of topup command:

Command: mrinfo dwi.mif -export_pe_eddy applytopup_config.txt applytopup_indices.txt
Command: dwiextract dwi.mif -pe 0.0,1.0,0.0,0.0443999991 - | mrconvert - dwi_pe_1.nii -strides -1,+2,+3,+4 -json_export dwi_pe_1.json
dwiextract: [ERROR] No dwi volumes present
mrconvert: [ERROR] no filename supplied to standard input (broken pipe?)
mrconvert: [ERROR] error opening image “-”

The script is apparently trying to extract volumes acquired in the PA phase-encoding direction from the main DWI dataset, but it only contains AP volumes.
There is no warning issued before this error. The same happens if I try with the -rpe_header (and -se_epi) options (I checked that all the the PE tables are as expected in the input files).


if I add a volume with reversed phase-encoding direction ( PA ) at the end of the main DWI dataset, I still get the error, at last when using option -rpe_pair. But If I use option -rpe_header with the extra B=0 volume, then the script completes without error (and correction looks reasonable).
When using option -rpe_pair, the error occurs because the script is trying to extract a PA volume from the main DWI dataset, while at the same time manually setting all phase-encoding values to AP using option -import_pe_table, which is contradictory and results in an error:

dwifslpreproc DWI_degibbs_test.mif DWI_corrected.mif -rpe_pair -pe_dir ap -readout_time 0.04438 -se_epi B0_degibbs.mif -eddy_options “–slm=linear --repol --data_is_shelled” -info

Command: dwiextract dwi.mif -import_pe_table dwi_manual_pe_scheme.txt -pe 0.0,1.0,0.0,0.0444 - | mrconvert - dwi_pe_1.nii -strides -1,+2,+3,+4 -json_export dwi_pe_1.json
dwiextract: [ERROR] No dwi volumes present

In this case, dwi_manual_pe_scheme.txt only contains lines with AP phase-encoding direction.
This suggests that this is due to a bug in the script?

From what I can see of the script output when it completes, the extracted B=0 volumes (both AP and PA) are used to make the eddy mask. But when using the -se_epi option, shouldn’t these be extracted from the provided B=0 dataset rather than the main DWI dataset?
Alternatively, maybe dwiextract should exit without error when no volume matching the requested phase-encoded direction is found and the mask would be based only on the B=0 volumes present in the main DWI data (i.e. only in the AP direction in my case).


OS: Ubuntu 16.04
MRtrix3* version: 3.02-193-gd63cc20