fsl convert_xfm
#!/bin/sh
# convert_xfm creates new flirt registration matrix files
# from existing ones.
# Concatenate 2 flirt registration matrices to make a 3rd:
convert_xfm -omat outmat_AtoC.mat -concat mat_BtoC.mat mat_AtoB.mat
#----------------------------------------
# Create the output (AtoB.mat) as the inverse
# of an existing matrix (BtoA.mat)
convert_xfm -omat AtoB.mat -inverse BtoA.mat