Closed ida-sk closed 2 years ago
I updated the Wiki with an example:
https://github.com/ANTsX/ANTs/wiki/Warp-and-reorient-a-diffusion-tensor-image#combining-warps
My second question is whether you would recommend to use dtifit first and afterwards register DT, FA, etc. separately or isn't it also possible (and maybe helpful for further steps) to register the DWI and afterwards fit tensors?
I believe the usual practice is to compute diffusion tensors in the native space. I think the HCP pipelines align the DWI to the T1w image, but this is only a rigid transform (distortion correction is performed before the DWI -> T1w registration) with a small correction for motion.
Thank you very much for your recommendations!
Am 28.02.2020 17:34, schrieb Philip Cook:
I updated the Wiki with an example:
https://github.com/ANTsX/ANTs/wiki/Warp-and-reorient-a-diffusion-tensor-image#combining-warps
My second question is whether you would recommend to use dtifit first and afterwards register DT, FA, etc. separately or isn't it also possible (and maybe helpful for further steps) to register the DWI and afterwards fit tensors?
I believe the usual practice is to compute diffusion tensors in the native space. I think the HCP pipelines align the DWI to the T1w image, but this is only a rigid transform (distortion correction is performed before the DWI -> T1w registration) with a small correction for motion.
-- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [1], or unsubscribe [2].
[1] https://github.com/ANTsX/ANTs/issues/957?email_source=notifications&email_token=AOHLXHZZA6JOOFMYQ7I4653RFE4KZA5CNFSM4K45PMX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENJD7HI#issuecomment-592592797 [2] https://github.com/notifications/unsubscribe-auth/AOHLXHZGK5N5FN3RRFJQDJTRFE4KZANCNFSM4K45PMXQ
Following your instructions (https://github.com/ANTsX/ANTs/wiki/Warp-and-reorient-a-diffusion-tensor-image) I still have the same problem as I had before; The images diffusionToAnatWarped.nii.gz and anatToGroupTemplateWarped.nii.gz look ok. However, the images dtGroupTemplateDeformed.nii.gz and dtNormalizedToGroupTemplate.nii.gz exclusively shows the outlines of the brain. Do you have any ideas what could cause this?
Try
ImageMath 3 fa.nii.gz TensorFA dt.nii.gz ImageMath 3 md.nii.gz TensorMeanDiffusion dt.nii.gz
The MD values in the interior of the brain will give you a ballpark for the correct setting for the background voxels.
Also make sure that your tensors are in the correct format:
https://github.com/ANTsX/ANTs/wiki/Importing-diffusion-tensor-data-from-other-software
Unfortunately, adjusting the -f option in antsApplyTransforms did not solve the problem that you can see in the image above. Also we transformed the tensor to the correct format the way you recommended (https://github.com/ANTsX/ANTs/wiki/Importing-diffusion-tensor-data-from-other-software). Using the PrintHeader Option, the new DT image seems to be correctly encoded. However, the transformed image looks a little strange. Did the transformation go wrong? Are there other options for transforming the image?
Tensor after transformation
Tensor before transformation
The respective code was;
dtifit -k DTI_eddy_corrected -o DTI_fit -m DTI_eddy_corrected_b0_brain_0.20_g0.1_mask -r DTI.bvec -b DTI.bval --save_tensor
ImageMath 4 dtiComp.nii.gz TimeSeriesDisassemble DTI_fittensor.nii.gz i=0 for index in xx xy xz yy yz zz; do mv dtiComp100${i}.nii.gz dtiComp${index}.nii.gz i=$((i+1)) done ImageMath 3 dtAnts.nii.gz ComponentTo3DTensor dtiComp_
Thank you for your quick and useful recommendations!
Beyond that we asked ourselves another question; After transforming the DT, the registration should be done by proxy, e.g. FA. However, when computing FA from the transformed DT, the FA image of course isn't in the required format as dim[0] is necessarily 3 not 5 and dim[5] is 1 instead of 6. Another approach could be to use the FA image that is part of the output from dtifit (FSL) - when doing so, does this image need to be transformed in any way?
(and - as I was not able to find an answer in the Wiki - are there also mandatory transformations for the T1 and for the Template which are both in NIFTI format?)
and - in any case - does ANTs prefer betted or unbetted images?
Might be useful; Code for the registration process;
ImageMath 3 fa.nii.gz TensorFA dtANTS.nii.gz
antsRegistrationSyNQuick.sh -d 3 -f ICBM_brain.nii.gz -m T1_brain_corrected_restore.nii.gz -o ANTS_t12icbm
antsApplyTransforms -d 3 -r ICBM_brain.nii.gz -i T1_brain_corrected_restore.nii.gz -e 0 -t ANTS_t12icbm1Warp.nii.gz -t ANTS_t12icbm0GenericAffine.mat -o out_t12icbm.nii.gz -v 1
antsRegistrationSyNQuick.sh -d 3 -f T1_brain_corrected_restore.nii.gz -m fa.nii.gz -o ANTS_fa2t1
antsApplyTransforms -d 3 -i dtANTS.nii.gz -o dt04ANTSGroupTemplateDeformed.nii.gz -e 2 -t ANTS_t12icbm1Warp.nii.gz -t ANTS_t12icbm0GenericAffine.mat -t ANTS_fa2t10GenericAffine.mat -r ICBM_brain.nii.gz -f 0.0004
antsApplyTransforms -d 3 -o [dt04ANTSCombinedWarp.nii.gz,1] -t ANTS_t12icbm1Warp.nii.gz -t ANTS_t12icbm0GenericAffine.mat -t ANTS_fa2t10GenericAffine.mat -r ICBM_brain.nii.gz -f 0.0004
ReorientTensorImage 3 dt04ANTSGroupTemplateDeformed.nii.gz dt04ANTSNormalizedToGroupTemplate.nii.gz dt04ANTSCombinedWarp.nii.gz
The only problem I can see in the above code is that you have not requested a rigid or affine transform here:
registration fa 2 t1
antsRegistrationSyNQuick.sh -d 3 -f T1_brain_corrected_restore.nii.gz -m fa.nii.gz -o ANTS_fa2t1
But you are only using the affine part below
antsApplyTransforms -d 3 -i dtANTS.nii.gz -o dt04ANTSGroupTemplateDeformed.nii.gz -e 2 -t ANTS_t12icbm1Warp.nii.gz -t ANTS_t12icbm0GenericAffine.mat -t ANTS_fa2t10GenericAffine.mat -r ICBM_brain.nii.gz -f 0.0004
Can you share the data?
here is the link to the data - it will be available for 3 days:
https://www3.hu-berlin.de/dateiaustausch?g=ry4nklrxzn4q86k66qn8
The folder 'originals' contains all relevant original data. The folder 'originals_preprocessing' contains images from the preprocessing (e.g. after topup or eddy). The folder 'originals_preprocessed_ants' contains the files used in the code above. [sub-folder 'originals_preprocessed_ants_f0.0004' - version with -f 0.0004]
Thanks I did download this, will take a look when I get a chance.
Dear Mr. Cook - did you have had time to look at the data?
I'm sorry, I did download it to my work machine, but I have not been able to dig into it.
A colleague has updated my antsDTOrientationTests repo to work with HCP data. I have not reviewed in detail but I think it is correct, and may be of use.
https://github.com/lindenmp/antsDTOrientationTests
I'll try to answer the questions as I see them:
I would try to figure out if these changes are in the brain itself, or if they are just in the noisy voxels around the edge of the brain. Because of the log transformation and interpolation, outlier tensors with negative eigenvalues can cause a big shift in the bounds of the image histogram. This can only really be avoided by fixing the problem tensors or masking them out ahead of transformation.
You can compute FA from the ANTs tensor image, using ImageMath. It will then be in the same space as the ANTs-format DT.
You can use b0, or FA, or both with antsRegistration, and apply the warps to the DT.
You should have the output of antsRegistration (Warp.nii.gz and GenericAffine.mat) for all registration transforms you want to apply, yes.
It can do either, the problems arise when you have inconsistencies between the images. If you have a moving image with skull and a brain-extracted template, for example, you will have trouble.
Finally got some time to look at this. I think the problem arises from interpolation at the edge of the brain mask. If the tensor does not have positive eigenvalues (due to noise or because it's been masked out and set to zero), it cannot be represented in the log space. So these eigenvalues get replaced, but in a way that results in very large mean diffusivity values.
I can't reproduce all the steps because I'm missing some of the files (like the bvecs / bvals), but here's what I get for mean diffusivity from
originals_preprocessed_ants/originals_preprocessed_ants_f0.0004/dt04ANTSGroupTemplateDeformed.nii.gz
You can see in the sagittal slice where the background tensors (-f) were inserted because those voxels map outside the domain of the moving image.
I should probably work on a more intelligent way of fixing this. But for right now, you could try applying the transforms to the unbetted DT image, then applying the brain mask in the template space.
Another probably minor thing I did notice:
antsApplyTransforms -d 3 -o [dt04ANTSCombinedWarp.nii.gz,1] -t ANTS_t12icbm1Warp.nii.gz -t ANTS_t12icbm0GenericAffine.mat -t ANTS_fa2t10GenericAffine.mat -r ICBM_brain.nii.gz -f 0.0004
the -f
option should only be used when transforming a tensor, not when combining the warp field.
Hello I am working on fMRI images (4 dimension) I want to register them on MNI template antregistration works very well on 3D, but when I want to apply the transformation on 4D image, it doesn't! This my code:
**antsRegistration -d 3 -n BSpline -t Affine[0.1] -m MI[MNI152_T1_2mm, SBRef.nii.gz,1,32,Regular,0.25] -c [1000x500x250,1e-6,20] -s 4x2x1vox -f 3x2x1 -u 0 -z 1 -o [Aff_Trasfrm, WarpedImage.nii.gz, InvWarpedImage.nii.gz]
antsApplyTransforms -d 3 -e 3 -i EPI_Image.nii.gz -r WarpedImage.nii.gz -o Aff_Reg_EPI.nii.gz -n BSpline -t Aff_Trasfrm0GenericAffine.mat -v 1**
Can anyone help ?
Regards
Please don't randomly comment on old threads with copy and pasted comments
Dear ntustison and ANTS-Community,
I am trying to apply transformations from registering (1) T1.nii.gz to template.nii.gz and (2) b0.nii.gz to T1.nii.gz to my DT.nii.gz (result from dtifit, fsl). [refering to: https://github.com/ANTsX/ANTs/wiki/Warp-and-reorient-a-diffusion-tensor-image]
My first question is; if a want to apply both transformations (1) and (2) to DT.nii.gz - is it necessary to first combine transformations (1) and (2) by e.g. using sth. like: antsApplyTransforms -d 3 -r fixed.nii.gz -o [dtCombinedWarp.nii.gz,1] \ -t movingb0_ToT11Warp.nii.gz -t movingbo_ToT10GenericAffine.mat \ -t movingT1_ToTemplate1Warp.nii.gz -t movingT1_ToTemplate0GenericAffine.mat -r fixed.nii.gz ? Or should that just be done for the Reorienting, but not be put into the antsApplyTransforms?
My second question is whether you would recommend to use dtifit first and afterwards register DT, FA, etc. separately or isn't it also possible (and maybe helpful for further steps) to register the DWI and afterwards fit tensors?
Best regards!