]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Tue, 30 Aug 2011 08:03:42 +0000 (10:03 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Tue, 30 Aug 2011 08:03:42 +0000 (10:03 +0200)
32 files changed:
registration/clitkBLUTDIRGenericFilter.cxx
registration/clitkBLUTDIRGenericFilter.h
registration/clitkBSplineDeformableTransform.h
registration/clitkBSplineDeformableTransform.txx
registration/clitkConvertBSplineDeformableTransformToVFGenericFilter.cxx
registration/clitkConvertBSplineDeformableTransformToVFGenericFilter.h
registration/clitkCorrelationRatioImageToImageMetric.txx
registration/clitkDeformationFieldTransform.h
registration/clitkDeformationFieldTransform.txx
registration/clitkDemonsDeformableRegistrationGenericFilter.txx
registration/clitkMatrixTransformToVFGenericFilter.h
registration/clitkMatrixTransformToVFGenericFilter.txx
registration/clitkMultiResolutionPDEDeformableRegistration.txx
registration/clitkMultipleBSplineDeformableTransform.h
registration/clitkMultipleBSplineDeformableTransform.txx
registration/clitkNormalizedCorrelationImageToImageMetric.txx
registration/clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx
registration/clitkPointListTransform.h
registration/clitkPointListTransform.txx
registration/clitkShapedBLUTSpatioTemporalDIRGenericFilter.txx
registration/clitkShapedBLUTSpatioTemporalDeformableTransform.h
registration/clitkShapedBLUTSpatioTemporalDeformableTransform.txx
registration/itkMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx
registration/itkMeanSquaresImageToImageMetricFor3DBLUTFFD.txx
tools/clitkBSplineCoefficientsToValuesGenericFilter.h
tools/clitkBSplineCoefficientsToValuesGenericFilter.txx
tools/clitkInvertVFGenericFilter.h
tools/clitkInvertVFGenericFilter.txx
tools/clitkJacobianImageGenericFilter.h
tools/clitkWarpImageGenericFilter.txx
vv/vvImageWarp.cxx
vv/vvMidPosition.cxx

index 15afacf1b475b6f734bee22854a01dc6d6625ae8..0822bd9f3f0c434325d4995ed711d8e3e6133ba3 100644 (file)
@@ -747,21 +747,25 @@ namespace clitk
       // Compute the DVF (only deformable transform)
       //=======================================================
       typedef itk::Vector< float, SpaceDimension >  DisplacementType;
-      typedef itk::Image< DisplacementType, InputImageType::ImageDimension >  DeformationFieldType;
-      typedef itk::TransformToDeformationFieldSource<DeformationFieldType, double> ConvertorType;
+      typedef itk::Image< DisplacementType, InputImageType::ImageDimension >  DisplacementFieldType;
+#if ITK_VERSION_MAJOR >= 4
+      typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
+#else
+      typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
+#endif
       typename ConvertorType::Pointer filter= ConvertorType::New();
       filter->SetNumberOfThreads(1);
       transform->SetBulkTransform(NULL);
       filter->SetTransform(transform);
       filter->SetOutputParametersFromImage(fixedImage);
       filter->Update();
-      typename DeformationFieldType::Pointer field = filter->GetOutput();
+      typename DisplacementFieldType::Pointer field = filter->GetOutput();
 
 
       //=======================================================
       // Write the DVF
       //=======================================================
-      typedef itk::ImageFileWriter< DeformationFieldType >  FieldWriterType;
+      typedef itk::ImageFileWriter< DisplacementFieldType >  FieldWriterType;
       typename FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
       fieldWriter->SetFileName( m_ArgsInfo.vf_arg );
       fieldWriter->SetInput( field );
index d867caababdff328074dc460770638c9368fc270..eda242f5b4d7d843a91cb2809dbbe319536d06db 100644 (file)
 #include "itkLabelGeometryImageFilter.h"
 #include "itkImageDuplicator.h"
 #include "itkExtractImageFilter.h"
-#include "itkTransformToDeformationFieldSource.h"
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkTransformToDisplacementFieldSource.h"
+#else
+  #include "itkTransformToDeformationFieldSource.h"
+#endif
 
 namespace clitk
 {
index 5a084c9d841c2a3ffec678936666c41d1f0d9772..bab7f8c78257206b4d060b557211235d89b2217d 100644 (file)
@@ -254,7 +254,15 @@ namespace clitk
     } 
     
     /** Compute the Jacobian Matrix of the transformation at one point */
+#if ITK_VERSION_MAJOR >= 4
+    virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const;
+    virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented for " << this->GetNameOfClass() );
+    }
+#else
     virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
