Skip to content

Commit

Permalink
WIP: COMP: Upgrade ITK from v5.2.0 to v5.3rc02
Browse files Browse the repository at this point in the history
Upgraded to ITK version 5.3 (RC02), which was released on 11 November 2021.

Including upgrade to C++14, and various performance improvements:

InsightSoftwareConsortium/ITK@6a8569e Use the faster `TransformPhysicalPointToContinuousIndex` overload
InsightSoftwareConsortium/ITK@eb6ac88 Use the faster `TransformPhysicalPointToIndex` overload in filter
InsightSoftwareConsortium/ITK@0539a2c Remove protected `itk::Transform` data member `m_DirectionChange`
InsightSoftwareConsortium/ITK@eec9fe6 Remove unnecessary `IdentityTransform::m_ZeroJacobian`
InsightSoftwareConsortium/ITK@9961ccd Use FastEvaluate in MattesMutualInformationImageToImageMetric + v4
InsightSoftwareConsortium/ITK@9745409 Use FixedArray for table within BSplineInterpolationWeightFunction
InsightSoftwareConsortium/ITK@c23944b Remove BSplineInterpolationWeightFunction Kernel, use FastEvaluate
InsightSoftwareConsortium/ITK@bc7c5df Use FixedArray for BSplineBaseTransform ParameterIndexArrayType
InsightSoftwareConsortium/ITK@9bf745b Use FixedArray for BSplineInterpolationWeightFunction OutputType
InsightSoftwareConsortium/ITK@c64a58d Make `ResampleImageFilter::LinearThreadedGenerateData` faster

Release Notes: https://github.com/InsightSoftwareConsortium/ITK/releases/tag/v5.3rc02

Follow-up to pull request #475 commit 6803b26 "COMP: Upgrade ITK from v5.1.1 to v5.2.0" (merged on 31 May 2021).
  • Loading branch information
N-Dekker committed Jan 3, 2022
1 parent 0cb585e commit 0c7346c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 76 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ElastixGitHubActions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.3rc02"
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.3rc02"
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.3rc02"
cmake-build-type: "Release"
ANNLib: "libANNlib-5.0.1.dylib"
ANNLib2: "libANNlib-5.0.dylib"
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 13 additions & 23 deletions Common/Transforms/itkAdvancedBSplineDeformableTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,8 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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;
Expand Down Expand Up @@ -380,9 +379,8 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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;
Expand Down Expand Up @@ -447,9 +445,7 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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);
WeightsType weights;

/** Compute the B-spline derivative weights. */
IndexType supportIndex;
Expand Down Expand Up @@ -505,9 +501,8 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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<typename WeightsType::ValueType, numberOfWeights * SpaceDimension> coeffs;
Expand Down Expand Up @@ -610,8 +605,7 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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<WeightsValueType, numberOfWeights * SpaceDimension> coeffs;
Expand Down Expand Up @@ -734,9 +728,8 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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);
Expand Down Expand Up @@ -839,8 +832,7 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::GetJ
/** Allocate weight on the stack. */
typedef typename WeightsType::ValueType WeightsValueType;
const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights;
WeightsValueType weightsArray[numberOfWeights];
WeightsType weights(weightsArray, numberOfWeights, false);
WeightsType weights;

/** Allocate coefficients on the stack. */
std::array<WeightsValueType, numberOfWeights * SpaceDimension> coeffs;
Expand Down Expand Up @@ -991,9 +983,8 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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);
Expand Down Expand Up @@ -1117,8 +1108,7 @@ AdvancedBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::GetJ
/** Allocate weight on the stack. */
typedef typename WeightsType::ValueType WeightsValueType;
const unsigned long numberOfWeights = WeightsFunctionType::NumberOfWeights;
WeightsValueType weightsArray[numberOfWeights];
WeightsType weights(weightsArray, numberOfWeights, false);
WeightsType weights;

/** Allocate coefficients on the stack. */
std::array<WeightsValueType, numberOfWeights * SpaceDimension> coeffs;
Expand Down
15 changes: 9 additions & 6 deletions Common/Transforms/itkBSplineInterpolationWeightFunctionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ namespace itk
*/
template <class TCoordRep = float, unsigned int VSpaceDimension = 2, unsigned int VSplineOrder = 3>
class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunctionBase
: public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>, Array<double>>
: public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>
{
public:
/** Standard class typedefs. */
typedef BSplineInterpolationWeightFunctionBase Self;
typedef FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>, Array<double>> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
typedef BSplineInterpolationWeightFunctionBase Self;
typedef FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>
Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;

/** Run-time type information (and related methods). */
itkTypeMacro(BSplineInterpolationWeightFunctionBase, FunctionBase);
Expand All @@ -70,7 +73,7 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunctionBase
static constexpr unsigned long NumberOfWeights = Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension);

/** OutputType typedef support. */
typedef Array<double> WeightsType;
typedef FixedArray<double, NumberOfWeights> WeightsType;

/** Index and size typedef support. */
typedef Index<VSpaceDimension> IndexType;
Expand Down
4 changes: 1 addition & 3 deletions Common/Transforms/itkCyclicBSplineDeformableTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ CyclicBSplineDeformableTransform<TScalarType, NDimensions, VSplineOrder>::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);
Expand Down
52 changes: 15 additions & 37 deletions Common/Transforms/itkRecursiveBSplineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@ auto
RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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])
Expand Down Expand Up @@ -156,10 +152,8 @@ RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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.
Expand Down Expand Up @@ -215,10 +209,8 @@ RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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.
Expand Down Expand Up @@ -269,11 +261,8 @@ RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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]);
Expand Down Expand Up @@ -357,13 +346,9 @@ RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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]);
Expand Down Expand Up @@ -477,11 +462,8 @@ RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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]);
Expand Down Expand Up @@ -577,13 +559,9 @@ RecursiveBSplineTransform<TScalar, NDimensions, VSplineOrder>::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]);
Expand Down
2 changes: 1 addition & 1 deletion Testing/CI/Azure/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
ITKv5_VERSION: v5.2.0
ITKv5_VERSION: v5.3rc02
ITK_GIT_URL: https://github.com/InsightSoftwareConsortium/ITK
ITK_SOURCE_DIR: $(Agent.BuildDirectory)/ITK-source
ITK_BINARY_DIR: $(Agent.BuildDirectory)/ITK-build
Expand Down
3 changes: 1 addition & 2 deletions Testing/itkBSplineTransformPointPerformanceTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ class BSplineTransform_TEST : public AdvancedBSplineDeformableTransform<TScalarT
TransformPoint_OLD(const InputPointType & point) const
{
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;
Expand Down

0 comments on commit 0c7346c

Please sign in to comment.