mrttransform not work before concatinete two dwi series

Dear expert
I’m new for mrtrix. Sorry for my biginner’question.
I’ve two separate dwi series, which are only scan polarity is inverted (AP and PA) for TOPUP, to concatenate.
dwi PA is acquired using FOV rotated comparing with dwi AP (caused by some technical error at console setting). mview shows leftward rotated dwi PA.mif.
dwifslpreproc was nicely run, and TOPUP correct susceptibility artifact despite this position error.

There is dwiAP_den_unr_preproc.mif(strait) and dwiPA_den_unr_preproc.mif (rotated).

I tried commands below.

dwiextract dwiAP_den_unr_preproc.mif --bzero | mrmath – mean_dwiAP_den_unr_preproc_b0.mif -axis 3

dwiextract dwiPA_den_unr_preproc.mif --bzero | mrmath – mean_dwiPA_den_unr_preproc_b0.mif -axis 3

flirt -in mean_dwiPA_den_unr_preproc_b0.mif -ref mean_dwiAP_den_unr_preproc_b0.mif -out r_mean_dwiPA_den_unr_preproc_b0.mif -omat AP2PA.mat

transformconvert AP2PA.mat mean_dwiPA_den_unr_preproc_b0.mif mean_dwiAP_den_unr_preproc_b0.mif flirt_import AP2PA_mrtrix.txt

mrtransport dwiPA_den_unr_preproc.mif -linear AP2PA_mrtrix.txt r_ dwiPA_den_unr_preproc.mif

mrtransport works without error. But r_dwiPA_den_unr_preproc.mif is still rotated despite well posisioned r_mean_dwiPA_den_unr_preproc_b0.mif…

How can I corregister dwiAP.mif and dwiPA.mif?

I appreciate any kind of advice.
Scenery

Masaki

mriinfo of
dwi_denAP_unr_preproc_unbiased_b0.mif
dwi_denPA_unr_preproc_unbiased_b0.mif
r_dwi_denPA_unr_preproc_unbiased_b0.mif
r_dwi_denPA_unr_preproc_unbiased.mif
are attached bilow


Image name: “NODDI_denAP_unr_preproc_unbiased_b0.mif”