+#endif
 
     /** Return the number of parameters that completely define the Transfom */
     virtual unsigned int GetNumberOfParameters(void) const;
@@ -363,6 +371,9 @@ namespace clitk
 
     // VD Add MultipleBSplineDeformableTransform as friend to facilitate wrapping
     friend class MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>;
+#if ITK_VERSION_MAJOR >= 4
+    mutable JacobianType                            m_SharedDataBSplineJacobian;
+#endif
 
   }; //class BSplineDeformableTransform
 
index db47430b5a82ab339d4103558a29d923bce7d6c8..1a2dfd3ccab98b4e60deef7e064edf18de99a474 100644 (file)
@@ -32,7 +32,11 @@ namespace clitk
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  ::BSplineDeformableTransform():Superclass(0)
+#else
   ::BSplineDeformableTransform():Superclass(OutputDimension,0)
+#endif
   {
     unsigned int i;
     
@@ -576,10 +580,18 @@ namespace clitk
     m_CoefficientImage = m_WrappedImage;
     
     //JV Wrap jacobian into OutputDimension X Vectorial images
+#if ITK_VERSION_MAJOR >= 4
+    this->m_SharedDataBSplineJacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
+#else
     this->m_Jacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
+#endif
 
     // Use memset to set the memory
+#if ITK_VERSION_MAJOR >= 4
+    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
+#else
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
+#endif
     memset(jacobianDataPointer, 0,  OutputDimension*numberOfPixels*sizeof(JacobianPixelType));
     m_LastJacobianIndex = m_ValidRegion.GetIndex();
     m_NeedResetJacobian = false;
@@ -904,6 +916,69 @@ namespace clitk
 
   // JV weights are identical as for transformpoint, could be done simultaneously in metric!!!!
   // Compute the Jacobian in one position 
+#if ITK_VERSION_MAJOR >= 4
+  template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
+  void
+  BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+  ::ComputeJacobianWithRespectToParameters(const InputPointType & point, JacobianType & jacobian) const
+  {
+    if (m_NeedResetJacobian)
+      ResetJacobian();
+
+    //========================================================
+    // For each dimension, copy the weight to the support region
+    //========================================================
+
+    // Check if inside mask
+    if (m_Mask &&  !(m_Mask->IsInside(point) ) )
+      {
+       // Outside: no (deformable) displacement
+        jacobian = m_SharedDataBSplineJacobian;
+       return;
+      }
+
+    //Get index
+    this->TransformPointToContinuousIndex( point, m_Index );
+
+    // NOTE: if the support region does not lie totally within the grid
+    // we assume zero displacement and return the input point
+    if ( !this->InsideValidRegion( m_Index ) )
+      {
+        jacobian = m_SharedDataBSplineJacobian;
+       return;
+      }
+
+    //Compute interpolation weights
+    const WeightsDataType *weights = NULL;
+    m_VectorInterpolator->EvaluateWeightsAtContinuousIndex( m_Index, &weights, m_LastJacobianIndex);
+    m_SupportRegion.SetIndex( m_LastJacobianIndex );
+
+    //Reset the iterators
+    unsigned int j = 0;
+    for ( j = 0; j < OutputDimension; j++ )
+      m_Iterator[j] = IteratorType( m_JacobianImage[j], m_SupportRegion);
+
+    // For each dimension, copy the weight to the support region
+    while ( ! (m_Iterator[0]).IsAtEnd() )
+      {
+       //copy weight to jacobian image
+       for ( j = 0; j < OutputDimension; j++ )
+         {
+           m_ZeroVector[j]=*weights;
+           (m_Iterator[j]).Set( m_ZeroVector);
+           m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
+           ++(m_Iterator[j]);
+         }
+       // go to next coefficient in the support region
+       weights++;
+      }
+    m_NeedResetJacobian = true;
+
+    // Return the result
+    jacobian = m_SharedDataBSplineJacobian;
+
+  }
+#else
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   const 
   typename BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
@@ -972,6 +1047,7 @@ namespace clitk
     return this->m_Jacobian;
 
   }
