]> Creatis software - clitk.git/blobdiff - registration/clitkBLUTDIRGenericFilter.cxx
Be sure Number of Frame of Rotation exists in dicom tags
[clitk.git] / registration / clitkBLUTDIRGenericFilter.cxx
index b49d9909639a88ae71874e1d12d3deabe8f99659..60cd30db0bc21024e3c187d642062be4b4bb88fe 100644 (file)
@@ -30,14 +30,11 @@ It is distributed under dual licence
 #include "clitkBLUTDIRGenericFilter.h"
 #include "clitkBLUTDIRCommandIterationUpdateDVF.h"
 #include "itkCenteredTransformInitializer.h"
-#if ITK_VERSION_MAJOR >= 4
-#  if ITK_VERSION_MINOR < 6
-#    include "itkTransformToDisplacementFieldSource.h"
-#  else
-#    include "itkTransformToDisplacementFieldFilter.h"
-#  endif
+#include "itkLabelStatisticsImageFilter.h"
+#if (ITK_VERSION_MAJOR == 4) && (ITK_VERSION_MINOR < 6)
+# include "itkTransformToDisplacementFieldSource.h"
 #else
-#  include "itkTransformToDeformationFieldSource.h"
+# include "itkTransformToDisplacementFieldFilter.h"
 #endif
 
 namespace clitk
@@ -377,11 +374,12 @@ namespace clitk
         fixedMask->SetImage(labels);
 
         // Find the bounding box of the "inside" label
-        typedef itk::LabelGeometryImageFilter<ImageLabelType> GeometryImageFilterType;
-        typename GeometryImageFilterType::Pointer geometryImageFilter=GeometryImageFilterType::New();
-        geometryImageFilter->SetInput(labels);
-        geometryImageFilter->Update();
-        typename GeometryImageFilterType::BoundingBoxType boundingBox = geometryImageFilter->GetBoundingBox(1);
+        typedef itk::LabelStatisticsImageFilter<ImageLabelType, ImageLabelType> StatisticsImageFilterType;
+        typename StatisticsImageFilterType::Pointer statisticsImageFilter=StatisticsImageFilterType::New();
+        statisticsImageFilter->SetInput(labels);
+        statisticsImageFilter->SetLabelInput(labels);
+        statisticsImageFilter->Update();
+        typename StatisticsImageFilterType::BoundingBoxType boundingBox = statisticsImageFilter->GetBoundingBox(1);
 
         // Limit the transform region to the mask
         for (unsigned int i=0; i<InputImageType::ImageDimension; i++)
@@ -396,9 +394,7 @@ namespace clitk
         // Crop the fixedImage to the bounding box to facilitate multi-resolution
         typedef itk::ExtractImageFilter<FixedImageType,FixedImageType> ExtractImageFilterType;
         typename ExtractImageFilterType::Pointer extractImageFilter=ExtractImageFilterType::New();
-#if ITK_VERSION_MAJOR == 4
         extractImageFilter->SetDirectionCollapseToSubmatrix();
-#endif
         extractImageFilter->SetInput(fixedImage);
         extractImageFilter->SetExtractionRegion(transformRegion);
         extractImageFilter->Update();
@@ -652,16 +648,10 @@ namespace clitk
       typedef itk::ImageToImageMetric< FixedImageType, MovingImageType >  MetricType;
       typename  MetricType::Pointer metric=genericMetric->GetMetricPointer();
       if (movingMask) metric->SetMovingImageMask(movingMask);
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
       if (threadsGiven) {
         metric->SetNumberOfThreads( threads );
         if (m_Verbose) std::cout<< "Using " << threads << " threads." << std::endl;
       }
-#else
-      if (m_Verbose) std::cout<<"Not setting the number of threads (not compiled with USE_OPTIMIZED_REGISTRATION_METHODS)..."<<std::endl;
-#endif
-
 
       //=======================================================
       // Optimizer
@@ -742,11 +732,7 @@ namespace clitk
 
       try
       {
-#if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
-        registration->StartRegistration();
-#else
         registration->Update();
-#endif
       }
       catch( itk::ExceptionObject & err )
       {
@@ -801,14 +787,10 @@ namespace clitk
       //=======================================================
       typedef itk::Vector< float, SpaceDimension >  DisplacementType;
       typedef itk::Image< DisplacementType, InputImageType::ImageDimension >  DisplacementFieldType;
-#if ITK_VERSION_MAJOR >= 4
-#  if ITK_VERSION_MINOR < 6
+#if (ITK_VERSION_MAJOR == 4) && (ITK_VERSION_MINOR < 6)
       typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
-#  else
-      typedef itk::TransformToDisplacementFieldFilter<DisplacementFieldType, double> ConvertorType;
-#  endif
 #else
-      typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
+      typedef itk::TransformToDisplacementFieldFilter<DisplacementFieldType, double> ConvertorType;
 #endif
       typename ConvertorType::Pointer filter= ConvertorType::New();
       filter->SetNumberOfThreads(1);