AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
April 11, 2014 01:03PM
I'm pretty sure someone had posted something like this before, but I can't seem to find it. In any case, here is a potential solution that takes advantage principally of the x,y,z variables in 3dcalc that are used to access the xyz positions in a dataset. The same method can be applied to linear or nonlinear transformations. Several afni programs also provide transformations of xyz coordinates, primarily with Vecwarp, but also consider the xyz transformation capabilities available for lists of coordinates in "whereami -calc_chain src dest -coord_file" and 3drotate.

# compute displacement from some transformation

# put xyz in voxels
3dcalc -a anat+orig -expr x -prefix anat_xorig
3dcalc -a anat+orig -expr y -prefix anat_yorig
3dcalc -a anat+orig -expr z -prefix anat_zorig

# transform xyz voxels to new location
3dAllineate -1Dmatrix_apply anat_al2tlrc_mat.aff12.1D -master anat_al2tlrc+tlrc. \
-prefix anat_xxform -final cubic anat_xorig+orig.
3dAllineate -1Dmatrix_apply anat_al2tlrc_mat.aff12.1D -master anat_al2tlrc+tlrc. \
-prefix anat_yxform -final cubic anat_yorig+orig.
3dAllineate -1Dmatrix_apply anat_al2tlrc_mat.aff12.1D -master anat_al2tlrc+tlrc. \
-prefix anat_zxform -final cubic anat_zorig+orig.

# calculate how far the original positions moved compared
# to the new xyz locations
3dcalc -a anat_xxform+tlrc. -expr 'a-x' -prefix anat_xdisp
3dcalc -a anat_yxform+tlrc. -expr 'a-y' -prefix anat_ydisp
3dcalc -a anat_zxform+tlrc. -expr 'a-z' -prefix anat_zdisp

# put it all together in one dataset for convenience
# dx,dy,dz are separate subbricks
3dbucket -prefix anat_xyzdisp anat_?disp+tlrc.HEAD

# make an RGB image of the displacement too combining into
# a single image
3dThreetoRGB -prefix anat_xyzdisp_rgb anat_?disp+tlrc.HEAD

# calculate the overall distance displaced
3dcalc -a anat_xdisp+tlrc. -b anat_ydisp+tlrc. -c anat_zdisp+tlrc. \
-expr 'sqrt(a^2+b^2+c^2)' -prefix anat_dist_disp
Subject Author Posted

displacement field from -1Dmatrix_apply

afribeiro April 10, 2014 06:21PM

Re: displacement field from -1Dmatrix_apply

Daniel Glen April 11, 2014 01:03PM