3dvolreg will give you the translation (in mm) + rotation (in deg) parameters registering to a particular volume.
An example of running 3dvolreg from the AFNI Bootcamp demo (from the afni_proc.py command in AFNI_data6/FT_analysis/s05*) is approximately (using a tcsh syntax for defining a variable “$run”, which you certainly don’t need to use; note that the AFNI command is agnostic to shell, beyond syntax):
set run = 1
3dvolreg \
-verbose \
-zpad 1 \
-base REFERENCE_BASE_VOL \
-1Dfile dfile.r$run.1D -prefix rm.epi.volreg.r$run \
-cubic \
-1Dmatrix_save mat.r$run.vr.aff12.1D \
INPUT_TIMESERIES
… where you can specify which volume you want to be the base for registration by choosing an index [n], where n=0,1,…, N-1 for N total volumes. When running afni_proc.py, actually we usually recommend specifying the “minimum outlier volume”-- in your case, you can probably just pick “0” for your requirements, since you want framewise displacement, anyways.
The above command produces a set of motion corrected volumes “rm.epi.volreg.r$run”, and a 6-column file “dfile.r$run.1D” of the 3 translations and rotations, as noted above. I think by framewise displacement, you want the derivative of these, then-- the difference of the total motion estimate should give the differential between volumes?
That can be calculated with 1d_tool.py:
1d_tool.py -infile dfile.r${run}.1D -derivative -write fwd.r${run}.1D
so for i = 1,…, N-1, the [i]th value from the original matrix X = {X[i,j]} is X[i,j]-X[i-1,j].
Is that all you need for your calcs? If you wanted to sum across the absolute value of the 6 motion parameters per TR, then you could do this to dump the numbers to the screen or a text file:
3dTstat -abssum -prefix - fwd.r${run}.1D
3dTstat -abssum -prefix - fwd.r${run}.1D > fwd_abssum.1D
or, to save it in a variable
set mmm = ( `3dTstat -abssum -prefix - fwd.r${run}.1D` )
(please check the numbers that should actually be calculated…)
–pt