Manipulating antsImage attributes in ANTsR

June 15, 2016

Today I was trying to generate a hippocampus segmentation by registering an atlas brain (for which I have a manual binary segmentation) to my target brain. My procedure in R involved the following steps:


1. Register atlas T1 to target T1 using 'antsRegistration' (both already N4 corrected)

2. Apply the forward transformations to the binary hippocampus mask 



Step 2 returned an array of all zeros. When I applied the forward transformations from Step 1, the hippocampus completely disappeared!



I needed to fix the origin of the hippocampus mask antsImage object, which originally was 0,0,0. I used 'antsSetOrigin' and 'antsGetOrigin' to set the origin to that of my atlas T1. 



I was expecting this procedure to take 2 minutes, so naturally it took me 2 hours. Step 1 went smoothly, and the resulting warped atlas looked great using the default 'SyN' transformation type, which first does an affine (i.e., linear) transformation followed by a deformable (i.e., non-linear) one. An affine transformation can only translate, rotate, and scale the atlas brain to get it close to the target brain. This provides a good starting point so that the deformable transformation can then stretch and shear the atlas to make it look even more like the target.  Repeat these words to yourself every day and I promise the basics of image registration will eventually click and make sense.  It only took me about 365 repeats.


Step 2 mysteriously returned an array of all zeros. When I applied the forward transformations from Step 1, the hippocampus completely disappeared! Thinking it might be my choice of interpolation that was the problem, I consulted my advisor who wisely suggested nearest neighbor interpolation. This makes sense because I don't want anything other than 0s and 1s in my transformed binary hippocampus segmentation, but unfortunately this wasn't the problem. Step 2 was still telling me my target brain did not have a hippocampus.


antsImage objects are S4 class objects, and fortunately when you type the name of an antsImage object it prints out some useful summary information which includes the origin. For more information about the NIFTI file format, check out this page. For a detailed introduction to image spaces and orientations, I really like this page (example code is in python).



Please reload

Recent Posts

May 20, 2016

Please reload

Search By Tags
Please reload

Share This Post

© 2016 Kristin Linn