T1w to DWI alignment errors in 5tt ACT

Dear MRtrix3 users and developers,
I’m trying to adapt the preprocessing pipeline available at OSF (B.A.T.M.A.N) to my data in order to perform Anatomically Constrained Tractography (OSF | B.A.T.M.A.N.: Basic and Advanced Tractography with MRtrix for All Neurophiles). Unfortunately I encounter some form of image registration error between T1 and DWI images.

Here’s a picture of my dwi_b0 image with the 5tt_nocoreg.mif image overlayed onto it (almost perfectly aligned):

Here’s a picture of my dwi_b0 image with the 5tt_nocoreg.mif image overlayed onto it (crazy stuff here!):

Here’s my bit of code for five tyssue type generation and then registration to dwi images:


#converting DICOM T1 directory to T1 image in .mif format
mrconvert /T1 T1_raw.mif

#preparing data for anatomically constrained tractography (ACT) to increase biological plausibility of stramlines
5ttgen fsl T1_raw.mif 5tt_nocoreg.mif -nocleanup

#compute mean of b0 images
dwiextract dwi_den_unr_preproc.mif - -bzero | mrmath - mean mean_b0_preprocessed.mif -axis 3

mrconvert mean_b0_preprocessed.mif mean_b0_preprocessed.nii.gz
bet mean_b0_preprocessed.nii.gz mean_b0_preprocessed_BET.nii.gz

#getting images for registration
cp 5ttgen-tmp-*/T1_BET.nii.gz ./
cp 5ttgen-tmp-*/T1_BET_pve_2.nii.gz ./
mrconvert T1_raw.mif T1.nii.gz

#register dwi to T1 and then apply inverse transform to register 5tt image to dwi
epi_reg --epi=mean_b0_preprocessed_BET.nii.gz --t1=T1.nii.gz --t1brain=T1_BET.nii.gz --wmseg=T1_BET_pve_2.nii.gz --out=diff2struct_fsl

transformconvert diff2struct_fsl.mat mean_b0_preprocessed_BET.nii.gz T1.nii.gz flirt_import diff2struct_mrtrix.txt

mrtransform 5tt_nocoreg.mif -linear diff2struct_mrtrix.txt -inverse 5tt_coreg.mif

#check results with:
mrview dwi_den_unr_preproc.mif -overlay.load 5tt_nocoreg.mif -overlay.colourmap 2 -overlay.load 5tt_coreg.mif -overlay.colourmap 1

Here there is mrinfo’s output of 5tt_nocoreg.mif and 5tt_coreg.mif