+#endif
 
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
index 261a9d8ac092fadd8786298a6e0fea3a675138dc..169de13db8d6fffe219c18b04adb3b3be160baab 100644 (file)
@@ -80,7 +80,11 @@ namespace clitk
     // -----------------------------------------------
     // Filter
     // -----------------------------------------------
+#if ITK_VERSION_MAJOR >= 4
+    typedef itk::TransformToDisplacementFieldSource<OutputImageType, double> ConvertorType;
+#else
     typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
+#endif
     ConvertorType::Pointer filter= ConvertorType::New();
 
     //Output image info
index e976f642a2039635856c1af7d4ed79370515ee9a..bcdf67ba43670a1b2b3efa0ca63f264d39ceb29e 100644 (file)
 //itk include
 #include "itkLightObject.h"
 #include "itkImageMaskSpatialObject.h"
-#include "itkTransformToDeformationFieldSource.h"
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkTransformToDisplacementFieldSource.h"
+#else
+  #include "itkTransformToDeformationFieldSource.h"
+#endif
 
 
 namespace clitk 
index e7133ca69da81d03113c216b952f4ffc6b1a829c..aac2a786560e270580faafdee5155b488b327fde 100644 (file)
@@ -266,8 +266,13 @@ CorrelationRatioImageToImageMetric<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint , jacobian);
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
+#endif
 
 
       const RealType fixedValue     = ti.Value();
@@ -384,8 +389,13 @@ CorrelationRatioImageToImageMetric<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+        this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
+#endif
 
 
       const RealType fixedValue     = ti.Value();
index dd289591fb05e62ad496776eb07f118cdcc3c72f..06c528855cdd8fb4ec09b24b8a97c164e8c9614d 100644 (file)
@@ -109,11 +109,22 @@ namespace clitk
       return OutputCovariantVectorType();
     }
 
+#if ITK_VERSION_MAJOR >= 4
+    virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( << "DeformationFieldTransform doesn't declare ComputeJacobianWithRespectToParameters" );
+    }
+    virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( << "DeformationFieldTransform doesn't declare ComputeJacobianWithRespectToPosition" );
+    }
+#else
     virtual const JacobianType& GetJacobian(const InputPointType  &point ) const
     {
       itkExceptionMacro( << "DeformationFieldTransform doesn't declare GetJacobian" );
       return this->m_Jacobian;
     }
+#endif
 
   protected:
     DeformationFieldTransform();
index e8349a6569258262e5677b924826b5fc8e663f36..049f270bd25a5ebc797646ba1135b891d04cefdf 100644 (file)
@@ -26,7 +26,11 @@ namespace clitk
   // Constructor
   template<class TScalarType, unsigned int InputDimension, unsigned int OutputDimension, unsigned int SpaceDimension>
   DeformationFieldTransform<TScalarType, InputDimension, OutputDimension, SpaceDimension>
+#if ITK_VERSION_MAJOR >= 4
+  ::DeformationFieldTransform():Superclass(1)
+#else
   ::DeformationFieldTransform():Superclass(OutputDimension,1)