Dimensions: 116 x 116 x 78
Voxel size: 1.93103 x 1.93103 x 1.9
Data strides: [ -1 2 -3 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9946 0.08579 -0.05803 -117.1
-0.08986 0.9934 -0.07151 -104.8
0.05151 0.07634 0.9958 -76.86
command_history: mrconvert NODDI_AP/NODDI_AP.nii NODDI_AP.mif -fslgrad NODDI_AP/NODDI_AP.bvec NODDI_AP/NODDI_AP.bval -datatype float32 (version=3.0.2)
[7 entries] dwidenoise NODDI_AP.mif NODDI_AP_den.mif -noise NODDI_AP_noise.mif -nthreads 8 (version=3.0.2)

dwiextract NODDI_denAP_unr_preproc_unbiased.mif - -bzero (version=3.0.2)
mrmath - mean NODDI_denAP_unr_preproc_unbiased_b0.mif -axis 3 (version=3.0.2)
comments: TE=95;sec=61397.8675;phaseDir=+;dwell=0.375
mrtrix_version: 3.0.2
prior_dw_scheme: 0,0,0,0
[8 entries] 0,0,0,0

0,0,0,0
0,0,0,0
prior_pe_scheme: 0.0,-1.0,0.0,0.032
[68 entries] 0.0,-1.0,0.0,0.032

0.0,-1.0,0.0,0.032
0.0,-1.0,0.0,0.032


Image name: “NODDI_denPA_unr_preproc_unbiased_b0.mif”


Dimensions: 116 x 116 x 78
Voxel size: 1.93103 x 1.93103 x 1.9
Data strides: [ -1 2 -3 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9946 -0.08579 -0.05803 -98.21
0.08158 0.9941 -0.07151 -123.7
0.06382 0.06639 0.9958 -77.12
command_history: mrconvert NODDI_PA/NODDI_PA.nii NODDI_PA.mif -fslgrad NODDI_PA/NODDI_PA.bvec NODDI_PA/NODDI_PA.bval -datatype float32 (version=3.0.2)
[7 entries] dwidenoise NODDI_PA.mif NODDI_PA_den.mif -noise NODDI_PA_noise.mif -nthreads 8 (version=3.0.2)

dwiextract NODDI_denPA_unr_preproc_unbiased.mif - -bzero (version=3.0.2)
mrmath - mean NODDI_denPA_unr_preproc_unbiased_b0.mif -axis 3 (version=3.0.2)
comments: TE=95;sec=61687.5975;phaseDir=-;dwell=0.375
mrtrix_version: 3.0.2
prior_dw_scheme: -0,0,0,0
[9 entries] 0,0,0,0

-0,0,0,0
0,0,0,0
prior_pe_scheme: 0.0,1.0,0.0,0.032
[69 entries] 0.0,1.0,0.0,0.032

0.0,1.0,0.0,0.032
0.0,1.0,0.0,0.032


Image name: “r_NODDI_denPA_unr_preproc_unbiased_b0.nii.gz”


Dimensions: 116 x 116 x 78
Voxel size: 1.93103 x 1.93103 x 1.9
Data strides: [ -1 2 -3 ]
Format: NIfTI-1.1 (GZip compressed)
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9946 0.08579 -0.05803 -117.1
-0.08986 0.9934 -0.07151 -104.8
0.05151 0.07634 0.9958 -76.86
comments: 6.0.4:ddd0a010


Image name: “r_NODDI_denPA_unr_preproc_unbiased.mif”


Dimensions: 116 x 116 x 78 x 69
Voxel size: 1.93103 x 1.93103 x 1.9 x 3.7
Data strides: [ -1 2 -3 4 ]
Format: MRtrix
Data type: 32 bit float (little endian)
Intensity scaling: offset = 0, multiplier = 1
Transform: 0.9942 -0.08963 -0.05909 -97.81
0.08572 0.9942 -0.06567 -124.2
0.06463 0.06022 0.9961 -76.89
command_history: mrconvert NODDI_PA/NODDI_PA.nii NODDI_PA.mif -fslgrad NODDI_PA/NODDI_PA.bvec NODDI_PA/NODDI_PA.bval -datatype float32 (version=3.0.2)
[6 entries] dwidenoise NODDI_PA.mif NODDI_PA_den.mif -noise NODDI_PA_noise.mif -nthreads 8 (version=3.0.2)

/home/masaki/miniconda3/bin/dwibiascorrect ants NODDI_denPA_unr_preproc.mif NODDI_denPA_unr_preproc_unbiased.mif -bias NODDI_PA_bias.mif (version=3.0.2)
mrtransform NODDI_denPA_unr_preproc_unbiased.mif -linear AP2PA_mrtrix.txt r_NODDI_denPA_unr_preproc_unbiased.mif -inverse -force (version=3.0.2)
comments: TE=95;sec=61687.5975;phaseDir=-;dwell=0.375
transform modified
dw_scheme: -0,0,0,0
[69 entries] 0.9718375813,-0.185413392,0.1454432761,700

0.6760369552,-0.6177393531,-0.4017116368,2000
0,0,0,0
mrtrix_version: 3.0.2
prior_pe_scheme: 0.0,1.0,0.0,0.032
[69 entries] 0.0,1.0,0.0,0.032

0.0,1.0,0.0,0.032
0.0,1.0,0.0,0.032

Without having checked in too much detail (your commands posted do not appear to be exactly what you ran: mrtransport should be mrtransform, flirt does not work with .mif images), I’d suspect the transformation worked but mrview shows you the rotated image.

Do the images look aligned when one is shown as an overlay? mrview mean_dwiAP_den_unr_preproc_b0.mif -overlay.load r_dwiPA_den_unr_preproc.mif -overlay.opacity 0.3 If so, everything is aligned in scanner space. Note, you can but don’t need to resample one image onto the grid of the other via mrtransform 's-template` option.

If the overlay is not aligned with the main image, please check that the transformed moving image produced by flirt is aligned with the target image and double-check that the commands including and after the flirt call are what you ran and we’ll have another look.

Welcome Masaki!

While it’s not described explicitly in your original post, I am inferring that you have executed dwifslpreproc twice—once with the AP volumes input, and once with the PA volumes input—and are now trying to achieve co-localisation between those two corrected volume series. You also commented that the susceptibility artifact correction has worked, suggesting to me that you have extracted the b=0 volumes from each of the AP and PA series and provided those to dwifslpreproc both times via the -se_epi option.

The disadvantage of operating in this way is that one or both of the series will therefore need to be interpolated twice: once as occurs within the FSL eddy command, and then a second time in order to bring the two series onto the same image grid. What would be preferable is for dwifslpreproc to be run once, with all data, so that all image data are transformed from input DWI to pre-processed DWI with a single interpolation step.

My initial thought was that you should simply run mrcat on the two DWI series prior to running dwifslpreproc, as that will produce a single 4D series containing all volumes; if your phase encoding information is embedded in the image header, that information will be conveyed properly in the image header to dwifslpreproc. Concatenation along the volume axis only requires that the number of voxels in the other axes be equivalent between the two images; the fact that the transform matrices are different between the two images does not preclude concatenation. But in thinking about this, there may be a limitation in doing so. Because the rotation component of the two transform matrices differs, taking the raw image intensities from one image and storing them on the voxel grid of the other—not performing image interpolation, just exploiting the fact that the number of voxels is equivalent for all spatial axes for the two series—actually involves rotating in space the data from the second series, which in turn necessitates that the diffusion gradient table also be rotated.

While I think this is something I can address in a software update, in your case what I would suggest is running mrtransform on the PA data, providing the AP image via the -replace option. That should (@maxpietsch can hopefully confirm) rotate the DWI gradient table corresponding to the change in the header transformation. Once you have done that, you can then concatenate the two series together prior to running dwifslpreproc.

Finally, a note on the consequences of this. It sounds like you have acquired data where all DWI volumes have been acquired in both phase encoding directions. Under normal circumstances, following eddy, these pairs of image volumes would be explicitly combined together to produce a single image volume per unique DWI sensitisation. There is a condition for this to be reasonable, which is that the orientation of diffusion sensitisation relative to the underlying biology is (sufficiently) equal between the two volumes (otherwise you’d be blurring data in orientation space). However following my suggestion above, since there is an implicit rotation occurring in bringing the data onto the same image grid, the diffusion sensitisation directions of “paired” DWI volumes will no longer be equivalent. As such, these will not be explicitly recombined by dwifslpreproc, and so the number of volumes in the output image series will be the sum of the number of volumes in the AP and PA series.

Hope that all makes sense
Rob

:+1: -replace does modify the gradient table.