> ************************************************
> Image:               "5tt_nocoreg.mif"
> ************************************************
>   Dimensions:        192 x 245 x 195 x 5
>   Voxel size:        0.700521 x 0.700521 x 0.7 x ?
>   Data strides:      [ 2 3 4 1 ]
>   Format:            MRtrix
>   Data type:         32 bit float (little endian)
>   Intensity scaling: offset = 0, multiplier = 1
>   Transform:               0.9998    -0.01169     0.01318      -59.43
>                           0.01551      0.9388     -0.3442      -70.12
>                         -0.008352      0.3444      0.9388      -79.66
>   command_history:   /home/duzzo/mrtrix3/bin/mrcalc "T1_BET_pve_1.nii.gz" "multiplier_noNAN.mif" "-mult" "remove_unconnected_wm_mask.mif" "-mult" "cgm.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>                      /home/duzzo/mrtrix3/bin/mrcat "cgm.mif" "sgm.mif" "wm.mif" "csf.mif" "path.mif" "-" "-axis" "3" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>                      /home/duzzo/mrtrix3/bin/mrconvert "-" "combined_precrop.mif" "-strides" "+2,+3,+4,+1" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>                      /home/duzzo/mrtrix3/bin/mrcrop "combined_precrop.mif" "result.mif" "-mask" "-" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>                      /home/duzzo/mrtrix3/bin/mrconvert "result.mif" "/mnt/226AE1226AE0F407/DTI/pipeline_test/Duzzo/5tt_nocoreg.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>   comments:          6.0.1
>   mrtrix_version:    3
************************************************
Image:               "5tt_coreg.mif"
************************************************
  Dimensions:        192 x 195 x 245 x 5
  Voxel size:        0.700521 x 0.7 x 0.700521 x ?
  Data strides:      [ 2 -4 3 1 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:               0.9962    -0.08495     0.01874      -3.205
                          0.05217      0.7558      0.6527      -155.2
                         -0.06962     -0.6493      0.7574      -35.24
  command_history:   /home/duzzo/mrtrix3/bin/mrcalc "T1_BET_pve_1.nii.gz" "multiplier_noNAN.mif" "-mult" "remove_unconnected_wm_mask.mif" "-mult" "cgm.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
  [6 entries]        /home/duzzo/mrtrix3/bin/mrcat "cgm.mif" "sgm.mif" "wm.mif" "csf.mif" "path.mif" "-" "-axis" "3" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
                     ...
                     /home/duzzo/mrtrix3/bin/mrconvert "result.mif" "/mnt/226AE1226AE0F407/DTI/pipeline_test/Duzzo/5tt_nocoreg.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
                     mrtransform "5tt_nocoreg.mif" "-linear" "diff2struct_mrtrix.txt" "-inverse" "5tt_coreg.mif"  (version=3.0_RC3-137-g5d6b3a6f)
  comments:          6.0.1
                     transform modified
  mrtrix_version:    3.0_RC3-137-g5d6b3a6f
.0_RC3-137-g5d6b3a6f

Does anyone have an idea of why this is happening or where my pipeline is wrong?

thanks for your kind help and support
Davide

Hi,

I think the problem is here:

You should rename your WM mask as T1_BET_wmseg.nii.gz, and waht I don’t know is if it uses partial volume effect or binary images, you could try with both and see what happens.

Best regards,

Manuel

Dear Manuel,
many thanks for the quick answer!
I tried remaming the partial volume mask as T1_BET_wmseg.nii.gz but unfortunately the error still remained (blue is 5tt_nocoreg.mif, orange is 5tt_coreg.mif

mrinfo says:

>  ************************************************
> Image:               "5tt_coreg_wmseg.mif"
> ************************************************
>  Dimensions:        192 x 195 x 245 x 5
>   Voxel size:        0.700521 x 0.7 x 0.700521 x ?
>   Data strides:      [ 2 -4 3 1 ]
>   Format:            MRtrix
>   Data type:         32 bit float (little endian)
>   Intensity scaling: offset = 0, multiplier = 1
>   Transform:               0.9962    -0.08495     0.01874      -3.205
>                           0.05217      0.7558      0.6527      -155.2
>                          -0.06962     -0.6493      0.7574      -35.24
>   command_history:   /home/duzzo/mrtrix3/bin/mrcalc "T1_BET_pve_1.nii.gz" "multiplier_noNAN.mif" "-mult" "remove_unconnected_wm_mask.mif" "-mult" "cgm.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>   [6 entries]        /home/duzzo/mrtrix3/bin/mrcat "cgm.mif" "sgm.mif" "wm.mif" "csf.mif" "path.mif" "-" "-axis" "3" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>                      ...
>                      /home/duzzo/mrtrix3/bin/mrconvert "result.mif" "/mnt/226AE1226AE0F407/DTI/pipeline_test/Duzzo/5tt_nocoreg.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
>                      mrtransform "5tt_nocoreg.mif" "-linear" "diff2struct_mrtrix_wmseg.txt" "-inverse" "5tt_coreg_wmseg.mif" "-force"  (version=3.0_RC3-137-g5d6b3a6f)
>   comments:          6.0.1
>                      transform modified
>   mrtrix_version:    3.0_RC3-137-g5d6b3a6f

I then tried with a binary mask from 5tt image itself:

mrconvert 5tt_nocoreg.mif 5tt_nocoreg.nii.gz
fslsplit 5tt_nocoreg.nii.gz vol -t
mv vol0002..nii.gz T1_BET_wmseg.nii.gz
....

and the alignment improved (still not optimal):

mrinfo says:

Image:               "5tt_coreg_wmseg.mif"
************************************************
  Dimensions:        192 x 245 x 195 x 5
  Voxel size:        0.700521 x 0.700521 x 0.7 x ?
  Data strides:      [ 2 3 4 1 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:               0.9959    -0.03314    -0.08453         -63
                        -0.003852      0.9147      -0.404      -56.37
                          0.09071      0.4027      0.9108      -77.84
  command_history:   /home/duzzo/mrtrix3/bin/mrcalc "T1_BET_pve_1.nii.gz" "multiplier_noNAN.mif" "-mult" "remove_unconnected_wm_mask.mif" "-mult" "cgm.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
  [6 entries]        /home/duzzo/mrtrix3/bin/mrcat "cgm.mif" "sgm.mif" "wm.mif" "csf.mif" "path.mif" "-" "-axis" "3" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
                     ...
                     /home/duzzo/mrtrix3/bin/mrconvert "result.mif" "/mnt/226AE1226AE0F407/DTI/pipeline_test/Duzzo/5tt_nocoreg.mif" "-nthreads" "4"  (version=3.0_RC3-137-g5d6b3a6f)
                     mrtransform "5tt_nocoreg.mif" "-linear" "diff2struct_mrtrix_wmseg.txt" "-inverse" "5tt_coreg_wmseg.mif" "-force"  (version=3.0_RC3-137-g5d6b3a6f)
  comments:          6.0.1
                     transform modified
  mrtrix_version:    3.0_RC3-137-g5d6b3a6f

so this surely has helped but has not solved the issue.
I’m also wondering why the 5tt_nocoreg.mif image is so similar to the mean_b0_preprocessed_BET.mif reference

Hi,

I think the 5tt file is builded with the probability maps, so unless there is an extra command after that, the wm should be a pve.

Could you check that the T1, T1_BET and T1_BET_wmseg are in the same space? and the output of epi_reg is aligned to the T1? maybe the B0 mask is not good enough?

Best regards,

Manuel

Dear Manuel,
you were right in checking the T1_BET image. As always, looking at the data is the best thing to do.
Now the registration works perfectly.
Using mean_b0_preprocessed.nii.gz (instead of the BET image) and hard segmentation (non pve) wmseg image also improves the alignment

here the final result:

thanks for your kind help and support
Davide

Hi all,

I wanted to align 5tt_nocoreg.mif to the subjects’ DWI space and saw this thread. However, I realized that using epi_reg results in alignment errors whatever I do so I came up with a simpler solution and I wonder was there a reason that you haven’t used it? Any comments are appreciated.

5ttgen fsl t1.nii.gz 5tt_nocoreg.mif -nocleanup
dwiextract preproc_dwi.mif - -bzero | mrmath - mean preproc_b0.nii.gz -axis 3
bet preproc_b0.nii.gz preproc_b0_brain.nii.gz #I had to change -f option
flirt -in preproc_b0_brain.nii.gz -ref T1_BET.nii.gz -cost normmi -dof 6 -omat dwi_to_t1.mat -out dwi_to_t1.nii.gz
transformconvert dwi_to_t1.mat preproc_b0_brain.nii.gz T1_BET.nii.gz flirt_import dwi_to_t1.txt
mrtransform 5tt_nocoreg.mif -linear dwi_to_t1.txt -inverse 5tt_coreg.mif
5tt2vis 5tt_coreg.mif 5tt_coreg_vis.mif

The result can be viewed:
image

Bests,
Amir