I’m seeking advice on a persistent issue with distortion correction in obliquely acquired rat DWI data using MRtrix3 and FSL. Despite extensive attempts, running dwifslpreproc consistently introduces severe spatial distortion.
Core Issue:
After dwifslpreproc, the brain becomes displaced, compressed, or warped out of the FOV
These distortions are not present in the raw DWI (post-denoising and Gibbs correction)
Post-hoc registration to T2 fails to correct it
The preprocessed DWI is less anatomically accurate than the input
Data & Acquisition
PE directions tested: AP, PA, A, P (verified via mrinfo, DICOM, and inspection)
Eddy options
–slm=linear, --slm=quadratic
–flm=quadratic, --repol, --mporder, --dont_peas, etc.
Readout times: 0.1–0.4 tested
-nocleanup enabled to inspect intermediates
Custom acqparams.txt and index.txt (double-checked)
→ Distortion persists in all cases, with brain anteriorly warped and misaligned with T2.
Troubleshooting PE Direction and Obliqueness:
Reorientation / Resampling
fslswapdim, fslorient, mrconvert -axes, mrgrid
Confirmed PE vector consistency across transformations
Manual FSL Topup/Eddy
Ran topup + eddy_openmp directly
Created b0_pair.nii.gz via mrcat, tested various acqparams/index files
→ Same distortion outcome as dwifslpreproc
Post-Correction Registration
Tried salvaging warped DWI via:
mrregister (rigid, affine, nonlinear)
flirt, fnirt
Full antsRegistration (SyN)
→ All failed due to gross deformation
Other Pipelines Tested
rodent-whole-brain-preprocessing-recipe: failed at topup
Used bruker2nifti instead of Dicomifier: no improvement
I suspect topup/eddy misinterpret the PE direction in oblique rat data, generating invalid warps. No combination of reorientation, header correction, or direct fieldmap estimation has resolved the distortion.
If anyone has any suggestions, I’d be grateful for your input on:
How to handle distortion correction in oblique rat DWI when dwifslpreproc/topup/eddy fail?
Whether reorienting to axial slices or manipulating the affine matrix may help?
If there is any rodent-specific workflows or topup/eddy configuration changes that have worked for others?
Thank you in advanced!
Charlotte
Example output from dwifslpreproc (almost all variations tried yield the same results to varying degrees):
To debug an issue like this, run dwifslpreproc with the -nocleanup option (you appear to already do this, based on the screenshots you presented). This way, the temporary directory dwifslpreproc-tmp-??????, which is where all intermediate files that are produced by dwifslpreproc are stored, is not deleted when dwifslpreproc completes.
Within that folder you will find a log.txt that lists all individual commands run by dwifslpreproc. Go over them one by one and check if the output of each command makes sense.
E.g. if the log.txt shows that topup is part of the pipeline, check whether the output of the subsequent applytopup indeed reduces EPI distortions compared to the input, by displaying both dwi_pe_0.nii and dwi_pe_0_applytopup.nii.gz using mrview (and check whether the correction happens along the PE axis).
Other things to check are the eddy_mask.nii, which is the brain mask that is used during eddy. Given that you work with rat data, there is a good chance that dwi2mask produces a bad brain mask. To check, overlay eddy_mask.nii onto dwi_pe_0_applytopup.nii.gz
Finally, if those check out, also check the output of eddy.
This way you will know exactly where things go wrong and when you report back there is also a good chance that someone will be able to point out the issue/solution.
Looking back at your screenshots above, if you complement them with dwi_pe_0_applytopup.nii.gz and eddy_mask.nii, there is a good chance that we can see where things go wrong.
Thanks so much for your responses and suggestions! I really appreciate the time you’ve taken to help me with this. I’m still relatively new to MRtrix and image processing in general (I’m a student), so your guidance has been super helpful.
Topup completes and converges at each resolution level (log output looks fine), but visually there’s no appreciable difference between dwi_pe_0.nii.gz and dwi_pe_0_applytopup.nii.gz (or possibly a bit worse). It seems like topup is either estimating a near-zero field or failing to apply any meaningful correction at all.
The eddy_mask.nii.gz output looks quite rough, it clips parts of the brain and includes non-brain voxels.
I’ve tried replacing it with a cleaner mask based on the mean b=0 (thresholded and dilated) and also with one from bet4animal on the T2. These help slightly, but ultimately just lead to a different distortion in the final output. So it seems the core issue isn’t in eddy itself but in the field topup is producing (or not producing).
I extracted a b=0 image from a separate PA scan acquired during the same session, with matching voxel size, slice prescription, and FOV. I used these as a pair in dwifslpreproc with the -rpe_pair option.
Can you visually confirm that the RPE image has an opposite distortion and occupies the same “space” as the DWI image?
From personal experience, until very recently, RPE images in Paravision weren’t supported at all and so it was usually accomplished with a hacked together flip that didn’t always mean that the images (when converted to NIFTI) were aligned. My RPE images were usually offset (left or right almost 50%) from the main image instead of having the brains at least roughly aligned.
If you open both the b0 and the RPE b0 in e.g., ITKSNAP, do they appear roughly aligned?
To check if you are affected by this problem (or potentially some unknown variant of it), you can check if topup_datain.txt, applytopup_config.txt, and eddy_config.txt in your scratch folder contain consistent phase encoding information (share the first few lines of those files here if not sure).