Registration and protocol-mask alignment problems with FSL XTRACT

Hello,

I am using FSL XTRACT for tractography with preprocessed diffusion data and completed BEDPOSTX models.

During visual QC, I noticed that the registered images and the standard protocol masks mapped into native diffusion space do not appear to align correctly with the anatomy. The processing completes successfully, but the anatomical alignment remains questionable.

How would you systematically identify whether the problem comes from diffusion-to-T1 registration, T1-to-standard registration, or applying the transforms to the masks?

What checks and corrections would you recommend before processing the full cohort? I can share the exact commands and example overlays.

Thank you.

On one subject, I’d first locate the earliest bad overlay: diffusion reference mapped into T1, T1 mapped into the exact standard reference, then that standard reference mapped back into diffusion space. If those look sound but the protocol masks do not, inspect mask warping separately.

Could you share your FSL/XTRACT version, registration commands and XTRACT command, plus cropped, de-identified overlays at those three stages? One concrete check from the XTRACT help: -stdwarp expects standard-to-diffusion first and diffusion-to-standard second. Also state the reference images and warp convention used; ANTs fields require conversion to FSL’s convention.

Thank you for your guidance. I’m using FSL 6.0.7.18 and ANTs 2.6.5, with FSL’s MNI152_T1_2mm_brain.nii.gz as the standard reference.

The attached images show the same subject:

  1. 01_diffusion_in_T1.png: diffusion reference mapped into native T1.

    epi_reg 
    –epi=b0_brain.nii.gz 
    –t1=T1_whole.nii.gz 
    –t1brain=T1_brain.nii.gz 
    –out=b0_to_T1
    
    convert_xfm 
    -omat T1_to_b0.mat 
    -inverse b0_to_T1.mat
    
  2. 02_T1_in_standard_nonlinear.png: T1 mapped into the standard reference.

    
    
  3. FIXED=“$FSLDIR/data/standard/MNI152_T1_2mm_brain.nii.gz”
    MOVING=“T1_brain.nii.gz”
    
    antsRegistration --dimensionality 3 --float 1 
    –random-seed 20261026 
    –collapse-output-transforms 1 
    –write-composite-transform 0 
    –output “[ants_,T1_nonlinear_in_MNI.nii.gz]” 
    –interpolation Linear 
    –use-histogram-matching 0 
    –initial-moving-transform “[$FIXED,$MOVING,1]” 
    –transform “Rigid[0.1]” 
    –metric “MI[$FIXED,$MOVING,1,32,Regular,0.25]” 
    –convergence “[1000x500x250x100,1e-6,10]” 
    –shrink-factors 8x4x2x1 
    –smoothing-sigmas 3x2x1x0vox 
    –transform “Affine[0.1]” 
    –metric “MI[$FIXED,$MOVING,1,32,Regular,0.25]” 
    –convergence “[1000x500x250x100,1e-6,10]” 
    –shrink-factors 8x4x2x1 
    –smoothing-sigmas 3x2x1x0vox 
    –transform “SyN[0.2,3,0]” 
    –metric “CC[$FIXED,$MOVING,1,2]” 
    –convergence “[100x70x50x20,1e-6,10]” 
    –shrink-factors 8x4x2x1 
    –smoothing-sigmas 3x2x1x0vox
    
  4. 03_standard_in_diffusion_nonlinear.png: standard reference mapped back into diffusion space.

    antsApplyTransforms 
    -d 3 
    -i “$FIXED” 
    -r “$MOVING” 
    -n Linear 
    -t “[ants_0GenericAffine.mat,1]” 
    -t ants_1InverseWarp.nii.gz 
    -o standard_in_T1.nii.gz
    
    flirt 
    -in standard_in_T1.nii.gz 
    -ref b0_brain.nii.gz 
    -applyxfm 
    -init T1_to_b0.mat 
    -interp trilinear 
    -noresampblur 
    -out standard_in_diffusion.nii.gz
    

then XTRACT command

convertwarp 
–ref=b0_brain.nii.gz 
–premat=identity.mat 
–out=native_identity_warp.nii.gz

xtract 
-bpx retained_model.bedpostX 
-out xtract_output 
-species HUMAN 
-p affine_mapped_native_protocols 
-str structureList.txt 
-stdref b0_brain.nii.gz 
-stdwarp native_identity_warp.nii.gz native_identity_warp.nii.gz 
-native


Grayscale shows the reference image; red edges show the mapped image. I’ve also attached the registration and mask-transformation commands.

ANTs transforms were applied using antsApplyTransforms, and FSL matrices using FLIRT. The attached XTRACT command is from a separate affine test using already-mapped native masks and identity FSL warps; it does not correspond to the nonlinear overlays above.

Could you help identify the first stage showing incorrect alignment?

Thanks, separating the nonlinear overlays from the affine XTRACT test helps. I would not reverse the ANTs transform order you show: with standard as fixed and T1 as moving, the inverted affine followed by the inverse warp matches the documented standard-to-T1 image-resampling sequence: Forward and inverse warps for warping images, pointsets and Jacobians · ANTsX/ANTs Wiki · GitHub

I can’t confidently identify the first failed registration from these dense edge montages. In particular, a broadly matching outer contour can hide local mismatch. A few cropped orthogonal views of 01 and 02 around the ventricles and corpus callosum, with a checkerboard or less dense overlay, would make that judgement much more reliable.