+#endif
   {
      m_DeformationField=NULL;
      m_Interpolator=DefaultInterpolatorType::New();
index 90d5319717de2c7bcaf281599cf44104875a1e61..6132dc5897ae115d57fd9117e93cfd954a024307 100644 (file)
@@ -151,8 +151,12 @@ namespace clitk
     //find the multiresolution filter
     //     typedef typename  RegistrationFilterType::FixedImageType InternalImageType;
     //     typedef typename  RegistrationFilterType::MovingImageType MovingImageType;
-    typedef typename  RegistrationFilterType::DeformationFieldType DeformationFieldType;
-    typedef clitk::MultiResolutionPDEDeformableRegistration<FixedImageType, MovingImageType, DeformationFieldType> MultiResolutionRegistrationType; 
+#if ITK_VERSION_MAJOR >= 4
+    typedef typename  RegistrationFilterType::DisplacementFieldType DisplacementFieldType;
+#else
+    typedef typename  RegistrationFilterType::DeformationFieldType DisplacementFieldType;
+#endif
+    typedef clitk::MultiResolutionPDEDeformableRegistration<FixedImageType, MovingImageType, DisplacementFieldType> MultiResolutionRegistrationType;
     typedef CommandResolutionLevelUpdate<MultiResolutionRegistrationType> LevelObserver;
     
   protected:
@@ -533,7 +537,11 @@ namespace clitk
     //JV TODO
     // pdeFilter->SetMaximumError(m_ArgsInfo.maxError_arg);
     // pdeFilter->SetMaximumKernelWidth(m_ArgsInfo.maxError_arg);
+#if ITK_VERSION_MAJOR >= 4
+    pdeFilter->SetSmoothDisplacementField(!m_ArgsInfo.fluid_flag);
+#else
     pdeFilter->SetSmoothDeformationField(!m_ArgsInfo.fluid_flag);
+#endif
     pdeFilter->SetSmoothUpdateField(m_ArgsInfo.fluid_flag);
     pdeFilter->SetUseImageSpacing( m_ArgsInfo.spacing_flag );
 
@@ -599,7 +607,11 @@ namespace clitk
     typedef itk::WarpImageFilter< MovingImageType, FixedImageType, DeformationFieldType >    WarpFilterType;
     typename WarpFilterType::Pointer warp = WarpFilterType::New();
 
+#if ITK_VERSION_MAJOR >= 4
+    warp->SetDisplacementField( deformationField );
+#else
     warp->SetDeformationField( deformationField );
+#endif
     warp->SetInput( movingImageReader->GetOutput() );
     warp->SetOutputOrigin(  fixedImage->GetOrigin() );
     warp->SetOutputSpacing( fixedImage->GetSpacing() );
index 34648cb928e7035329a764b79c9f4b5ed8f67adc..717e938a4b667b86dfaebc3eea570d578789e222 100644 (file)
 
 //itk include
 #include "itkLightObject.h"
-#include "itkTransformToDeformationFieldSource.h"
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkTransformToDisplacementFieldSource.h"
+#else
+  #include "itkTransformToDeformationFieldSource.h"
+#endif
 #include "itkAffineTransform.h"
 
 namespace clitk 
index 0540a134a12018a2935b6977435cba68fbe47596..ebc0e45c3ba6ba0beaf9d30dd05b5a954444ebad 100644 (file)
@@ -78,7 +78,11 @@ namespace clitk
     typedef itk::Image<Displacement, Dimension> OutputImageType;
     
     // Filter
+#if ITK_VERSION_MAJOR >= 4
+    typedef itk::TransformToDisplacementFieldSource<OutputImageType, double> ConvertorType;
+#else
     typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
+#endif
     typename   ConvertorType::Pointer filter= ConvertorType::New();
 
     // Output image info
index a10942c1db04dbc1c150d9d6ad66c4159c0b683f..5c6b0aeaf55c38e2e3361f2d683a15a4c7d1b927 100644 (file)
@@ -335,7 +335,11 @@ MultiResolutionPDEDeformableRegistration<TFixedImage,TMovingImage,TDeformationFi
       
       if( tempField.IsNull() )
        {
+#if ITK_VERSION_MAJOR >= 4
+         m_RegistrationFilter->SetInitialDisplacementField( NULL );
+#else
          m_RegistrationFilter->SetInitialDeformationField( NULL );
+#endif
        }
       else
        {
@@ -357,7 +361,11 @@ MultiResolutionPDEDeformableRegistration<TFixedImage,TMovingImage,TDeformationFi
       tempField = m_FieldExpander->GetOutput();
       tempField->DisconnectPipeline();
 
+#if ITK_VERSION_MAJOR >= 4
+      m_RegistrationFilter->SetInitialDisplacementField( tempField );
+#else
       m_RegistrationFilter->SetInitialDeformationField( tempField );
+#endif
 
       }
 
index 3e8dc3a5b0afca8b2aadcaa508ce47a0a32cab98..09f008faa65ffe3f04d560038ce87770ff74c3ce 100644 (file)
@@ -213,7 +213,15 @@ namespace clitk
     }
 
     /** Compute the Jacobian Matrix of the transformation at one point */
+#if ITK_VERSION_MAJOR >= 4
+    virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const;
+    virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented for " << this->GetNameOfClass() );
+    }
+#else
     virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
+#endif
 
     /** Return the number of parameters that completely define the Transfom */
     virtual unsigned int GetNumberOfParameters(void) const;
@@ -261,6 +269,9 @@ namespace clitk
     std::vector<ParametersType>                     m_parameters;
     mutable std::vector<CoefficientImagePointer>    m_CoefficientImages;
     mutable int                                     m_LastJacobian;
