From 05e7d4cd14300262a97c1b439d6868af543537e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sun, 17 Mar 2019 11:58:41 -0400 Subject: [PATCH] ENH: Add tests to the module. Add tests to the module. --- test/CMakeLists.txt | 38 ++++++++++++ ...morphosisImageRegistrationMethodv4Test.cxx | 53 +++++++++++++++++ ...miLagrangianIntegrationImageFilterTest.cxx | 58 +++++++++++++++++++ ...locityFieldSemiLagrangianTransformTest.cxx | 52 +++++++++++++++++ test/itkWrapExtrapolateImageFunctionTest.cxx | 51 ++++++++++++++++ 5 files changed, 252 insertions(+) create mode 100644 test/CMakeLists.txt create mode 100644 test/itkMetamorphosisImageRegistrationMethodv4Test.cxx create mode 100644 test/itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest.cxx create mode 100644 test/itkTimeVaryingVelocityFieldSemiLagrangianTransformTest.cxx create mode 100644 test/itkWrapExtrapolateImageFunctionTest.cxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..d8461cf --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,38 @@ +itk_module_test() + +set(NDRegTests + itkMetamorphosisImageRegistrationMethodv4Test.cxx + itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest.cxx + itkTimeVaryingVelocityFieldSemiLagrangianTransformTest.cxx + itkWrapExtrapolateImageFunctionTest.cxx + ) + +CreateTestDriver(NDReg "${NDReg-Test_LIBRARIES}" "${NDRegTests}") + +itk_add_test(NAME itkMetamorphosisImageRegistrationMethodv4Test + COMMAND NDRegTestDriver + --compare ${ITK_TEST_OUTPUT_DIR}/itkMyFilterTestOutput.mha + DATA{Baseline/itkMyFilterTestOutput.mha} + itkMetamorphosisImageRegistrationMethodv4Test ${ITK_TEST_OUTPUT_DIR}/itkMyFilterTestOutput.mha + ) + +itk_add_test(NAME itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest + COMMAND NDRegTestDriver + --compare ${ITK_TEST_OUTPUT_DIR}/itkMyFilterTestOutput.mha + DATA{Baseline/itkMyFilterTestOutput.mha} + itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest ${ITK_TEST_OUTPUT_DIR}/itkMyFilterTestOutput.mha + ) + +itk_add_test(NAME itkTimeVaryingVelocityFieldSemiLagrangianTransformTest + COMMAND NDRegTestDriver --without-threads + --compare ${ITK_TEST_OUTPUT_DIR}/itkNormalDistributionImageSourceTestOutput.mha + DATA{Baseline/itkNormalDistributionImageSourceTestOutput.mha} + itkTimeVaryingVelocityFieldSemiLagrangianTransformTest ${ITK_TEST_OUTPUT_DIR}/itkNormalDistributionImageSourceTestOutput.mha + ) + +itk_add_test(NAME itkWrapExtrapolateImageFunctionTest + COMMAND NDRegTestDriver + --compare ${ITK_TEST_OUTPUT_DIR}/itkMyFilterTestOutput.mha + DATA{Baseline/itkMyFilterTestOutput.mha} + itkWrapExtrapolateImageFunctionTest ${ITK_TEST_OUTPUT_DIR}/itkMyFilterTestOutput.mha + ) diff --git a/test/itkMetamorphosisImageRegistrationMethodv4Test.cxx b/test/itkMetamorphosisImageRegistrationMethodv4Test.cxx new file mode 100644 index 0000000..ba2dde6 --- /dev/null +++ b/test/itkMetamorphosisImageRegistrationMethodv4Test.cxx @@ -0,0 +1,53 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#include "itkMetamorphosisImageRegistrationMethodv4.h" +#include "itkImageFileWriter.h" +#include "itkTestingMacros.h" + + +int itkMetamorphosisImageRegistrationMethodv4Test( int argc, char * argv[] ) +{ + if( argc < 2 ) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << argv[0]; + std::cerr << " outputImage"; + std::cerr << std::endl; + return EXIT_FAILURE; + } + + + const char * outputImageFileName = argv[1]; + + const unsigned int Dimension = 2; + using PixelType = float; + using ImageType = itk::Image< PixelType, Dimension >; + + using MetamorphosisImageRegistrationMethodv4Type = itk::MetamorphosisImageRegistrationMethodv4< ImageType, ImageType >; + MetamorphosisImageRegistrationMethodv4Type::Pointer metamorphosisImageRegistration = + MetamorphosisImageRegistrationMethodv4Type::New(); + + EXERCISE_BASIC_OBJECT_METHODS( metamorphosisImageRegistration, MetamorphosisImageRegistrationMethodv4, + TimeVaryingVelocityFieldImageRegistrationMethodv4 ); + + + + std::cout << "Test finished." << std::endl; + return EXIT_SUCCESS; +} diff --git a/test/itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest.cxx b/test/itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest.cxx new file mode 100644 index 0000000..f5da9c2 --- /dev/null +++ b/test/itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest.cxx @@ -0,0 +1,58 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#include "itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilter.h" +#include "itkImageFileWriter.h" +#include "itkTestingMacros.h" + + +int itkTimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterTest( int argc, char * argv[] ) +{ + if( argc < 2 ) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << argv[0]; + std::cerr << " outputImage"; + std::cerr << std::endl; + return EXIT_FAILURE; + } + + constexpr unsigned int Dimension = 3; + + using PixelType = float; + using ImageType = itk::Image< PixelType, Dimension >; + + using VectorType = itk::Vector< PixelType, Dimension >; + using DisplacementFieldType = itk::Image< VectorType, Dimension >; + using TimeVaryingVelocityFieldType = itk::Image< VectorType, Dimension >; + + using TimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterType = + itk::TimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilter< TimeVaryingVelocityFieldType, + DisplacementFieldType >; + TimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterType::Pointer + timeVaryingVelocityFieldSemiLagrangianIntegrationImageFilter = + TimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilterType::New(); + + EXERCISE_BASIC_OBJECT_METHODS( timeVaryingVelocityFieldSemiLagrangianIntegrationImageFilter, + TimeVaryingVelocityFieldSemiLagrangianIntegrationImageFilter, TimeVaryingVelocityFieldIntegrationImageFilter ); + + + + std::cout << "Test finished." << std::endl; + return EXIT_SUCCESS; +} diff --git a/test/itkTimeVaryingVelocityFieldSemiLagrangianTransformTest.cxx b/test/itkTimeVaryingVelocityFieldSemiLagrangianTransformTest.cxx new file mode 100644 index 0000000..087613b --- /dev/null +++ b/test/itkTimeVaryingVelocityFieldSemiLagrangianTransformTest.cxx @@ -0,0 +1,52 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#include "itkTimeVaryingVelocityFieldSemiLagrangianTransform.h" +#include "itkImageFileWriter.h" +#include "itkTestingMacros.h" + + +int itkTimeVaryingVelocityFieldSemiLagrangianTransformTest( int argc, char * argv[] ) +{ + if( argc < 2 ) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << argv[0]; + std::cerr << " outputImage"; + std::cerr << std::endl; + return EXIT_FAILURE; + } + + constexpr unsigned int Dimension = 2; + + using PixelType = float; + using ImageType = itk::Image< PixelType, Dimension >; + + using TimeVaryingVelocityFieldSemiLagrangianTransformType = + itk::TimeVaryingVelocityFieldSemiLagrangianTransform< PixelType >; + TimeVaryingVelocityFieldSemiLagrangianTransform::Pointer timeVaryingVelocityFieldSemiLagrangianTransform = + TimeVaryingVelocityFieldSemiLagrangianTransform::New(); + + EXERCISE_BASIC_OBJECT_METHODS( timeVaryingVelocityFieldSemiLagrangianTransform, + TimeVaryingVelocityFieldSemiLagrangianTransform, TimeVaryingVelocityFieldTransform ); + + + + std::cout << "Test finished." << std::endl; + return EXIT_SUCCESS; +} diff --git a/test/itkWrapExtrapolateImageFunctionTest.cxx b/test/itkWrapExtrapolateImageFunctionTest.cxx new file mode 100644 index 0000000..22fbd27 --- /dev/null +++ b/test/itkWrapExtrapolateImageFunctionTest.cxx @@ -0,0 +1,51 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#include "itkWrapExtrapolateImageFunction.h" +#include "itkImageFileWriter.h" +#include "itkTestingMacros.h" + + +int itkWrapExtrapolateImageFunctionTest( int argc, char * argv[] ) +{ + if( argc < 2 ) + { + std::cerr << "Missing parameters." << std::endl; + std::cerr << "Usage: " << argv[0]; + std::cerr << " outputImage"; + std::cerr << std::endl; + return EXIT_FAILURE; + } + + constexpr unsigned int Dimension = 2; + + using PixelType = float; + using ImageType = itk::Image< PixelType, Dimension >; + + using WrapExtrapolateImageFunctionType = itk::WrapExtrapolateImageFunction< ImageType >; + WrapExtrapolateImageFunctionType::Pointer wrapExtrapolateImageFunction = + WrapExtrapolateImageFunctionType::New(); + + EXERCISE_BASIC_OBJECT_METHODS( wrapExtrapolateImageFunction, WrapExtrapolateImageFunction, + ExtrapolateImageFunction ); + + + + std::cout << "Test finished." << std::endl; + return EXIT_SUCCESS; +}