Problem reorienting DTI images #1461
Replies: 5 comments 8 replies
-
Sorry I have not had time to look at this. Can you share the template an an example dtAnts.nii.gz? |
Beta Was this translation helpful? Give feedback.
-
Hi Philip, Thanks so much for following up on my post! The files are quite large (>300MB each). I uploaded to a Dropbox folder that can be shared. Should I post the link here of or better to email you? Best, p.s. We're neighbors. I'm at Penn too. 4th floor Goddard. Happy to swing by if easier to chat in person. |
Beta Was this translation helpful? Give feedback.
-
Sorry again! I added the nii.gz file to folder 1. Do you think I'm doing something weird in the preprocessing of the diffusion data? Or could there be something weird with how I have the template oriented? The RGB map looks correct in native space after converting from mrtrix to the ANTs format. It gets weird (AP and RL seem to be flipped) when warping to template. Maybe that the template is in a weird space and, as you said, ANTs is warping correctly? |
Beta Was this translation helpful? Give feedback.
-
Thanks for all these files, I think I've ruled out any problems with the data at the tensor level. I believe the issue is that your input tensors are in physical space. This is why the RGB images in native space look correct - because ITK-SNAP displays the image in it's best guess of the physical canonical orientations - it uses the image header to figure out how to display the image so that the L, R, P, A, I, S, labels are correct. There's disagreement between software on how to represent the gradient directions (bvecs) and tensors. It's a long story but ANTs expects tensors in voxel space on disk. When you call You can call I'm sorry to have to warn about a longstanding issue with tensor orientation and reorientation (#1137). I've tried to address this but have not had the resources to do so definitively. You might need to verify the reorientation yourself, by doing a rigid registration that will make problems obvious. If you load your template into SNAP as an overlay, you can apply a large (eg, 30 degree) rotation - save that and use as a reference image. Then do a registration to the rotated template (using rebased tensors as above), apply reorientation, and then rebase and look at tensor color. This should highlight any problems. This is all very confusing, so just to reiterate:
To simplify, imagine we had a consistent voxel space between the moving and template images, like RPI. Then if you called Unfortunately, there's also degeneracy in the RGB representation, so it's not easy especially if the rotations are fairly small to judge by eye. The best way to tell is via tractography, but that again requires importing to some other software, which might interpret the image differently. |
Beta Was this translation helpful? Give feedback.
-
Hi Philip, Thanks so much for spending all this time looking at my data and for thoroughly explaining the issues with tensor reorientation. This is all really terrific and super helpful! Running RebaseTensorImage before and after antsApplyTransforms results in reasonable looking RGB maps in template space. I still need to test with the ~30 degree rotation and also see if tracking looks OK. I also will probably just recreate the template in ASL. There's no reason it needs to be IPR (and not sure why it's oblique in the first place). Happy for you to hold onto the data and use it for additional testing. Also, happy to provide more data of that kind if it would be useful for testing! Best, |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have some diffusion data that I preprocessed with MRtrix3 then aligned to a template using ANTs. Prior to registration, the RGB maps look correct (i.e., in native space). After transformation using ANTs' recommended steps here, the colors are incorrect. e.g., the corpus callosum is green instead of red. There is little difference between the template-warped RGB maps pre- and post- ReorientTensor (see attached images), so it seems like the reorienting isn't doing what I want it to do. Below, I copy the commands I used as well as screenshots showing the RGB maps pre and post warping. Any advice on how to debug would be much appreciated!
In case relevant, these data were collected on a Bruker 11.7T scanner.
Best,
Mike
Convert ordering of tensor data from MRtrix to ANTs format:
ImageMath 4 dtiComp.nii.gz TimeSeriesDisassemble tensor.nii
i=0
for index in xx yy zz xy xz yz; do
mv dtiComp100${i}.nii.gz dtiComp_${index}.nii.gz
i=$((i+1))
done
ImageMath 3 dtAnts.nii.gz ComponentTo3DTensor dtiComp_
Calculate FA, MD, and RGB maps
ImageMath 3 dtFA_native.nii.gz TensorFA dtAnts.nii.gz
ImageMath 3 dtMD_native.nii.gz TensorMeanDiffusion dtAnts.nii.gz
ImageMath 3 dtRGB_native.nii.gz TensorColor dtAnts.nii.gz
Register to template
antsRegistrationSyN.sh -f template.nii.gz -m bzero.nii.gz -d 3 -o dwi2template -n 4
Warp tensor to template
antsApplyTransforms -d 3 -e 2 -i dtAnts.nii.gz -o tensor2template.nii.gz -t dwi2template1Warp.nii.gz -t dwi2template0GenericAffine.mat -r template.nii.gz
Correct orientation due to warping
antsApplyTransforms -d 3 -o [dtCombinedWarp.nii.gz,1] -t dwi2template1Warp.nii.gz -t dwi2template0GenericAffine.mat -r template.nii.gz
ReorientTensorImage 3 tensor2template.nii.gz tensor2template_reoriented.nii.gz dtCombinedWarp.nii.gz
ImageMath 3 dtFA_template_reorient.nii.gz TensorFA tensor2template_reoriented.nii.gz
ImageMath 3 dtMD_template_reorient.nii.gz TensorMeanDiffusion tensor2template_reoriented.nii.gz
ImageMath 3 dtRGB_template_reorient.nii.gz TensorColor tensor2template_reoriented.nii.gz
Native space:
After antsApplyTransforms but before ReorientTensorImage:
After ReorientTensorImage:
Beta Was this translation helpful? Give feedback.
All reactions