+#if ITK_VERSION_MAJOR >= 4
+    mutable JacobianType                            m_SharedDataBSplineJacobian;
+#endif
 
     void InitJacobian();
     // FIXME it seems not used
index 0ec20aa2bdf29398a97a267b81cf21d6dd800f46..32ebced48447e08923ce6baefec63dbdb4253716 100644 (file)
@@ -29,7 +29,11 @@ namespace clitk
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  ::MultipleBSplineDeformableTransform() : Superclass(0)
+#else
   ::MultipleBSplineDeformableTransform() : Superclass(OutputDimension, 0)
+#endif
   {
     m_nLabels = 1;
     m_labels = 0;
@@ -425,15 +429,38 @@ namespace clitk
     return m_trans[lidx]->DeformablyTransformPoint(inputPoint);
   }
 
+#if ITK_VERSION_MAJOR >= 4
+  template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
+  inline void
+  MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+  ::ComputeJacobianWithRespectToParameters (const InputPointType &point, JacobianType &jacobian) const
+  {
+    if (m_LastJacobian != -1)
+      m_trans[m_LastJacobian]->ResetJacobian();
+
+    int lidx = 0;
+    if (m_labels)
+      lidx = m_labelInterpolator->Evaluate(point) - 1;
+    if (lidx == -1)
+    {
+      m_LastJacobian = lidx;
+      jacobian = this->m_SharedDataBSplineJacobian;
+      return;
+    }
+
+    JacobianType unused;
+    m_trans[lidx]->ComputeJacobianWithRespectToParameters(point, unused);
+    m_LastJacobian = lidx;
+
+    jacobian = this->m_SharedDataBSplineJacobian;
+  }
+
+#else
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   inline const typename MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::JacobianType &
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetJacobian( const InputPointType & point ) const
   {
-    /*
-    for (unsigned i = 0; i < m_nLabels; ++i)
-      m_trans[i]->ResetJacobian();
-      */
     if (m_LastJacobian != -1)
       m_trans[m_LastJacobian]->ResetJacobian();
 
@@ -451,6 +478,7 @@ namespace clitk
 
     return this->m_Jacobian;
   }
+#endif
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   inline void
@@ -465,8 +493,13 @@ namespace clitk
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions,NOutputDimensions>::InitJacobian()
   {
     unsigned numberOfParameters = this->GetNumberOfParameters();
+#if ITK_VERSION_MAJOR >= 4
+    this->m_SharedDataBSplineJacobian.set_size(OutputDimension, numberOfParameters);
+    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
+#else
     this->m_Jacobian.set_size(OutputDimension, numberOfParameters);
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
+#endif
     memset(jacobianDataPointer, 0,  numberOfParameters * sizeof (JacobianPixelType));
 
     unsigned tot = 0;
index 3708f103ed8391866c17db471e6b0dac444603ae..342549ee72ea276bc0cde8610221b6052cf2d768 100644 (file)
@@ -251,8 +251,13 @@ NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
       const RealType fixedValue   = ti.Get();
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
+#endif
 
       // Get the gradient by NearestNeighboorInterpolation:
       // which is equivalent to round up the point components.
@@ -427,8 +432,13 @@ NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
       const RealType fixedValue     = ti.Get();
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
+#endif
 
       // Get the gradient by NearestNeighboorInterpolation:
       // which is equivalent to round up the point components.
index 511f97392259cdda3a4927e7909bab8ee9b8a18a..7290bd49fb1fb2cd3c701e12a7db24815503573b 100644 (file)
@@ -251,8 +251,13 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
       const RealType fixedValue   = ti.Get();
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
+#endif
 
       // Get the gradient by NearestNeighboorInterpolation:
       // which is equivalent to round up the point components.
@@ -427,8 +432,13 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
       const RealType fixedValue     = ti.Get();
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
+#endif
 
       // Get the gradient by NearestNeighboorInterpolation:
       // which is equivalent to round up the point components.
index 9fbd7d21a6690cca49be5df435e88d1e13db7baa..d98c525d6abd3c114454c6e4fccba22dfeec968e 100644 (file)
@@ -117,11 +117,22 @@ namespace clitk
       return OutputCovariantVectorType();
     }
 
