MRtrix3 / mrtrix3

MRtrix3 provides a set of tools to perform various advanced diffusion MRI analyses, including constrained spherical deconvolution (CSD), probabilistic tractography, track-density imaging, and apparent fibre density
http://www.mrtrix.org
Mozilla Public License 2.0
295 stars 182 forks source link

Issue with FOD reorientation in Rigid Transforms #2765

Closed ppruc closed 1 year ago

ppruc commented 1 year ago

Hello,

I've come across an issue when applying rigid-body transformations to FODs with reorientation. When calling mrtransform with the -linear -reorient_fod yes option, only the transform is applied, however, FODs do not seem to be reoriented. After transforming the session wmfods to a common session template, this is the wmfod difference image:

MicrosoftTeams-image (2)

When applying the same transform as deformation warp (converted by applying the rigid-body transformations to the wmfods idendity matrices with reslicing on the template) with reoriention to the wmfods, and then taking the difference of the transformed images, this is the result:

MicrosoftTeams-image (3)

When applying the same warp without reorientation, I get the same difference image as obsereved initially by using the -linear -reorient yes options.

MicrosoftTeams-image (4)

Experienced using MRtrix3 3.0.3

bjeurissen commented 1 year ago

I am not sure your screenshots indicate that reorientation is not working. If I understand correctly, what you are looking at is differences in the zero-th order SH coefficients, which are completely unaffected by reorientation.

Regarding the reduced difference in zero-th order coefficients when applying the rigid transformation as a deformation, rather than a plain rigid transform:

I suspect, this is because applying a rigid transform using mrtransform will merely adjust the image header and not touch the actual voxel values (apart from FOD reorientation, if requested) . As a result you are probably voxel-wise subtracting two images with distinct transformations in the image headers (I suspect you would get a warning about that), making it seem as if the differences are massive. When you apply the rigid transform as a warp, the headers will stay the same and the voxel values will be resampled, explaining the much lower difference.

If you want to have the same behaviour for rigid transforms, you should use the -template option of mrtransform.

ppruc commented 1 year ago

Hi Ben,

thanks for the reply! You're right, what shown here is the zero-th order SH image. However, I did use the -template option for the linear transforms - I believe it's also indicated in the upper left corner the first image, saying "regridded to template image".

But I also had a second look at the transformed + reoriented FODs.. seems like I didn't zoom in close enough the first time, they are slightly moving indeed, just more subtle than I would've thought.. so FOD reorientation must be working, apologies!

What I also noticed: I still get the same differences as observed in the very first image when applying the "rigid warp" without fod modulation; which I find confusing, because since the warp represents a rigid transform, I would've thought that FOD modulation shouldnt't have an effect? given the determinant should be 1 everywhere?

commands used for generating the "rigid warp": warpinit ses-01/dwi/wmfod_norm.mif.gz ses-01/dwi/idendity.mif.gz mrtransform ses-01/dwi/idendity.mif.gz -linear template/linear/sub2temp_ses-01_rigid.txt template/warps/sub2temp_ses-01.mif.gz -template template/template_wmfod.mif.gz

Best Philip

bjeurissen commented 1 year ago

Is it possible to share the images and provide a listing of all the commands so we can reproduce?

BTW: I just noticed that the intensity range in the viewer is not set the same for both images you show. Could you set an identical range?

ppruc commented 1 year ago

uiii true you're absolutely right!

Think we have our solution: The warp produced some very high and low values at the borders of the image (probably some FOV issue?) which set the automatic intensity range to approx -3 to 3, making the small difference values barely visible. Manually setting the range gives the same image as previously produced by the linear transforms. So everything is working just fine, reorientation, modulation, etc.

Very sorry having overlooked this and thanks a lot for your help!

bjeurissen commented 1 year ago

Glad that it is sorted!