From a0cf5235691ab0e7416600ed29db5abf2ff8ffe2 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 2 Feb 2022 16:22:12 +0100 Subject: [PATCH] COMP: Upgrade ITK from v5.2.0 to v5.3rc03 Upgraded to ITK version 5.3 (RC03), which was tagged on 16 January 2022: https://github.com/InsightSoftwareConsortium/ITK/releases/tag/v5.3rc03 Including upgrade to C++14, and various performance improvements: https://github.com/InsightSoftwareConsortium/ITK/commit/6a8569ef11cf4f788eeb659b532156479309d7a7 Use the faster `TransformPhysicalPointToContinuousIndex` overload https://github.com/InsightSoftwareConsortium/ITK/commit/eb6ac88c8209ff6cfb3f280bb25e8388f236e211 Use the faster `TransformPhysicalPointToIndex` overload in filter https://github.com/InsightSoftwareConsortium/ITK/commit/0539a2c4ddd2b189d1e48eaf5294ce5556efe732 Remove protected `itk::Transform` data member `m_DirectionChange` https://github.com/InsightSoftwareConsortium/ITK/commit/eec9fe67056bfb5c693a4915b86eac9271e1dc83 Remove unnecessary `IdentityTransform::m_ZeroJacobian` https://github.com/InsightSoftwareConsortium/ITK/commit/9961ccd672cb67ab2128390a49748104eb4459b6 Use FastEvaluate in MattesMutualInformationImageToImageMetric + v4 https://github.com/InsightSoftwareConsortium/ITK/commit/974540982b2926ee6dc4f3933c07962ff74ac9a6 Use FixedArray for table within BSplineInterpolationWeightFunction https://github.com/InsightSoftwareConsortium/ITK/commit/c23944ba54205757c326e1520a4f43d83ac30c4e Remove BSplineInterpolationWeightFunction Kernel, use FastEvaluate https://github.com/InsightSoftwareConsortium/ITK/commit/bc7c5dff2d6a29815bce50cbe7fd8bb5476a4a2b Use FixedArray for BSplineBaseTransform ParameterIndexArrayType https://github.com/InsightSoftwareConsortium/ITK/commit/9bf745bda51044c90208c7b0776e87d7c86adb11 Use FixedArray for BSplineInterpolationWeightFunction OutputType https://github.com/InsightSoftwareConsortium/ITK/commit/c64a58d42a4543eaf1ba20bd1f4c95c7d9658c00 Make `ResampleImageFilter::LinearThreadedGenerateData` faster Follow-up to pull request https://github.com/SuperElastix/elastix/pull/475 commit 6803b26a73aea270cf7b75e0febc4d53ea21053e "COMP: Upgrade ITK from v5.1.1 to v5.2.0" (merged on 31 May 2021). Note: The last elastix git revision on the develop branch that still supported ITK 5.2 was tagged: "last-itk5.2-support" --- .github/workflows/ElastixGitHubActions.yml | 6 +-- CMakeLists.txt | 2 +- .../itkAdvancedBSplineDeformableTransform.hxx | 37 +++++-------- ...tkBSplineInterpolationWeightFunctionBase.h | 8 +-- .../itkCyclicBSplineDeformableTransform.hxx | 7 +-- .../itkRecursiveBSplineTransform.hxx | 52 ++++++------------- Testing/CI/Azure/ci.yml | 2 +- ...tkBSplineTransformPointPerformanceTest.cxx | 3 +- 8 files changed, 42 insertions(+), 75 deletions(-) diff --git a/.github/workflows/ElastixGitHubActions.yml b/.github/workflows/ElastixGitHubActions.yml index 0d3436b70..029743153 100644 --- a/.github/workflows/ElastixGitHubActions.yml +++ b/.github/workflows/ElastixGitHubActions.yml @@ -18,21 +18,21 @@ jobs: - os: ubuntu-18.04 c-compiler: "gcc" cxx-compiler: "g++" - itk-git-tag: "v5.2.0" + itk-git-tag: "v5.3rc03" cmake-build-type: "Release" ANNLib: "libANNlib-5.0.so" ANNLib2: "libANNlib-5.0.so.1" - os: windows-2019 c-compiler: "cl.exe" cxx-compiler: "cl.exe" - itk-git-tag: "v5.2.0" + itk-git-tag: "v5.3rc03" cmake-build-type: "Release" ANNLib: "ANNlib-5.0.dll" vcvars64: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" - os: macos-10.15 c-compiler: "clang" cxx-compiler: "clang++" - itk-git-tag: "v5.2.0" + itk-git-tag: "v5.3rc03" cmake-build-type: "Release" ANNLib: "libANNlib-5.0.1.dylib" ANNLib2: "libANNlib-5.0.dylib" diff --git a/CMakeLists.txt b/CMakeLists.txt index 651d796c4..28cc3093f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ if(ELASTIX_USE_OPENCL) endif() # Find ITK. -find_package( ITK 5.2.0 REQUIRED COMPONENTS +find_package( ITK 5.3 REQUIRED COMPONENTS ITKCommon ITKDisplacementField ITKDistanceMap diff --git a/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx b/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx index e793fc664..342c92233 100644 --- a/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx +++ b/Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx @@ -193,9 +193,8 @@ AdvancedBSplineDeformableTransform::Tran { /** Allocate memory on the stack: */ const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; typename ParameterIndexArrayType::ValueType indicesArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; ParameterIndexArrayType indices(indicesArray, numberOfWeights, false); OutputPointType outputPoint; @@ -352,9 +351,8 @@ AdvancedBSplineDeformableTransform::GetJ /** Compute the number of affected B-spline parameters. * Allocate memory on the stack. */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; /** Compute the weights. */ IndexType supportIndex; @@ -418,9 +416,8 @@ AdvancedBSplineDeformableTransform::Eval /** Compute the number of affected B-spline parameters. * Allocate memory on the stack. */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; /** Compute the B-spline derivative weights. */ IndexType supportIndex; @@ -475,9 +472,8 @@ AdvancedBSplineDeformableTransform::GetS /** Compute the number of affected B-spline parameters. */ /** Allocate memory on the stack: */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; /** Array for CoefficientImage values */ std::array coeffs; @@ -579,8 +575,7 @@ AdvancedBSplineDeformableTransform::GetS /** Helper variables. */ /** Allocate memory on the stack: */ const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - WeightsValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Array for CoefficientImage values */ std::array coeffs; @@ -702,9 +697,8 @@ AdvancedBSplineDeformableTransform::GetJ /** Helper variables. */ /** Allocate memory on the stack: */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; IndexType supportIndex; this->m_DerivativeWeightsFunctions[0]->ComputeStartIndex(cindex, supportIndex); @@ -806,8 +800,7 @@ AdvancedBSplineDeformableTransform::GetJ /** Allocate weight on the stack. */ using WeightsValueType = typename WeightsType::ValueType; const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - WeightsValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Allocate coefficients on the stack. */ std::array coeffs; @@ -957,9 +950,8 @@ AdvancedBSplineDeformableTransform::GetJ /** Compute the number of affected B-spline parameters. */ /** Allocate memory on the stack: */ - const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; + WeightsType weights; IndexType supportIndex; this->m_SODerivativeWeightsFunctions[0][0]->ComputeStartIndex(cindex, supportIndex); @@ -1082,8 +1074,7 @@ AdvancedBSplineDeformableTransform::GetJ /** Allocate weight on the stack. */ using WeightsValueType = typename WeightsType::ValueType; const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - WeightsValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; /** Allocate coefficients on the stack. */ std::array coeffs; diff --git a/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h b/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h index 157cd7524..8219a3566 100644 --- a/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h +++ b/Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h @@ -48,12 +48,14 @@ namespace itk */ template class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunctionBase - : public FunctionBase, Array> + : public FunctionBase, + FixedArray> { public: /** Standard class typedefs. */ using Self = BSplineInterpolationWeightFunctionBase; - using Superclass = FunctionBase, Array>; + using Superclass = FunctionBase, + FixedArray>; using Pointer = SmartPointer; using ConstPointer = SmartPointer; @@ -70,7 +72,7 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunctionBase static constexpr unsigned long NumberOfWeights = Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension); /** OutputType typedef support. */ - using WeightsType = Array; + using WeightsType = FixedArray; /** Index and size typedef support. */ using IndexType = Index; diff --git a/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx b/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx index e89ed4476..3af88feea 100644 --- a/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx +++ b/Common/Transforms/itkCyclicBSplineDeformableTransform.hxx @@ -141,9 +141,8 @@ CyclicBSplineDeformableTransform::Transf { /** Allocate memory on the stack: */ const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; typename ParameterIndexArrayType::ValueType indicesArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; ParameterIndexArrayType indices(indicesArray, numberOfWeights, false); OutputPointType outputPoint; @@ -319,9 +318,7 @@ CyclicBSplineDeformableTransform::GetSpa /** Compute the number of affected B-spline parameters. */ /** Allocate memory on the stack: */ - const SizeValueType numberOfWeights = WeightsFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray[numberOfWeights]; - WeightsType weights(weightsArray, numberOfWeights, false); + WeightsType weights; IndexType supportIndex; this->m_DerivativeWeightsFunctions[0]->ComputeStartIndex(cindex, supportIndex); diff --git a/Common/Transforms/itkRecursiveBSplineTransform.hxx b/Common/Transforms/itkRecursiveBSplineTransform.hxx index 3f6b02aee..1a2ff32ac 100644 --- a/Common/Transforms/itkRecursiveBSplineTransform.hxx +++ b/Common/Transforms/itkRecursiveBSplineTransform.hxx @@ -47,15 +47,11 @@ auto RecursiveBSplineTransform::TransformPoint(const InputPointType & point) const -> OutputPointType { - /** Define some constants. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - /** Initialize output point. */ OutputPointType outputPoint; /** Allocate weights on the stack: */ - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); + WeightsType weights1D; /** Check if the coefficient image has been set. */ if (!this->m_CoefficientImages[0]) @@ -151,10 +147,8 @@ RecursiveBSplineTransform::GetJacobian( * In contrast to the normal B-spline weights function, the recursive version * returns the individual weights instead of the multiplied ones. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - IndexType supportIndex; + WeightsType weights1D; + IndexType supportIndex; this->m_RecursiveBSplineWeightFunction->Evaluate(cindex, weights1D, supportIndex); /** Recursively compute the first numberOfIndices entries of the Jacobian. @@ -209,10 +203,8 @@ RecursiveBSplineTransform::EvaluateJacobianW * In contrast to the normal B-spline weights function, the recursive version * returns the individual weights instead of the multiplied ones. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - IndexType supportIndex; + WeightsType weights1D; + IndexType supportIndex; this->m_RecursiveBSplineWeightFunction->Evaluate(cindex, weights1D, supportIndex); /** Recursively compute the inner product of the Jacobian and the moving image gradient. @@ -262,11 +254,8 @@ RecursiveBSplineTransform::GetSpatialJacobia } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); @@ -349,13 +338,9 @@ RecursiveBSplineTransform::GetSpatialHessian } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType hessianWeightsArray1D[numberOfWeights]; - WeightsType hessianWeights1D(hessianWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; + WeightsType hessianWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); @@ -468,11 +453,8 @@ RecursiveBSplineTransform::GetJacobianOfSpat } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); @@ -567,13 +549,9 @@ RecursiveBSplineTransform::GetJacobianOfSpat } /** Create storage for the B-spline interpolation weights. */ - const unsigned int numberOfWeights = RecursiveBSplineWeightFunctionType::NumberOfWeights; - typename WeightsType::ValueType weightsArray1D[numberOfWeights]; - WeightsType weights1D(weightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType derivativeWeightsArray1D[numberOfWeights]; - WeightsType derivativeWeights1D(derivativeWeightsArray1D, numberOfWeights, false); - typename WeightsType::ValueType hessianWeightsArray1D[numberOfWeights]; - WeightsType hessianWeights1D(hessianWeightsArray1D, numberOfWeights, false); + WeightsType weights1D; + WeightsType derivativeWeights1D; + WeightsType hessianWeights1D; double * weightsPointer = &(weights1D[0]); double * derivativeWeightsPointer = &(derivativeWeights1D[0]); diff --git a/Testing/CI/Azure/ci.yml b/Testing/CI/Azure/ci.yml index 61b0d8631..3e57ad3ff 100644 --- a/Testing/CI/Azure/ci.yml +++ b/Testing/CI/Azure/ci.yml @@ -1,5 +1,5 @@ variables: - ITKv5_VERSION: v5.2.0 + ITKv5_VERSION: v5.3rc03 ITK_GIT_URL: https://github.com/InsightSoftwareConsortium/ITK ITK_SOURCE_DIR: $(Agent.BuildDirectory)/ITK-source ITK_BINARY_DIR: $(Agent.BuildDirectory)/ITK-build diff --git a/Testing/itkBSplineTransformPointPerformanceTest.cxx b/Testing/itkBSplineTransformPointPerformanceTest.cxx index b11fcc6f4..f009d328f 100644 --- a/Testing/itkBSplineTransformPointPerformanceTest.cxx +++ b/Testing/itkBSplineTransformPointPerformanceTest.cxx @@ -61,9 +61,8 @@ class BSplineTransform_TEST : public AdvancedBSplineDeformableTransform