+#if ITK_VERSION_MAJOR >= 4
+    virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( << "PointListTransform doesn't declare ComputeJacobianWithRespectToParameters" );
+    }
+    virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( << "PointListTransform doesn't declare ComputeJacobianWithRespectToPosition" );
+    }
+#else
     virtual const JacobianType& GetJacobian(const InputPointType  &point ) const
     {
       itkExceptionMacro( << "PointListTransform doesn't declare GetJacobian" );
       return this->m_Jacobian;
     }
+#endif
 
   protected:
     PointListTransform();
index 7a7808a2c9f7051798ddef55014886cbbf7fd9b7..a93a309b589284139d8154b33e5d2c97796674d2 100644 (file)
@@ -26,7 +26,11 @@ namespace clitk
   // Constructor
   template<class TScalarType, unsigned int NDimensions, unsigned int NOutputDimensions>
   PointListTransform<TScalarType, NDimensions, NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  ::PointListTransform():Superclass(1)
+#else
   ::PointListTransform():Superclass(NOutputDimensions,1)
+#endif
   {
     m_PointLists.resize(0);
     m_PointList.resize(1);
index 5434b228f470c0ba02ae2efe8aca47d43ce9e1f8..963fb7811cbc5f0d24d5298c6478ec01aac4d218 100644 (file)
@@ -819,7 +819,11 @@ namespace clitk
     typedef itk::WarpImageFilter< MovingImageType, FixedImageType, DeformationField4DType >    WarpFilterType;
     typename WarpFilterType::Pointer warp = WarpFilterType::New();
 
+#if ITK_VERSION_MAJOR >= 4
+    warp->SetDisplacementField( field4D );
+#else
     warp->SetDeformationField( field4D );
+#endif
     warp->SetInput( movingImageReader->GetOutput() );
     warp->SetOutputOrigin(  fixedImage->GetOrigin() );
     warp->SetOutputSpacing( fixedImage->GetSpacing() );
index 835123c34d9e78a38a826a677a3c8977d8156f5b..f3071b136c39433e2738063a646b268eadb5bc56 100644 (file)
@@ -263,7 +263,15 @@ namespace clitk
     } 
     
     /** Compute the Jacobian Matrix of the transformation at one point */
+#if ITK_VERSION_MAJOR >= 4
+    virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const;
+    virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
+    {
+      itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented for " << this->GetNameOfClass() );
+    }
+#else
     virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
+#endif
 
     /** Return the number of parameters that completely define the Transfom */
     virtual unsigned int GetNumberOfParameters(void) const;
@@ -430,6 +438,9 @@ namespace clitk
     // JV Shape
     unsigned int m_TransformShape;
 
+#if ITK_VERSION_MAJOR >= 4
+    mutable JacobianType                            m_SharedDataBSplineJacobian;
+#endif
 
   }; //class ShapedBLUTSpatioTemporalDeformableTransform
 
index ea50aa4d2d27b60918f42fada57225143f4cae4c..cebdb5bae492ec753a7e0e247bf9cf52aa70777b 100644 (file)
@@ -32,7 +32,11 @@ namespace clitk
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  ::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(0)
+#else
   ::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(OutputDimension,0)
+#endif
   {
     unsigned int i;
     
@@ -802,11 +806,19 @@ namespace clitk
     //=====================================
     //JV Wrap jacobian into OutputDimension X Vectorial images
     //=====================================
+#if ITK_VERSION_MAJOR >= 4
+    this->m_SharedDataBSplineJacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
+#else
     this->m_Jacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
+#endif
 
     // Use memset to set the memory
     // JV four rows of three comps of parameters
+#if ITK_VERSION_MAJOR >= 4
+    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
+#else
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
+#endif
     memset(jacobianDataPointer, 0,  OutputDimension*numberOfPixels*sizeof(JacobianPixelType));
 
     for (unsigned int j=0; j<OutputDimension; j++)
@@ -2375,11 +2387,17 @@ namespace clitk
   // JV weights are identical as for transformpoint, could be done simultaneously in metric!!!!
   // Compute the Jacobian in one position 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
+#if ITK_VERSION_MAJOR >= 4
+  void
+  ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
+  ::ComputeJacobianWithRespectToParameters( const InputPointType & point, JacobianType & jacobian) const
+#else
   const 
   typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::JacobianType & 
   ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetJacobian( const InputPointType & point ) const
+#endif
   {
   
     //========================================================
@@ -2475,7 +2493,12 @@ namespace clitk
     if(m_Mask &&  !(m_Mask->IsInside(point) ) )
       {
        // Outside: no (deformable) displacement
+#if ITK_VERSION_MAJOR >= 4
+        jacobian = m_SharedDataBSplineJacobian;
+        return;
+#else
        return this->m_Jacobian;
+#endif
       }        
 
     // Get index   
@@ -2485,7 +2508,12 @@ namespace clitk
     // we assume zero displacement and return the input point
     if ( !this->InsideValidRegion( m_Index ) )
       {
+#if ITK_VERSION_MAJOR >= 4
+        jacobian = m_SharedDataBSplineJacobian;
+        return;
+#else
        return this->m_Jacobian;
+#endif
       }
 
     // Compute interpolation weights
@@ -2653,7 +2681,11 @@ namespace clitk
       }
 
     // Return the result
+#if ITK_VERSION_MAJOR >= 4
+    jacobian = m_SharedDataBSplineJacobian;
+#else
     return this->m_Jacobian;
+#endif
   }
 
  
