]> Creatis software - clitk.git/blobdiff - registration/clitkAffineRegistrationGenericFilter.cxx
Debug RTStruct conversion with empty struc
[clitk.git] / registration / clitkAffineRegistrationGenericFilter.cxx
index be0b296018510e9d9ddd34a3128e402ab549f9f0..2c94379e99e1f8411710e20e968b82c96b3467a5 100644 (file)
@@ -3,7 +3,7 @@
 
   Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
 
 #ifndef CLITKAFFINEREGISTRATIONGENERICFILTER_CXX
 #define CLITKAFFINEREGISTRATIONGENERICFILTER_CXX
 
 #include "clitkAffineRegistrationGenericFilter.h"
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageCommon.h"
+#include "clitkAffineRegistration_ggo.h"
+#include "clitkImageArithm_ggo.h"
+#include "clitkCorrelationRatioImageToImageMetric.h"
+#include "clitkTransformUtilities.h"
+#include "clitkGenericMetric.h"
+#include "clitkGenericOptimizer.h"
+#include "clitkGenericInterpolator.h"
+#include "clitkGenericAffineTransform.h"
+#include "clitkImageToImageGenericFilter.h"
+
+
+//itk include
+#include <itkMultiResolutionImageRegistrationMethod.h>
+#include <itkMultiResolutionPyramidImageFilter.h>
+#include <itkImageToImageMetric.h>
+#include <itkEuler2DTransform.h>
+#include <itkCenteredEuler3DTransform.h>
+#include <itkImage.h>
+#include <itkResampleImageFilter.h>
+#include <itkCastImageFilter.h>
+#include <itkNormalizeImageFilter.h>
+#include <itkDiscreteGaussianImageFilter.h>
+#include <itkImageMaskSpatialObject.h>
+#include <itkCommand.h>
+#include <itkCheckerBoardImageFilter.h>
+#include <itkSubtractImageFilter.h>
+#include <itkLightObject.h>
+#include <itkImageMomentsCalculator.h>
+#include <itkThresholdImageFilter.h>
+
+// other includes
+#include <time.h>
+#include <iostream>
+#include <iomanip>
+
 
 namespace clitk
 {
@@ -45,11 +84,11 @@ public:
   }
 
   // Execute
-  void Execute(itk::Object *caller, const itk::EventObject & event) {
+  void Execute(itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE {
     Execute( (const itk::Object *)caller, event);
   }
 
-  void Execute(const itk::Object * object, const itk::EventObject & event) {
+  void Execute(const itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE {
     if ( !(itk::IterationEvent().CheckEvent( &event )) ) {
       return;
     }
@@ -108,7 +147,7 @@ public:
   // Two arguments are passed to the Execute() method: the first
   // is the pointer to the object which invoked the event and the
   // second is the event that was invoked.
-  void Execute(itk::Object * object, const itk::EventObject & event) {
+  void Execute(itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE {
     if ( !(itk::IterationEvent().CheckEvent( &event )) ) {
       return;
     }
@@ -138,7 +177,7 @@ public:
     }
   }
 
-  void Execute(const itk::Object * , const itk::EventObject & ) {
+  void Execute(const itk::Object * , const itk::EventObject & ) ITK_OVERRIDE {
     return;
   }
 
@@ -175,11 +214,8 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   typedef typename  InputImageType::PixelType PixelType;
 //typedef typename InputImageType::ImageDimension Dimension;
 
-
-#ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
   bool threadsGiven=m_ArgsInfo.threads_given;
   int threads=m_ArgsInfo.threads_arg;
-#endif
 
   //Coordinate Representation
   typedef double TCoordRep;
@@ -324,7 +360,7 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   // If given, we connect a mask to reference or target
   //============================================================================
   typedef itk::ImageMaskSpatialObject<  InputImageType::ImageDimension >   MaskType;
-  typename MaskType::Pointer  fixedMask=NULL;
+  typename MaskType::Pointer  fixedMask=ITK_NULLPTR;
   if (m_ArgsInfo.referenceMask_given) {
     fixedMask= MaskType::New();
     typedef itk::Image< unsigned char, InputImageType::ImageDimension >   ImageMaskType;
@@ -345,7 +381,7 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   }
 
   typedef itk::ImageMaskSpatialObject<  InputImageType::ImageDimension >   MaskType;
-  typename MaskType::Pointer  movingMask=NULL;
+  typename MaskType::Pointer  movingMask=ITK_NULLPTR;
   if (m_ArgsInfo.targetMask_given) {
     movingMask= MaskType::New();
     typedef itk::Image< unsigned char, InputImageType::ImageDimension >   ImageMaskType;
@@ -396,11 +432,13 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   typename  MetricType::Pointer metric=genericMetric->GetMetricPointer();
   if (movingMask) metric->SetMovingImageMask(movingMask);
 
-#ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
-  if (threadsGiven) metric->SetNumberOfThreads( threads );
+  if (threadsGiven) {
+#if ITK_VERSION_MAJOR <= 4
+    metric->SetNumberOfThreads( threads );
 #else
-  if (m_Verbose) std::cout<<"Not setting the number of threads (not compiled with USE_OPTIMIZED_REGISTRATION_METHODS)..."<<std::endl;
+    metric->SetNumberOfWorkUnits( threads );
 #endif
+  }
 
   //============================================================================
   // Initialize using image moments.
@@ -541,7 +579,7 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   if (m_Verbose) std::cout << "Starting the registration now..." << std::endl;
 
   try {
-    registration->StartRegistration();
+    registration->Update();
   } catch ( itk::ExceptionObject & err ) {
     std::cerr << "ExceptionObject caught !" << std::endl;
     std::cerr << err << std::endl;