Warping a binary mask to standard space

Hi there,

I attempted to warp a binary mask to standard space using several afni commands and the results don;t look great. (A bunch of the labels become long decimals,especially and there are grainy outlines at the edges that shouldn’t be there). I believe the issue involves the fact that I am using a transformation matrix to warp a binary mask, and perhaps have chosen the wrong way to do this. (I have embedded images at the bottom of this message for reference). I’ve been able to achieve this well in ANTS, but would prefer to do it AFNI for consistency with my analysis.

I used auto_tlrc, cat matvec, and 3dAllineate (see below). Could you recommend a more appropriate way to achieve the binary mask (using the 2 mm MNI 152 template)?

# warp anatomical template in original space to MNI 2mm template
@auto_tlrc -base MNI152_T1_2mm_brain.nii.gz \
	 		-input Zach_Template_1point5+orig -no_ss \
	 		-init_xform AUTO_CENTER \

#store foward transformation in a text file
cat_matvec Zach_Template_1point5+tlrc::WARP_DATA -I > matrix_ZachToMNI.1D \

#align binary ROI mask (original space = Zach_Template_1point5) to MNI space using transformation matrix
3dAllineate -input Zach_ROIs+orig \
                -1Dmatrix_apply matrix_ZachToMNI.1D \
                -prefix Zach_ROIs_ToMNI \

Here are the images - for some reason they aren;t embedding but you should still be able to open the image url

Here is a picture of the ROIs in original space

And here are ROIs after I’ve aligned them to MNI

Thanks in advance!

In your 3dAllineate command, add -final NN. That should help.

 -final iii  = Defines the interpolation mode used to create the
               output dataset.  [Default == 'cubic']
            ** N.B.: If you are applying a transformation to an
                       integer-valued dataset (such as an atlas),
                       then you should use '-final NN' to avoid
                       interpolation of the integer labels.

Thank you that sounds perfect