index 852583b8373c52a804e9e007b329bf07edd6c645..1b38cae012c10569ca6d8add8bcf8ab490d6fb0c 100644 (file)
@@ -1445,9 +1445,13 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
     // Compute the transform Jacobian.
     typedef typename TransformType::JacobianType JacobianType;
-    const JacobianType& jacobian =
-      this->m_Transform->GetJacobian(
-        m_FixedImageSamples[sampleNumber].FixedImagePointValue );
+#if ITK_VERSION_MAJOR >= 4
+      JacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( m_FixedImageSamples[sampleNumber].FixedImagePointValue, jacobian );
+#else
+      const JacobianType & jacobian =
+        this->m_Transform->GetJacobian( m_FixedImageSamples[sampleNumber].FixedImagePointValue );
+#endif
 
     for ( unsigned int mu = 0; mu < m_NumberOfParameters; mu++ ) {
       double innerProduct = 0.0;
@@ -1480,8 +1484,13 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
       weights = m_BSplineTransformWeightsArray[sampleNumber];
       indices = m_BSplineTransformIndicesArray[sampleNumber];
     } else {
+#if ITK_VERSION_MAJOR >= 4
+      m_BSplineTransform->ComputeJacobianFromBSplineWeightsWithRespectToPosition(
+        m_FixedImageSamples[sampleNumber].FixedImagePointValue, m_Weights, m_Indices );
+#else
       m_BSplineTransform->GetJacobian(
         m_FixedImageSamples[sampleNumber].FixedImagePointValue, m_Weights, m_Indices );
+#endif
     }
 
     for( unsigned int dim = 0; dim < FixedImageDimension; dim++ ) {
index 88a71c5a0060c2f82294cb64ad3ab3311d974792..ec4b7ba6ed9c738edd3c15cdb4912311e2e32a79 100644 (file)
@@ -197,9 +197,13 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
-
+#endif
 
       const RealType fixedValue     = ti.Value();
       this->m_NumberOfPixelsCounted++;
@@ -311,9 +315,13 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
+#if ITK_VERSION_MAJOR >= 4
+      TransformJacobianType jacobian;
+      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
+#else
       const TransformJacobianType & jacobian =
         this->m_Transform->GetJacobian( inputPoint );
-
+#endif
 
       const RealType fixedValue     = ti.Value();
       this->m_NumberOfPixelsCounted++;
index ff102320daf38582f1a15afe40881b4a65bfbd4c..184cc4f4374bfb51f68bfad91b12da166b3433ca 100644 (file)
 #include "itkBSplineResampleImageFunction.h"
 #include "clitkVectorBSplineResampleImageFunction.h"
 #include "itkAddImageFilter.h"
-#include "itkTransformToDeformationFieldSource.h"
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkTransformToDisplacementFieldSource.h"
+#else
+  #include "itkTransformToDeformationFieldSource.h"
+#endif
 
 namespace clitk 
 {
index a2156499773160bd62d6b430ac762688361ca22c..0111db24da506afa39a3bec1286af876104002df 100644 (file)
@@ -284,7 +284,11 @@ namespace clitk
     // Matrix Transform
     if(m_ArgsInfo.matrix_given)
       {
+#if ITK_VERSION_MAJOR >= 4
+       typedef itk::TransformToDisplacementFieldSource<OutputImageType, double> ConvertorType;
+#else
        typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
+#endif
        typename   ConvertorType::Pointer filter= ConvertorType::New();
        filter->SetOutputParametersFromImage(output);
        
index a3207984487684a769fcab7696af7ee5e7885b1d..012524c8fc266d817b9cda408cde4259def6d5d9 100644 (file)
 
 //itk include
 #include "itkLightObject.h"
-#include "itkInverseDeformationFieldImageFilter.h"
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkInverseDisplacementFieldImageFilter.h"
+#else
+  #include "itkInverseDeformationFieldImageFilter.h"
+#endif
 
 namespace clitk 
 {
index b9641fad1f376cf85d7b046f36f95e01958b734b..9835c2e739f64d3edd1af378e7955efc43059ba7 100644 (file)
@@ -148,7 +148,11 @@ InvertVFGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
 
   case 1: {
     // Create the InverseDeformationFieldFilter
+#if ITK_VERSION_MAJOR >= 4
+    typedef itk::InverseDisplacementFieldImageFilter<InputImageType,OutputImageType> FilterType;
+#else
     typedef itk::InverseDeformationFieldImageFilter<InputImageType,OutputImageType> FilterType;
+#endif
     typename FilterType::Pointer filter =FilterType::New();
     filter->SetInput(input);
     filter->SetOutputOrigin(input->GetOrigin());
index f54971952d01ca30dc262b2cc6378464e55143a5..73e9b64a289653e1d503706ae7cbfcd6592deb43 100644 (file)
 
 //itk include
 #include "itkLightObject.h"
-#include "itkInverseDeformationFieldImageFilter.h"
+#if ITK_VERSION_MAJOR >= 4
+  #include "itkInverseDisplacementFieldImageFilter.h"
+#else
+  #include "itkInverseDeformationFieldImageFilter.h"
+#endif
 
 namespace clitk 
 {
index 2ecc5d5dc0eabf20fc3a23c9f99974e1099fbf95..8544df2ba33bf859c827513c4219ac8e6301a42b 100644 (file)
@@ -192,7 +192,11 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     //Backward mapping
     typedef itk::WarpImageFilter<InputImageType, InputImageType, DeformationFieldType> BackwardWarpFilterType;
     typename BackwardWarpFilterType::Pointer backwardWarpFilter= BackwardWarpFilterType::New();
+#if ITK_VERSION_MAJOR >= 4
+    backwardWarpFilter->SetDisplacementField( deformationField );
+#else
     backwardWarpFilter->SetDeformationField( deformationField );
+#endif
     backwardWarpFilter->SetEdgePaddingValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
     backwardWarpFilter->SetOutputSpacing( deformationField->GetSpacing() );
     backwardWarpFilter->SetOutputOrigin( input->GetOrigin() );
index 1cfde1612b0ce77dacaf911b0d52dc9e584f4a8f..ff6580387a3c93aaef6c0af3a17c023f57a413d6 100644 (file)
@@ -101,7 +101,11 @@ void vvImageWarp::Update_WithDimAndPixelType()
     jacobian_filter->SetUseImageSpacingOn();
     vf_connector->SetInput(mVF->GetVTKImages()[num]);
     warp_filter->SetInput(input[num]);
+#if ITK_VERSION_MAJOR >= 4
+    warp_filter->SetDisplacementField(vf_connector->GetOutput());
+#else
     warp_filter->SetDeformationField(vf_connector->GetOutput());
+#endif
     jacobian_filter->SetInput(vf_connector->GetOutput());
     warp_filter->SetOutputSpacing(input[num]->GetSpacing());
     warp_filter->SetOutputOrigin(input[num]->GetOrigin());
index 88b176d360194d3406b462629225fde3be1f48f8..b4582e2275cb52ae8a59375329b537eda3fcfb11 100644 (file)
@@ -108,7 +108,11 @@ vvImage::Pointer WarpRefImage(OutputVFType::Pointer vf,vvImage::Pointer image,in
 
   typename FilterType::Pointer warp_filter = FilterType::New();
   warp_filter->SetInput(input);
+#if ITK_VERSION_MAJOR >= 4
+  warp_filter->SetDisplacementField(resampler->GetOutput());
+#else
   warp_filter->SetDeformationField(resampler->GetOutput());
+#endif
   warp_filter->SetOutputSpacing(input->GetSpacing());
   warp_filter->SetOutputOrigin(input->GetOrigin());
   warp_filter->SetOutputSize(input->GetLargestPossibleRegion().GetSize());