One concrete distinction for the separate XTRACT test: the current help defines -native as tracking in diffusion space and -in_native as protocol masks already being in diffusion space. Check your installed xtract --help before using the latter. An identity-warp test only tests the downstream path if the pre-mapped masks already align with the exact b0/bedpostX reference. Overlay one of those actual seed masks there first, separately from the nonlinear standard-image QC. The XTRACT help is linked above.

Many Thanks!
Here are clearer orthogonal views: diffusion-to-T1, nonlinear T1-to-standard, and the affine comparison. Each registration figure shows the reference, mapped image and checkerboard.

The fourth image shows the actual seed used by XTRACT in the separate affine tracking test. Its grid matches the diffusion/BEDPOSTX reference, and its binary mask is unchanged from the pre-mapped input. Anatomical placement still needs assessment.

My installed XTRACT help lists -native but not -in_native; I have included the help output.

Could you assess whether the first problematic stage is diffusion-to-T1 or T1-to-standard, particularly around the ventricles and corpus callosum?

These are much clearer. The ventricular boundaries differ visibly in the axial panel of 03, but that composite alone does not identify the first failed step. Your new 02 is labelled “affine”, whereas 03 uses the nonlinear chain.

The next comparison I’d make is the actual T1_nonlinear_in_MNI.nii.gz from your posted registration command against the fixed MNI reference, followed by standard_in_T1.nii.gz against native T1, before the final FLIRT step. That separates the nonlinear registration and its inverse application from the return to diffusion space. Please keep the affine comparison alongside them, rather than substituting it for the nonlinear output.

Also, if your installed help does not list -in_native, don’t add it on the basis of the current online help. That needs a version-specific check; the seed sharing the b0 grid is not an anatomical-placement check.

Thank you. I have now separated and labelled the comparisons:

A. Nonlinear T1 → MNI, against the fixed MNI reference.


B. Nonlinear MNI → native T1, before the final FLIRT step.


C. Affine T1 → MNI comparison.


D. Affine MNI → native T1 comparison, also before FLIRT.

Each figure shows the reference on the left, mapped image in the middle and checkerboard on the right.

Local mismatch appears to remain in B, before returning to diffusion space. Does this help distinguish a problem with the nonlinear registration from its inverse application?

Yes, B narrows this to the T1↔MNI chain before FLIRT. It doesn’t by itself separate registration quality from an inverse-application problem. Your posted inverse transform order already matches the ANTs image-resampling example linked above, so I wouldn’t swap it.

A useful next check is to reapply the saved forward warp and affine to the original T1, with the exact fixed MNI image as reference, and compare that result with T1_nonlinear_in_MNI.nii.gz written by the same registration run. Keep interpolation consistent and record --verbose output. If those differ substantially, check application settings and whether the files came from the same run before tuning registration parameters. If they agree, that establishes application consistency, not anatomical accuracy.

For B, can you confirm that the inverse warp, affine, T1 and MNI reference all belong to that same run, and share the exact inverse command and verbose output with private paths removed?

1 Like

Thank you. I reapplied the saved forward warp and affine to the original moving T1 using the saved fixed MNI reference, linear interpolation and float precision matching the registration.

The reapplied result closely reproduces T1_nonlinear_in_MNI.nii.gz: RMSE divided by the reference image’s absolute intensity P99 is 9.04 × 10⁻⁷. The maximum absolute voxel difference is 0.00444.

Reapplying the inverse command reproduces the previous panel-B image exactly. The T1, MNI reference, affine, forward warp, inverse warp and registration-written output also match their saved review copies by SHA-256.

These checks support file and application consistency, rather than anatomical accuracy. I have included the exact commands and verbose logs, with private paths removed.

Given the remaining local mismatch, which aspect of registration quality would you recommend investigating next?

inverse_verbose.txt (1.1 KB)

forward_command.txt (711 Bytes)

inverse_command.txt (721 Bytes)

forward_verbose.txt (1.1 KB)

That narrows it. I’d next compare the affine-only result from this same nonlinear run with its full nonlinear output. The earlier affine panel came from a separate test, so it may not show the initial alignment that SyN actually received.

Apply only the saved ants_0GenericAffine.mat to the original T1 on the same fixed MNI grid, keeping interpolation consistent. Compare matched slices and landmarks against the full nonlinear result. ANTs’ troubleshooting guide recommends this stage comparison.

If the mismatch is already present after affine, check the initial alignment and brain extraction first. If it appears or worsens during SyN, intermediate outputs from --write-interval-volumes can help locate the stage and resolution level. I’d isolate that on this subject before changing parameters across the cohort.

Thank you. I checked the saved script and need to clarify my earlier wording: C was generated by applying only ants_0GenericAffine.mat from the same nonlinear registration run, using the same moving T1, fixed MNI reference and linear interpolation.

The separate affine test I mentioned was the subsequent XTRACT tracking test—not an independently fitted affine registration for C. Sorry for the confusion.

Therefore, A and C are intended to show the full nonlinear output and its affine-only stage from the same run. I will verify that affine-only image by reapplying the saved matrix with verbose output before interpreting whether the mismatch appears or worsens during SyN.

Thanks for clarifying. I had read C as coming from a separate affine registration; that was the wrong distinction. If your reapplication reproduces C, A versus C already provides the same-run stage comparison I meant. I wouldn’t repeat a separate affine fit on the strength of my earlier wording.