I would like to use the combine the output of AFNI 3dVolReg (the .aff12.1D file) with other FSL and ANTs derived transformation in a single interpolation step. Does anyone know of a tool or script for converting AFNI transformations to FSL or ITK formats?

# Converting affine matrices from AFNI 3dVolReg to FSL or ITK/ANTs

From Bob Cox:

I have no idea about the other formats (FSL or ITK). However, I can tell you that AFNI transformation matrices are coordinate-based (not index-based), and

the coordinates are sign reversed in x and y from FSL — that is, AFNI uses DICOM order for xyz. So if you have an AFNI matrix

`[ a b c d ]`

T = [ e f g h ]

[ i j k l ]

[ 0 0 0 1 ] — this row is implicit, not in the file

then since x_FSL = [A] x_AFNI where

`[ -1 0 0 0 ]`

A = [ 0 -1 0 0 ]

[ 0 0 1 0 ]

[ 0 0 1 0 ] which is it’s own inverse, of course;

so the matrix that transforms x_FSL in the same way as T transforms x_AFNI is the matrix product T’ = [ A T A ], which is just

`[ a b -c -d ]`

T’ = [ e f -g -h ]

[ -i -j k l ]

[ 0 0 0 1 ]

**bartferguson**#3

Hi,

I would also like to use such a script - if it exists. Are the visitors of this thread also looking for something similar?

I’ve seen a 2011 email about the same posted on the AFNI mailing list: https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=fsl;81d877a8.1101

And again this year (2017): https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=fsl;49ee0deb.1704

It seems that the translation matrix needs to be converted from neurological (DICOM/ AFNI) to neuroimaging (FSL/SPM) by swapping the order in x and y, and corrected for where the origin is placed (therefore, this calculation is volume dependent).

BW