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  

|
Daniel Glen
September 01, 2006 05:20PM
The second script is similar to the first except it rotates the gradient vectors based on rotations for each gradient volume in the corresponding dataset. In other words, the 3dvolreg or 3dWarpDrive was used to align the whole DWI dataset.

#!/bin/tcsh
# @rotatevectors
#
# rotate vectors from tensor.1D based on volume registered dataset, r1_vr+orig
#
# use the matrix vector rotation fields from the header attributes
# if 3dvolreg was used, they will be named VOLREG_MATVEC_nnnnnn
# if 3dWarpDrive was used, they will be named WARPDRIVE_MATVEC_FOR_nnnnnn


if ("$1" == '' || "$1" == '-help' || "$1" == '-h') then
goto HELP
endif

if ("$#" < 2) then
echo "Not enough parameters"
goto END
endif

set dset = $1
set tensor1D = $2
set ngrads = `3dnvals $dset`
@ ngrads = $ngrads - 1
echo "Dataset: $dset"
echo "Gradient vectors: $tensor1D"
echo "Rotating vectors..."
rm -f rotatedgrads.1D

foreach grad ( `count -digits 6 1 $ngrads`)
# put the matrix vector on three rows to be compatible with Vecwarp
( cat_matvec "$dset"'::VOLREG_MATVEC_'${grad} > tempmatvec.1D ) > & /dev/null
# replace the translation vector with 0s
1dcat tempmatvec.1D'[0..2]' '1D:3@0' > tempmatvec0.1D

# if there are no attributes from 3dvolreg in header, try 3dWarpDrive rotations
set check = `wc tempmatvec.1D`
if ($check[1] == 0) then
( cat_matvec "$dset"'::WARPDRIVE_ROTMAT_FOR_'${grad} > tempmatvec0.1D ) > & /dev/null
set check = `wc tempmatvec0.1D`
if ($check[1] == 0) then
echo "No rotation matrix in header"
goto END
endif
endif

# get the original vector for the current gradient
# (no zero row, so subtract 1)
@ gradrow = $grad - 1
1dcat "$tensor1D{$gradrow}" > tempvector.1D
# rotate the vector for the current gradient
Vecwarp -matvec tempmatvec0.1D -backward -input tempvector.1D -force -output temprotgrad.1D > & /dev/null
# |& tee > /dev/null
# append the rotated gradients to a single file
cat temprotgrad.1D >> rotatedgrads.1D
rm temprotgrad.1D
rm tempmatvec*.1D
rm tempvector.1D
end
echo "Output gradient vector file is rotatedgrads.1D"

goto END

HELP:
echo "Usage: `basename $0` volreg_dset gradients.1D"
echo "Rotate DTI gradient vectors based on rotations from volume registration"
echo "Current script assumes 3dvolreg or 3dWarpDrive corrected dataset with"
echo "preference to 3dvolreg rotation parameters"
echo "Output file is rotatedgrads.1D"
echo ""
echo "Daniel Glen SSCC/NIMH/NIH"
echo ""
goto END

END:
Subject Author Posted

Rotating gradient vectors for Diffusion Tensors

Sally Durgerian June 07, 2006 05:37PM

Re: Rotating gradient vectors for Diffusion Tensors

RWCox June 08, 2006 05:51AM

Re: Rotating gradient vectors for Diffusion Tensors

Sally Durgerian June 08, 2006 11:17AM

Re: Rotating gradient vectors for Diffusion Tensors

Daniel Glen June 09, 2006 11:52AM

Re: Rotating gradient vectors for Diffusion Tensors

Wolfgang June 14, 2006 07:11AM

Re: Rotating gradient vectors for Diffusion Tensors

tony August 02, 2006 01:55PM

Re: Rotating gradient vectors for Diffusion Tensors

Daniel Glen September 01, 2006 05:11PM

Re: Rotating gradient vectors for Diffusion Tensors

Wolfgang August 12, 2008 12:31PM

Re: Rotating gradient vectors for Diffusion Tensors

Megan February 11, 2009 07:11PM

Re: Rotating gradient vectors for Diffusion Tensors

Daniel Glen September 01, 2006 05:20PM

Re: Rotating gradient vectors for Diffusion Tensors

_durai_ June 19, 2014 12:00PM

Re: Rotating gradient vectors for Diffusion Tensors

Daniel Glen June 20, 2014 04:12PM

Re: Rotating gradient vectors for Diffusion Tensors

Lin October 28, 2011 08:54PM

Re: Rotating gradient vectors for Diffusion Tensors

Daniel Glen October 28, 2011 10:19PM

Re: Rotating gradient vectors for Diffusion Tensors

Lin October 28, 2011 11:28PM

Re: Rotating gradient vectors for Diffusion Tensors

Daniel Glen October 31, 2011 09:08AM