How to calculate 6 parameters (roll, pitch, yaw, tx, ty, tz) from the .aff12.1D transformation file from 3DVolReg?

Hi AFNI Team,

I've run 3dVolReg on a EPI dataset which has given me .aff12.1D transformation file, 6 parameters file, and a MD file. I'd like to understand how the 6 parameters are calculated from the .aff12.1D file. I'd also like to know the parameter names of the 12 parameters as per the aff12 file. It'd be great if someone can shed some light on this.

AFNI version info (afni -ver): 24.1.02

#3dvolreg #3dallineate

Hi-

Sure. It would help to probably see your 3dvolreg command, to see the options you are using in detail; I can guess at some.

Firstly, this AFNI Academy playlist on various aspects of alignment might be a useful reference. It includes videos on EPI-EPI alignment (covering a lot of 3dvolreg) and EPI-anatomical alignment (covering more about 3dAllineate).

The *.aff12.1D files store the 12 degrees of freedom (DFs) of a linear affine transform: there are nine numbers of the 3x3 rotation/shear/scale matrix and three numbers of 3x1 translation vector. This style of output (using 1Dmatrix_save .. in either 3dAllineate or 3dvolreg) does not have the individual rotation/shear/scale/translation parameters. It just has the matrix+vector elements. To store the individual parameters, one would use -1Dparam_save .. in 3dAllineate; in 3dvolreg, one would can just save the rigid body (6 DF) parameters individually, with -dfile .. or -1Dfile ...

In general, it is not supereasy/straightforward to decompose the 3x3 + 3x1 matrix+vector elements into shear/rotation/etc. parameters. Going from parameters to matrix elements is OK, for what it's worth. There is an option in cat_matvec to get the "rigid equivalent" matrix+vector transformation of the 12 DF affine, using -P:

  -P = Do a polar decomposition on the 3x3 matrix part 
       of the mfile. This would result in an orthogonal
       matrix (rotation only, no scaling) Q that is closest,
       in the Frobenius distance sense, to the input matrix A.
    Note: if A = R * S * E, where R, S and E are the Rotation,
       Scale, and shEar matrices, respctively, Q does not 
       necessarily equal R because of interaction; Each of R,
       S and E affects most of the columns in matrix A.

I'm not sure what a "MD" file is from 3dvolreg?

If you have 6 parameters in a file from 3dvolreg, I'm guessing you sued -1Dfile .., and the help describes the ordering and what each volume means:

...
                    roll  = rotation about the I-S axis }
                    pitch = rotation about the R-L axis } degrees CCW
                    yaw   = rotation about the A-P axis }
                      dS  = displacement in the Superior direction  }
                      dL  = displacement in the Left direction      } mm
                      dP  = displacement in the Posterior direction }
... 
       ** roll  = shaking head 'no' left-right
       ** pitch = nodding head 'yes' up-down
       ** yaw   = wobbling head sideways (ear toward shoulder)
...
  -1Dfile ename   Save the motion parameters ONLY in file 'ename'.
                    The output is in 6 ASCII formatted columns:

                    roll pitch yaw dS  dL  dP
...

--pt