From cb709b3f6522b3a008836a353e6f62393f3fb751 Mon Sep 17 00:00:00 2001
From: srit <srit>
Date: Thu, 15 Jul 2010 13:22:00 +0000
Subject: [PATCH] Corrected bugs regarding the rigid case and the
 initialization.

---
 registration/clitkAffineRegistration.ggo            |  4 ++--
 .../clitkAffineRegistrationGenericFilter.txx        |  2 +-
 registration/clitkGenericAffineTransform.cxx        | 13 ++++++++-----
 registration/clitkGenericAffineTransform.h          |  4 ++--
 registration/clitkGenericAffineTransform.txx        |  2 +-
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/registration/clitkAffineRegistration.ggo b/registration/clitkAffineRegistration.ggo
index 6c9f439..6c26878 100644
--- a/registration/clitkAffineRegistration.ggo
+++ b/registration/clitkAffineRegistration.ggo
@@ -42,8 +42,8 @@ option "transform"  - "Type: 0=Identity, 1=Translation, 2=Rigid, 3=Affine" int n
 option "transX"     x "1-3: Initial translation in mm along the X axis"  float no  default="0.0"
 option "transY"     y "1-3: Initial translation in mm along the Y axis"  float no  default="0.0"
 option "transZ"     z "1-3: Initial translation in mm along the Z axis"  float no  default="0.0"
-option "initMatrix" - "2-3: Initial matrix (reference to object space) filename " string  no
-option "moment"     - "2-3: Initialize translation by aligning the center of gravities for the respective intensities" flag off
+option "initMatrix" - "1-3: Initial matrix (reference to object space) filename " string  no
+option "moment"     - "1-3: Initialize translation by aligning the center of gravities for the respective intensities" flag off
 
 section "Metric (optimized, threaded versions are available for *, compile ITK with REVIEW and OPT_REGISTRATION enabled)"
 
diff --git a/registration/clitkAffineRegistrationGenericFilter.txx b/registration/clitkAffineRegistrationGenericFilter.txx
index 90fb6e4..2ece121 100644
--- a/registration/clitkAffineRegistrationGenericFilter.txx
+++ b/registration/clitkAffineRegistrationGenericFilter.txx
@@ -527,7 +527,7 @@ AffineRegistrationGenericFilter::UpdateWithDimAndPixelType()
       matrix[3][3] = 1.0;
     }
   } else {
-//    matrix = clitk::GetBackwardAffineMatrix3D(finalParameters);
+    matrix = clitk::GetBackwardAffineMatrix<Dimension>(finalParameters);
   }
 
   std::cout << " Affine transform matrix =" << std::endl;
diff --git a/registration/clitkGenericAffineTransform.cxx b/registration/clitkGenericAffineTransform.cxx
index f1db790..de53ebd 100644
--- a/registration/clitkGenericAffineTransform.cxx
+++ b/registration/clitkGenericAffineTransform.cxx
@@ -1,4 +1,4 @@
-/*=========================================================================
+ /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
   Authors belong to:
@@ -29,9 +29,10 @@ template<>
 itk::MatrixOffsetTransformBase<double, 2, 2>::Pointer
 clitk::GenericAffineTransform<args_info_clitkAffineRegistration, double, 2>::GetNewEulerTransform()
 {
-  itk::Euler2DTransform< double >::Pointer p = itk::Euler2DTransform< double >::New();
+  typedef itk::Euler2DTransform< double > Transform2DType;
+  Transform2DType::Pointer t2 = Transform2DType::New();
   itk::MatrixOffsetTransformBase<double, 2, 2>::Pointer pp;
-  pp = p;
+  pp = t2;
   return pp;
 }
 
@@ -40,9 +41,11 @@ template<>
 itk::MatrixOffsetTransformBase<double, 3, 3>::Pointer
 clitk::GenericAffineTransform<args_info_clitkAffineRegistration, double, 3>::GetNewEulerTransform()
 {
-  itk::Euler3DTransform< double >::Pointer p = itk::Euler3DTransform< double >::New();
+  typedef itk::Euler3DTransform < double > Transform3DType;
+  Transform3DType::Pointer t3 = Transform3DType::New();
+  t3->SetComputeZYX(true); //SR: required?
   itk::MatrixOffsetTransformBase<double, 3, 3>::Pointer pp;
-  pp = p;
+  pp = t3;
   return pp;
 }
 }
diff --git a/registration/clitkGenericAffineTransform.h b/registration/clitkGenericAffineTransform.h
index a403074..f565a5e 100644
--- a/registration/clitkGenericAffineTransform.h
+++ b/registration/clitkGenericAffineTransform.h
@@ -33,8 +33,8 @@ option "transform"  - "Type: 0=Identity, 1=Translation, 2=Rigid, 3=Affine" int n
 option "transX"     x "1-3: Initial translation in mm along the X axis"  float no  default="0.0"
 option "transY"     y "1-3: Initial translation in mm along the Y axis"  float no  default="0.0"
 option "transZ"     z "1-3: Initial translation in mm along the Z axis"  float no  default="0.0"
-option "initMatrix" - "2-3: Initial matrix (reference to object space) filename " string  no
-option "moment"     - "2-3: Initialize translation by aligning the center of gravities for the respective intensities" flag off
+option "initMatrix" - "1-3: Initial matrix (reference to object space) filename " string  no
+option "moment"     - "1-3: Initialize translation by aligning the center of gravities for the respective intensities" flag off
 
 The use will look something like
 
diff --git a/registration/clitkGenericAffineTransform.txx b/registration/clitkGenericAffineTransform.txx
index eb4c6f9..4b4b067 100644
--- a/registration/clitkGenericAffineTransform.txx
+++ b/registration/clitkGenericAffineTransform.txx
@@ -92,10 +92,10 @@ GenericAffineTransform<args_info_type, TCoordRep, Dimension>::GetTransform()
     tMatrix->SetCenter(center);
 
     //Initialize transform
+    tMatrix->SetOffset(offset);
     if(m_ArgsInfo.initMatrix_given) {
       itk::Matrix<double, Dimension+1 , Dimension+1> matHom = ReadMatrix<Dimension>(m_ArgsInfo.initMatrix_arg);
       typename MatrixXType::MatrixType matrix = GetRotationalPartMatrix(matHom);
-      tMatrix->SetOffset(offset);
       tMatrix->SetMatrix(matrix);
     }
     m_Transform=tMatrix;
-- 
2.49.0