Notes:

ITK transforms are centered based and take one from mm to mm

AIR transforms appear to be center based and take one
from isotropic voxels to isotropic voxels

Here is what I expect to need:

Moving                                      Fixed
Result = S2 B+ Inv B-  Xfrm  A+ Inv A- S1   [orig]

BPlus=[1 0 0 0; 0 255/2*1.015625  0 0; 0 0 1 0; 0 0 0 1]
INV=[1 0 0 0; 0 -1 0 0; 0 0 0 1; 0 0 0 1]

Where:
  S1 is scaling from voxels to mm
  S2 is scalling from mm to voxels
  Inv is a conversion from right handed to left handed coordinate system (y axis)
  A- is a negative shift in fixed image space (y axis)
  A+ is a positive shift in fixed image space (y axis)

  B- is a negative shift in moving image space (y axis)
  B+ is a positive shift in moving image space (y axis)

There sould also be an additional V2 and V1 matrices at the two
ends of this equation that would map in the case of non-isotropic
in either the fixed or moving image. The current solution is a
multiplication of the air matrix to account for the non-istropic
voxels in the moving image, but it would be nicer to make this part
of our matrix multiplications.


Here is what seems to work but is off by less than a pixel in (x, y, and z)

Moving                                Fixed
Result =  B- Inv B+  Xfrm  A- Inv A+ [orig]


The result of this set of matrix multiplications is an affine
transformation with one rotation in the
opposite direction. The transpose of this matrix is used to correct this
issue.

The transform is then scaled to voxelDimension/pixel_size_r to
account for non-isotropic voxels.

Issues that are currently unresolved:
  1) slight shift in x, y, z
  2) why the conversion from voxel to mm is not needed


Ways to cheat and make this run fast for debugging

1. Run once and save the resulting transform using the the -otxfm option
2. Rerun all future cases with the -itxfm option


Standard parameters that seem to work well in general:
-n 5
-l 0.0001 0.00005 0.00001 0.000005 0.000001
-i 2500 2500 2500 2500 2500


1st Run
--------
export PathToRegressionTest=~/src/regressiontest
MutualRegistration -type ushort -s $PathToRegressionTest/SGI/MR/5x-B2/TEST/10_ACPC/14831300_10_T1_strict.img \
           -r $PathToRegressionTest/SGI/MR/5x-B2/TEST/31_003/T2_axial.img \
           -o test.img \
           -n 5 \
           -l 0.0001 0.00005 0.00001 0.000005 0.000001 \
           -i 2500 2500 2500 2500 2500 \
           -otxfm test.dat


Subsequent Runs
---------------
MutualRegistration -type ushort -s $PathToRegressionTest/SGI/MR/5x-B2/TEST/10_ACPC/14831300_10_T1_strict.img \
           -r $PathToRegressionTest/SGI/MR/5x-B2/TEST/31_003/T2_axial.img \
           -o test.img \
           -n 5 \
           -l 0.0001 0.00005 0.00001 0.000005 0.000001 \
           -i 2500 2500 2500 2500 2500 \
           -itxfm test.dat


By default it will save an air16 file called  temp.air16 in the present working directory
