From 3beeb9ce57fdbff85089cc2fcff83d25dda2de2c Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Thu, 8 Jul 2021 10:58:27 -0400 Subject: [PATCH 1/5] ENH: Add BlockMatching registration Python wrappings + example --- ...tiResolutionImageRegistrationMethodTest.py | 91 +++++++++++++++++++ wrapping/CMakeLists.txt | 6 ++ ...nRegularizationDisplacementCalculator.wrap | 13 +++ ...ngMetricImageToDisplacementCalculator.wrap | 13 +++ ...iResolutionFixedBlockRadiusCalculator.wrap | 20 ++++ ...esolutionFixedSearchRegionImageSource.wrap | 46 ++++++++++ ...ultiResolutionImageRegistrationMethod.wrap | 61 +++++++++++++ ...NeighborhoodIteratorMetricImageFilter.wrap | 16 ++++ 8 files changed, 266 insertions(+) create mode 100644 examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py create mode 100644 wrapping/itkBlockMatchingBayesianRegularizationDisplacementCalculator.wrap create mode 100644 wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap create mode 100644 wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap create mode 100644 wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap create mode 100644 wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap create mode 100644 wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap diff --git a/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py new file mode 100644 index 00000000..436448e0 --- /dev/null +++ b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +# Copyright NumFOCUS +# +# 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. + +import os +from urllib.request import urlretrieve + +import itk + +# Verify wrapping succeeded +assert 'MultiResolutionFixedBlockRadiusCalculator' in dir(itk.Ultrasound) + +# Get image input for registration +FIXED_IMAGE_PATH = 'Input/rf_pre15.mha' +MOVING_IMAGE_PATH = 'Input/rf_post15.mha' + +if not os.path.exists(FIXED_IMAGE_PATH): + url = 'https://data.kitware.com/api/v1/file/58ee3b778d777f16d095fd8a/download' + urlretrieve(url, FIXED_IMAGE_PATH) + +if not os.path.exists(MOVING_IMAGE_PATH): + url = 'https://data.kitware.com/api/v1/file/58ee3b758d777f16d095fd87/download' + urlretrieve(url, MOVING_IMAGE_PATH) + +fixed_image = itk.imread(FIXED_IMAGE_PATH, itk.D) +moving_image = itk.imread(MOVING_IMAGE_PATH, itk.D) + +dimension = fixed_image.GetImageDimension() +displacement_image_type = itk.Image[itk.Vector[itk.D,dimension],dimension] + +block_radius_calculator = itk.Ultrasound.MultiResolutionFixedBlockRadiusCalculator[type(fixed_image)].New() +block_radius_calculator.SetRadius([12,4]) + +# Create schedule for iterative registration +search_region_source = itk.Ultrasound.MultiResolutionFixedSearchRegionImageSource[type(fixed_image), + type(fixed_image), + displacement_image_type].New() +pyramid_schedule = itk.Array2D[itk.UI]() +pyramid_schedule.SetSize(3,2) +pyramid_schedule.SetElement(0,0,3) +pyramid_schedule.SetElement(0,1,2) +pyramid_schedule.SetElement(1,0,2) +pyramid_schedule.SetElement(1,1,1) +pyramid_schedule.SetElement(2,0,1) +pyramid_schedule.SetElement(2,1,1) + +search_region_source.SetPyramidSchedule(pyramid_schedule) +search_region_source.SetSearchRegionRadiusSchedule([50,6]) +search_region_source.SetOverlapSchedule(1.0) + +metric_image_filter = itk.Ultrasound.NormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter[type(fixed_image), + type(fixed_image), + type(fixed_image)].New() + +level_registration_method = itk.Ultrasound.ImageRegistrationMethod[type(fixed_image), + type(fixed_image), + type(fixed_image), + displacement_image_type, + itk.D].New() +level_registration_method.SetMetricImageFilter(metric_image_filter) + +# Set up the multi-resolution registration object +multi_res_registration_method = itk.Ultrasound.MultiResolutionImageRegistrationMethod[type(fixed_image), + type(fixed_image), + type(fixed_image), + displacement_image_type, + itk.D].New() +multi_res_registration_method.SetFixedImage(fixed_image) +multi_res_registration_method.SetMovingImage(moving_image) +multi_res_registration_method.SetBlockRadiusCalculator(block_radius_calculator) +multi_res_registration_method.SetSearchRegionImageSource(search_region_source) +multi_res_registration_method.SetSchedules(pyramid_schedule, pyramid_schedule) +multi_res_registration_method.SetImageRegistrationMethod(level_registration_method) + +# Run the actual registration +multi_res_registration_method.Update() + +# Write out results +itk.imwrite(multi_res_registration_method.GetOutput(), 'Output/rf_post15_registered.mha') diff --git a/wrapping/CMakeLists.txt b/wrapping/CMakeLists.txt index 187e0887..fb19699c 100644 --- a/wrapping/CMakeLists.txt +++ b/wrapping/CMakeLists.txt @@ -8,6 +8,12 @@ endif() itk_wrap_module(Ultrasound) set(WRAPPER_LIBRARY_GROUPS + itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator + itkBlockMatchingMetricImageToDisplacementCalculator + itkBlockMatchingBayesianRegularizationDisplacementCalculator + itkBlockMatchingMultiResolutionFixedSearchRegionImageSource + itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter + itkBlockMatchingMultiResolutionImageRegistrationMethod itkSpectra1DSupportWindowImageFilter itkCurvilinearArraySpecialCoordinatesImage itkFrequencyDomain1DFilterFunction diff --git a/wrapping/itkBlockMatchingBayesianRegularizationDisplacementCalculator.wrap b/wrapping/itkBlockMatchingBayesianRegularizationDisplacementCalculator.wrap new file mode 100644 index 00000000..6b0b77ea --- /dev/null +++ b/wrapping/itkBlockMatchingBayesianRegularizationDisplacementCalculator.wrap @@ -0,0 +1,13 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkImage.h") + +# Wrap desired class +itk_wrap_include("itkBlockMatchingBayesianRegularizationDisplacementCalculator.h") +itk_wrap_class("itk::BlockMatching::BayesianRegularizationDisplacementCalculator" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_V${ITKM_${t}}${d}}${d}" + "itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_V${ITKM_${t}}${d}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap new file mode 100644 index 00000000..ec099393 --- /dev/null +++ b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap @@ -0,0 +1,13 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) + +itk_wrap_include("itkBlockMatchingMetricImageToDisplacementCalculator.h") +itk_wrap_class("itk::BlockMatching::MetricImageToDisplacementCalculator" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(t2 ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_V${t2}${d}}${d}" + "${ITKT_I${ITKM_${t}}${d}}, ${ITKT_I${ITKM_V${t2}${d}}${d}}") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap b/wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap new file mode 100644 index 00000000..5a90a30f --- /dev/null +++ b/wrapping/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.wrap @@ -0,0 +1,20 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkImage.h") + +itk_wrap_include("itkBlockMatchingMultiResolutionBlockRadiusCalculator.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionBlockRadiusCalculator" POINTER) + foreach(t ${WRAP_ITK_SCALAR}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}" "itk::Image<${ITKT_${t}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionFixedBlockRadiusCalculator" POINTER) + foreach(t ${WRAP_ITK_SCALAR}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}" "itk::Image<${ITKT_${t}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap b/wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap new file mode 100644 index 00000000..23ae8089 --- /dev/null +++ b/wrapping/itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.wrap @@ -0,0 +1,46 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) + +itk_wrap_include("itkVector.h") +itk_wrap_include("itkImage.h") +itk_wrap_include("itkImageRegion.h") + +# Wrap for class template +itk_wrap_include("itkImageRegion.h") +itk_wrap_class("itk::Image" POINTER) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("IR${d}${d}" "itk::ImageRegion<${d}>, ${d}") + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkImageSource.h") +itk_wrap_class("itk::ImageSource" POINTER) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("IIR${d}${d}" "itk::Image,${d}>") + endforeach() +itk_end_wrap_class() + +# Wrap class hierarchy +itk_wrap_include("itkBlockMatchingMultiResolutionSearchRegionImageSource.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionSearchRegionImageSource" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(vt ${WRAP_ITK_VECTOR_REAL}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_${t}}${d}I${ITKM_${vt}${d}}${d}" + "itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${vt}${d}},${d}>") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() + +# Wrap class +itk_wrap_include("itkBlockMatchingMultiResolutionFixedSearchRegionImageSource.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionFixedSearchRegionImageSource" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(vt ${WRAP_ITK_VECTOR_REAL}) + itk_wrap_template("I${ITKM_${t}}${d}I${ITKM_${t}}${d}I${ITKM_${vt}${d}}${d}" + "itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${t}},${d}>, itk::Image<${ITKT_${vt}${d}},${d}>") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap new file mode 100644 index 00000000..4a461058 --- /dev/null +++ b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap @@ -0,0 +1,61 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkPoint.h") +itk_wrap_include("itkSmartPointer.h") +itk_wrap_include("itkImage.h") +itk_wrap_include("itkImageRegion.h") + +# Wrap base classes for itk::BlockMatching::MetricImageToDisplacementCalculator public members +#itk_wrap_class("itk::SmartPointer") +# foreach(t ${WRAP_ITK_REAL}) +# foreach(d ${ITK_WRAP_IMAGE_DIMS}) +# itk_wrap_template("I${ITKM_${t}}${d}" "itk::Image<${ITKT_${t}},${d}>") +# endforeach() +# endforeach() +#itk_end_wrap_class() + +itk_wrap_class("itk::Image" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("P${ITKM_${t}}${d}${d}" "itk::Point<${ITKT_${t}},${d}>, ${d}") + itk_wrap_template("SPI${ITKM_${t}}${d}${d}" "itk::SmartPointer>, ${d}") + endforeach() + endforeach() +itk_end_wrap_class() + +# Wrap class hierarchy +itk_wrap_include("itkImageToImageFilter.h") +itk_wrap_class("itk::ImageToImageFilter" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("IIR${d}${d}I${ITKM_V${t}${d}}${d}" + "itk::Image,${d}>, itk::Image<${ITKT_V${t}${d}},${d}>") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingImageRegistrationMethod.h") +itk_wrap_class("itk::BlockMatching::ImageRegistrationMethod" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(vt ${WRAP_ITK_VECTOR_REAL}) + set(img_m "I${ITKM_${t}}${d}") + set(img_t "itk::Image<${ITKT_${t}}, ${d}>") + itk_wrap_template("${img_m}${img_m}${img_m}I${ITKM_${vt}${d}}${d}" + "${img_t}, ${img_t}, ${img_t}, itk::Image<${ITKT_${vt}${d}},${d}>, ${ITKT_${t}}") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() + +# Wrap target class +itk_wrap_include("itkBlockMatchingMultiResolutionImageRegistrationMethod.h") +itk_wrap_class("itk::BlockMatching::MultiResolutionImageRegistrationMethod" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + set(img_m "I${ITKM_${t}}${d}") + set(img_t "itk::Image<${ITKT_${t}}, ${d}>") + itk_wrap_template("${img_m}${img_m}${img_m}I${ITKM_${vt}${d}}${d}" + "${img_t}, ${img_t}, ${img_t}, itk::Image<${ITKT_V${t}${d}},${d}>, ${ITKT_${t}}") + endforeach() + endforeach() +itk_end_wrap_class() diff --git a/wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap b/wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap new file mode 100644 index 00000000..4bad8c4a --- /dev/null +++ b/wrapping/itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.wrap @@ -0,0 +1,16 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) + +itk_wrap_include("itkBlockMatchingMetricImageFilter.h") +itk_wrap_class("itk::BlockMatching::MetricImageFilter" POINTER) + itk_wrap_image_filter("${WRAP_ITK_REAL}" 3 2+) +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingNormalizedCrossCorrelationMetricImageFilter.h") +itk_wrap_class("itk::BlockMatching::NormalizedCrossCorrelationMetricImageFilter" POINTER) + itk_wrap_image_filter("${WRAP_ITK_REAL}" 3 2+) +itk_end_wrap_class() + +itk_wrap_include("itkBlockMatchingNormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter.h") +itk_wrap_class("itk::BlockMatching::NormalizedCrossCorrelationNeighborhoodIteratorMetricImageFilter" POINTER) + itk_wrap_image_filter("${WRAP_ITK_REAL}" 3 2+) +itk_end_wrap_class() From d863da88dac4a04fdf319c39c52eb9b98bf67fc7 Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Mon, 26 Jul 2021 13:07:35 -0400 Subject: [PATCH 2/5] WIP: Add image point wrapping for calculator member --- ...kMatchingMetricImageToDisplacementCalculator.wrap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap index ec099393..3fe1541b 100644 --- a/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap +++ b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap @@ -1,5 +1,17 @@ set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +# Wrap for member types +itk_wrap_include("itkPoint.h") +itk_wrap_include("itkImage.h") +UNIQUE(point_types "${WRAP_ITK_REAL};D") +itk_wrap_class("itk::Image" POINTER) + foreach(t ${point_types}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("P${ITKM_${t}}${d}" "itk::Point<${ITKT_${t}}, ${d}>, ${d}") + endforeach() + endforeach() +itk_end_wrap_class() + itk_wrap_include("itkBlockMatchingMetricImageToDisplacementCalculator.h") itk_wrap_class("itk::BlockMatching::MetricImageToDisplacementCalculator" POINTER) foreach(t ${WRAP_ITK_REAL}) From 025ad3979f28ffa913c5cef7f75259c6e5e7b9de Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Fri, 23 Jul 2021 15:45:04 -0400 Subject: [PATCH 3/5] ENH: Rename BlockMatchingImageRegistrationMethod to mitigate collisions --- ...tiResolutionImageRegistrationMethodTest.py | 4 ++-- .../itkBlockMatchingDisplacementPipeline.h | 4 ++-- .../itkBlockMatchingImageRegistrationMethod.h | 16 ++++++------- ...tkBlockMatchingImageRegistrationMethod.hxx | 18 +++++++------- include/itkBlockMatchingMetricImageFilter.h | 2 +- ...chingMetricImageToDisplacementCalculator.h | 8 +++---- ...hingMultiResolutionBlockRadiusCalculator.h | 4 ++-- ...ultiResolutionFixedBlockRadiusCalculator.h | 2 +- ...ngMultiResolutionImageRegistrationMethod.h | 20 ++++++++-------- ...MultiResolutionImageRegistrationMethod.hxx | 24 +++++++++---------- ...kMatchingMultiResolutionIterationCommand.h | 2 +- ...ngMultiResolutionSearchRegionImageSource.h | 4 ++-- ...lockMatchingSearchRegionImageInitializer.h | 4 ++-- ...gularizationDisplacementCalculatorTest.cxx | 2 +- ...ockMatchingImageRegistrationMethodTest.cxx | 2 +- ...iResolutionImageRegistrationMethodTest.cxx | 4 ++-- ...ngMetricImageToDisplacementCalculator.wrap | 10 ++++++++ ...ultiResolutionImageRegistrationMethod.wrap | 12 ++++++---- 18 files changed, 78 insertions(+), 64 deletions(-) diff --git a/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py index 436448e0..a65337a9 100644 --- a/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py +++ b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py @@ -64,7 +64,7 @@ type(fixed_image), type(fixed_image)].New() -level_registration_method = itk.Ultrasound.ImageRegistrationMethod[type(fixed_image), +level_registration_method = itk.Ultrasound.BlockMatchingImageRegistrationMethod[type(fixed_image), type(fixed_image), type(fixed_image), displacement_image_type, @@ -72,7 +72,7 @@ level_registration_method.SetMetricImageFilter(metric_image_filter) # Set up the multi-resolution registration object -multi_res_registration_method = itk.Ultrasound.MultiResolutionImageRegistrationMethod[type(fixed_image), +multi_res_registration_method = itk.Ultrasound.BlockMatchingMultiResolutionImageRegistrationMethod[type(fixed_image), type(fixed_image), type(fixed_image), displacement_image_type, diff --git a/include/itkBlockMatchingDisplacementPipeline.h b/include/itkBlockMatchingDisplacementPipeline.h index c640f114..4a3af245 100644 --- a/include/itkBlockMatchingDisplacementPipeline.h +++ b/include/itkBlockMatchingDisplacementPipeline.h @@ -129,7 +129,7 @@ class ITK_TEMPLATE_EXPORT DisplacementPipeline /** The registration method. */ using LevelRegistrationMethodType = BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; /** Interpolation classes. */ using ParabolicInterpolatorType = @@ -174,7 +174,7 @@ class ITK_TEMPLATE_EXPORT DisplacementPipeline BlockMatching::BayesianRegularizationDisplacementCalculator; /** Multi-resolution registration method. */ - using RegistrationMethodType = BlockMatching::MultiResolutionImageRegistrationMethod -class ITK_TEMPLATE_EXPORT ImageRegistrationMethod +class ITK_TEMPLATE_EXPORT BlockMatchingImageRegistrationMethod : public ImageToImageFilter, TDisplacementImage> { public: - ITK_DISALLOW_COPY_AND_ASSIGN(ImageRegistrationMethod); + ITK_DISALLOW_COPY_AND_ASSIGN(BlockMatchingImageRegistrationMethod); /** ImageDimension enumeration. */ itkStaticConstMacro(ImageDimension, unsigned int, TDisplacementImage::ImageDimension); @@ -92,7 +92,7 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethod using SearchRegionImageType = Image; /** Standard class type alias. */ - using Self = ImageRegistrationMethod; + using Self = BlockMatchingImageRegistrationMethod; using Superclass = ImageToImageFilter; using Pointer = SmartPointer; using ConstPointer = SmartPointer; @@ -101,7 +101,7 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethod itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(ImageRegistrationMethod, ImageSource); + itkTypeMacro(BlockMatchingImageRegistrationMethod, ImageSource); /** Type of the point use for determing the location in the fixed image of a * block's center. */ @@ -188,8 +188,8 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethod protected: - ImageRegistrationMethod(); - virtual ~ImageRegistrationMethod() {} + BlockMatchingImageRegistrationMethod(); + virtual ~BlockMatchingImageRegistrationMethod() {} void GenerateOutputInformation() override; diff --git a/include/itkBlockMatchingImageRegistrationMethod.hxx b/include/itkBlockMatchingImageRegistrationMethod.hxx index 394c1c33..2e96d136 100644 --- a/include/itkBlockMatchingImageRegistrationMethod.hxx +++ b/include/itkBlockMatchingImageRegistrationMethod.hxx @@ -36,8 +36,8 @@ template -ImageRegistrationMethod:: - ImageRegistrationMethod() +BlockMatchingImageRegistrationMethod:: + BlockMatchingImageRegistrationMethod() : m_UseStreaming(false) { m_FixedImage = nullptr; @@ -55,7 +55,7 @@ template void -ImageRegistrationMethod::SetFixedImage( +BlockMatchingImageRegistrationMethod::SetFixedImage( FixedImageType * fixedImage) { if (this->m_FixedImage.GetPointer() != fixedImage) @@ -72,7 +72,7 @@ template void -ImageRegistrationMethod::SetMovingImage( +BlockMatchingImageRegistrationMethod::SetMovingImage( MovingImageType * movingImage) { if (this->m_MovingImage.GetPointer() != movingImage) @@ -89,7 +89,7 @@ template void -ImageRegistrationMethod:: +BlockMatchingImageRegistrationMethod:: GenerateOutputInformation() { Superclass::GenerateOutputInformation(); @@ -109,7 +109,7 @@ template void -ImageRegistrationMethod:: +BlockMatchingImageRegistrationMethod:: GenerateInputRequestedRegion() { Superclass::GenerateInputRequestedRegion(); @@ -132,7 +132,7 @@ template void -ImageRegistrationMethod:: +BlockMatchingImageRegistrationMethod:: EnlargeOutputRequestedRegion(DataObject * data) { this->m_MetricImageToDisplacementCalculator->ModifyEnlargeOutputRequestedRegion(data); @@ -145,7 +145,7 @@ template void -ImageRegistrationMethod::GenerateData() +BlockMatchingImageRegistrationMethod::GenerateData() { const SearchRegionImageType * input = this->GetInput(); @@ -212,7 +212,7 @@ template void -ImageRegistrationMethod::Initialize() +BlockMatchingImageRegistrationMethod::Initialize() { if (!m_FixedImage) { diff --git a/include/itkBlockMatchingMetricImageFilter.h b/include/itkBlockMatchingMetricImageFilter.h index d2ca8271..789226fa 100644 --- a/include/itkBlockMatchingMetricImageFilter.h +++ b/include/itkBlockMatchingMetricImageFilter.h @@ -31,7 +31,7 @@ namespace BlockMatching * region. * * This class is intended to be used internally by - * itk::BlockMatching::ImageRegistrationMethod and its ilk. + * itk::BlockMatching::BlockMatchingImageRegistrationMethod and its ilk. * * There are two inputs to this image, the Fixed Image, and the Moving Image. * A block or kernel from the FixedImage is specified with SetFixedRegion(). diff --git a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h index 6f4516b8..5fefb418 100644 --- a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h +++ b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h @@ -32,7 +32,7 @@ namespace BlockMatching * * \brief Calculates the displacement of a block from the MetricImage(s). * - * This class tightly integrates with BlockMatching::ImageRegistrationMethod. + * This class tightly integrates with BlockMatching::BlockMatchingImageRegistrationMethod. * It is the responsibility of this class to calculate the displacement given * MetricImage(s) in a block matching registration method. * @@ -47,7 +47,7 @@ namespace BlockMatching * * Caching of the MetricImage can be enabled by SetCacheMetricImageOn(); * - * The behavior of the associated BlockMatching::ImageRegistrationMethod + * The behavior of the associated BlockMatching::BlockMatchingImageRegistrationMethod * GenerateInputRequestedRegion() and EnlargeOutputRequestedRegion() with * ModifyGenerateInputRequestedRegion() and * ModifyEnlargeOutputRequestedRegion(). @@ -134,13 +134,13 @@ class ITK_TEMPLATE_EXPORT MetricImageToDisplacementCalculator : public Object virtual void Compute() = 0; - /** Modify the associated BlockMatching::ImageRegistrationMethod's + /** Modify the associated BlockMatching::BlockMatchingImageRegistrationMethod's * GenerateInputRequestedRegion(). */ virtual void ModifyGenerateInputRequestedRegion(RegionType & region) {} - /** Modify the associated BlockMatching::ImageRegistrationMethod's + /** Modify the associated BlockMatching::BlockMatchingImageRegistrationMethod's * EnlargeOutputRequestedRegion(). */ virtual void ModifyEnlargeOutputRequestedRegion(DataObject * data) diff --git a/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h b/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h index 3363c58a..c2b1946e 100644 --- a/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h +++ b/include/itkBlockMatchingMultiResolutionBlockRadiusCalculator.h @@ -29,7 +29,7 @@ namespace BlockMatching /** \class MultiResolutionBlockRadiusCalculator * * \brief Base class calculate the fixed image matching kernel radius for each level in a - * BlockMatching::MultiResolutionImageRegistrationMethod. + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod. * * This must be able to produce the fixed image block radius for every level of * the MultiResolutionPyramidImage filter. @@ -74,7 +74,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionBlockRadiusCalculator : public Object itkGetConstReferenceMacro(PyramidSchedule, ScheduleType); /** Set/Get the Fixed image. The fixed image is set during the - * BlockMatching::MultiResolutionImageRegistrationMethod and is available for + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod and is available for * child classes if the choose to use it. */ itkSetConstObjectMacro(FixedImage, FixedImageType); itkGetConstObjectMacro(FixedImage, FixedImageType); diff --git a/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h b/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h index f5f78aaf..295a4266 100644 --- a/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h +++ b/include/itkBlockMatchingMultiResolutionFixedBlockRadiusCalculator.h @@ -30,7 +30,7 @@ namespace BlockMatching * \brief A fixed radius is used for every level. * * This class generates the fixed image matching kernel radius in a - * BlockMatching::MultiResolutionImageRegistrationMethod. A fixed block radius + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod. A fixed block radius * is used, which means the size of the block in physical coordinates then * scales with the pyramid schedule. * diff --git a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h index 2c10c05e..9a2ebebd 100644 --- a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h +++ b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.h @@ -30,7 +30,7 @@ namespace itk namespace BlockMatching { -/** \class MultiResolutionImageRegistrationMethod +/** \class BlockMatchingMultiResolutionImageRegistrationMethod * * \brief Base class for multi-resolution image registration methods in the * BlockMatching set of tools. @@ -42,7 +42,7 @@ namespace BlockMatching * The SetNumberOfLevels() or SetSchedule() is used to set up the * MultiResolutionPyramidImageFilter. * - * \sa ImageRegistrationMethod + * \sa BlockMatchingImageRegistrationMethod * * \ingroup RegistrationFilters * \ingroup Ultrasound @@ -52,10 +52,10 @@ template -class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageSource +class ITK_TEMPLATE_EXPORT BlockMatchingMultiResolutionImageRegistrationMethod : public ImageSource { public: - ITK_DISALLOW_COPY_AND_ASSIGN(MultiResolutionImageRegistrationMethod); + ITK_DISALLOW_COPY_AND_ASSIGN(BlockMatchingMultiResolutionImageRegistrationMethod); /** ImageDimension enumeration. */ itkStaticConstMacro(ImageDimension, unsigned int, TDisplacementImage::ImageDimension); @@ -91,7 +91,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS using SearchRegionImageType = Image; /** Standard class type alias. */ - using Self = MultiResolutionImageRegistrationMethod; + using Self = BlockMatchingMultiResolutionImageRegistrationMethod; using Superclass = ImageSource; using Pointer = SmartPointer; using ConstPointer = SmartPointer; @@ -100,7 +100,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(MultiResolutionImageRegistrationMethod, ImageSource); + itkTypeMacro(BlockMatchingMultiResolutionImageRegistrationMethod, ImageSource); /** Type of the Fixed image multiresolution pyramid. */ using FixedImagePyramidType = MultiResolutionPyramidImageFilter; @@ -115,7 +115,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS /** Type of the registration method used at every level. */ using ImageRegistrationMethodType = typename BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; using ImageRegistrationMethodPointer = typename ImageRegistrationMethodType::Pointer; /** Type of the class to calculate the fixed image matching kernel block @@ -166,7 +166,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS ModifiedTimeType GetMTime() const override; - /** BlockMatching::ImageRegistrationMethod used to register each image at + /** BlockMatching::BlockMatchingImageRegistrationMethod used to register each image at * every level. */ itkSetObjectMacro(ImageRegistrationMethod, ImageRegistrationMethodType); itkGetModifiableObjectMacro(ImageRegistrationMethod, ImageRegistrationMethodType); @@ -181,8 +181,8 @@ class ITK_TEMPLATE_EXPORT MultiResolutionImageRegistrationMethod : public ImageS itkGetConstObjectMacro(SearchRegionImageSource, SearchRegionImageSourceType); protected: - MultiResolutionImageRegistrationMethod(); - virtual ~MultiResolutionImageRegistrationMethod(){}; + BlockMatchingMultiResolutionImageRegistrationMethod(); + virtual ~BlockMatchingMultiResolutionImageRegistrationMethod(){}; /** The size and spacing of the search region image at the lowest level is * used to generate the information for the output image. */ diff --git a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx index 1e4abdff..5411d868 100644 --- a/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx +++ b/include/itkBlockMatchingMultiResolutionImageRegistrationMethod.hxx @@ -33,8 +33,8 @@ template -MultiResolutionImageRegistrationMethod:: - MultiResolutionImageRegistrationMethod() +BlockMatchingMultiResolutionImageRegistrationMethod:: + BlockMatchingMultiResolutionImageRegistrationMethod() : m_FixedImage(nullptr) , m_MovingImage(nullptr) , m_NumberOfLevels(1) @@ -57,7 +57,7 @@ template ModifiedTimeType -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: GetMTime() const { unsigned long mtime = Superclass::GetMTime(); @@ -85,7 +85,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: StopRegistration(void) { m_Stop = true; @@ -98,7 +98,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: Initialize() { // Sanity checks @@ -122,7 +122,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: SetSchedules(const ScheduleType & fixedImagePyramidSchedule, const ScheduleType & movingImagePyramidSchedule) { if (m_NumberOfLevelsSpecified) @@ -155,7 +155,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: SetNumberOfLevels(unsigned long numberOfLevels) { if (m_ScheduleSpecified) @@ -176,7 +176,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: GenerateOutputInformation() { if (!m_FixedImage) @@ -215,7 +215,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: PreparePyramids() { // Sanity checks @@ -259,7 +259,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: PrepareBlockRadiusCalculator() { // Sanity checks @@ -279,7 +279,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: PrepareSearchRegionImageSource() { // Sanity checks @@ -299,7 +299,7 @@ template void -MultiResolutionImageRegistrationMethod:: +BlockMatchingMultiResolutionImageRegistrationMethod:: GenerateData() { m_Stop = false; diff --git a/include/itkBlockMatchingMultiResolutionIterationCommand.h b/include/itkBlockMatchingMultiResolutionIterationCommand.h index fa44f3f3..29c2b622 100644 --- a/include/itkBlockMatchingMultiResolutionIterationCommand.h +++ b/include/itkBlockMatchingMultiResolutionIterationCommand.h @@ -31,7 +31,7 @@ namespace BlockMatching * \class MultiResolutionIterationCommand * * \brief This is a base class for classes that want to observe/adjust a - * BlockMatching::MultiResolutionImageRegistrationMethod at every iteration. + * BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod at every iteration. * * \ingroup Ultrasound * */ diff --git a/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h b/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h index 4c558b3b..3808b2c9 100644 --- a/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h +++ b/include/itkBlockMatchingMultiResolutionSearchRegionImageSource.h @@ -35,7 +35,7 @@ template -class MultiResolutionImageRegistrationMethod; +class BlockMatchingMultiResolutionImageRegistrationMethod; /** \class MultiResolutionSearchRegionImageSource @@ -179,7 +179,7 @@ class ITK_TEMPLATE_EXPORT MultiResolutionSearchRegionImageSource typename TMetricImage, typename TDisplacementImageF, typename TCoordRep> - friend class MultiResolutionImageRegistrationMethod; + friend class BlockMatchingMultiResolutionImageRegistrationMethod; itkGetConstObjectMacro(PreviousDisplacements, DisplacementImageType); diff --git a/include/itkBlockMatchingSearchRegionImageInitializer.h b/include/itkBlockMatchingSearchRegionImageInitializer.h index 8e4bb628..b93e6b3e 100644 --- a/include/itkBlockMatchingSearchRegionImageInitializer.h +++ b/include/itkBlockMatchingSearchRegionImageInitializer.h @@ -28,10 +28,10 @@ namespace BlockMatching /** \class SearchRegionImageInitializer * * \brief Creates a SearchRegionImage for input into a - * BlockMatching::ImageRegistrationMethod. + * BlockMatching::BlockMatchingImageRegistrationMethod. * * This creates a SearchRegionImage for input into the - * BlockMatching::ImageRegistrationMethod. The search regions are centered + * BlockMatching::BlockMatchingImageRegistrationMethod. The search regions are centered * around the fixed image blocks and evenly spaced. Overlap between blocks may * be set with SetOverlap(). The input fixed image, fixed image block radius, * moving image, and search region radius must be set. diff --git a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx index 7c909908..b5e97b0d 100644 --- a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx +++ b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx @@ -74,7 +74,7 @@ itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest(int argc, char // The image registration method. using RegistrationMethodType = itk::BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; RegistrationMethodType::Pointer registrationMethod = RegistrationMethodType::New(); registrationMethod->SetFixedImage(fixedReader->GetOutput()); registrationMethod->SetMovingImage(movingReader->GetOutput()); diff --git a/test/itkBlockMatchingImageRegistrationMethodTest.cxx b/test/itkBlockMatchingImageRegistrationMethodTest.cxx index ef956b9a..603fc676 100644 --- a/test/itkBlockMatchingImageRegistrationMethodTest.cxx +++ b/test/itkBlockMatchingImageRegistrationMethodTest.cxx @@ -67,7 +67,7 @@ itkBlockMatchingImageRegistrationMethodTest(int argc, char * argv[]) searchRegions->SetSearchRegionRadius(searchRadius); using RegistrationMethodType = itk::BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; RegistrationMethodType::Pointer registrationMethod = RegistrationMethodType::New(); registrationMethod->SetFixedImage(fixedReader->GetOutput()); registrationMethod->SetMovingImage(movingReader->GetOutput()); diff --git a/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx b/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx index cbcd3e1f..09e3a4a3 100644 --- a/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx +++ b/test/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.cxx @@ -85,11 +85,11 @@ itkBlockMatchingMultiResolutionImageRegistrationMethodTest(int argc, char * argv MetricImageFilterType::Pointer metricImageFilter = MetricImageFilterType::New(); using LevelRegistrationMethodType = itk::BlockMatching:: - ImageRegistrationMethod; + BlockMatchingImageRegistrationMethod; LevelRegistrationMethodType::Pointer levelRegistrationMethod = LevelRegistrationMethodType::New(); levelRegistrationMethod->SetMetricImageFilter(metricImageFilter); - using RegistrationMethodType = itk::BlockMatching::MultiResolutionImageRegistrationMethod, ${d}") + endforeach() + endforeach() +itk_end_wrap_class() + itk_wrap_include("itkBlockMatchingMetricImageToDisplacementCalculator.h") itk_wrap_class("itk::BlockMatching::MetricImageToDisplacementCalculator" POINTER) foreach(t ${WRAP_ITK_REAL}) diff --git a/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap index 4a461058..34ff4c71 100644 --- a/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap +++ b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap @@ -13,10 +13,14 @@ itk_wrap_include("itkImageRegion.h") # endforeach() #itk_end_wrap_class() +message(STATUS ${ITK_WRAP_POINT}) itk_wrap_class("itk::Image" POINTER) - foreach(t ${WRAP_ITK_REAL}) - foreach(d ${ITK_WRAP_IMAGE_DIMS}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + #FIXME + foreach(t ${ITK_WRAP_POINT}) itk_wrap_template("P${ITKM_${t}}${d}${d}" "itk::Point<${ITKT_${t}},${d}>, ${d}") + endforeach() + foreach(t ${WRAP_ITK_REAL}) itk_wrap_template("SPI${ITKM_${t}}${d}${d}" "itk::SmartPointer>, ${d}") endforeach() endforeach() @@ -34,7 +38,7 @@ itk_wrap_class("itk::ImageToImageFilter" POINTER) itk_end_wrap_class() itk_wrap_include("itkBlockMatchingImageRegistrationMethod.h") -itk_wrap_class("itk::BlockMatching::ImageRegistrationMethod" POINTER) +itk_wrap_class("itk::BlockMatching::BlockMatchingImageRegistrationMethod" POINTER) foreach(t ${WRAP_ITK_REAL}) foreach(d ${ITK_WRAP_IMAGE_DIMS}) foreach(vt ${WRAP_ITK_VECTOR_REAL}) @@ -49,7 +53,7 @@ itk_end_wrap_class() # Wrap target class itk_wrap_include("itkBlockMatchingMultiResolutionImageRegistrationMethod.h") -itk_wrap_class("itk::BlockMatching::MultiResolutionImageRegistrationMethod" POINTER) +itk_wrap_class("itk::BlockMatching::BlockMatchingMultiResolutionImageRegistrationMethod" POINTER) foreach(t ${WRAP_ITK_REAL}) foreach(d ${ITK_WRAP_IMAGE_DIMS}) set(img_m "I${ITKM_${t}}${d}") From 4481861407908913a062cf2eabf27196fa22100f Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Fri, 30 Jul 2021 11:00:29 -0400 Subject: [PATCH 4/5] WIP: Replace MetricImage SmartPointer types with pointers for wrapping --- ...tiResolutionImageRegistrationMethodTest.py | 10 ++++----- ...anRegularizationDisplacementCalculator.hxx | 4 ++-- ...chingMetricImageToDisplacementCalculator.h | 2 +- ...gularizationDisplacementCalculatorTest.cxx | 1 + ...ngMetricImageToDisplacementCalculator.wrap | 19 +++++++++++----- ...ultiResolutionImageRegistrationMethod.wrap | 22 ------------------- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py index a65337a9..0a62d1b9 100644 --- a/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py +++ b/examples/itkBlockMatchingMultiResolutionImageRegistrationMethodTest.py @@ -34,11 +34,11 @@ url = 'https://data.kitware.com/api/v1/file/58ee3b758d777f16d095fd87/download' urlretrieve(url, MOVING_IMAGE_PATH) -fixed_image = itk.imread(FIXED_IMAGE_PATH, itk.D) -moving_image = itk.imread(MOVING_IMAGE_PATH, itk.D) +fixed_image = itk.imread(FIXED_IMAGE_PATH, itk.F) +moving_image = itk.imread(MOVING_IMAGE_PATH, itk.F) dimension = fixed_image.GetImageDimension() -displacement_image_type = itk.Image[itk.Vector[itk.D,dimension],dimension] +displacement_image_type = itk.Image[itk.Vector[itk.F,dimension],dimension] block_radius_calculator = itk.Ultrasound.MultiResolutionFixedBlockRadiusCalculator[type(fixed_image)].New() block_radius_calculator.SetRadius([12,4]) @@ -68,7 +68,7 @@ type(fixed_image), type(fixed_image), displacement_image_type, - itk.D].New() + itk.F].New() level_registration_method.SetMetricImageFilter(metric_image_filter) # Set up the multi-resolution registration object @@ -76,7 +76,7 @@ type(fixed_image), type(fixed_image), displacement_image_type, - itk.D].New() + itk.F].New() multi_res_registration_method.SetFixedImage(fixed_image) multi_res_registration_method.SetMovingImage(moving_image) multi_res_registration_method.SetBlockRadiusCalculator(block_radius_calculator) diff --git a/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx b/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx index 165393a7..7b9b2427 100644 --- a/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx +++ b/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx @@ -425,14 +425,14 @@ BayesianRegularizationDisplacementCalculator:: { priorImage = priorImageImageIt.GetPrevious(direction); // If we are inside the boundary. - if (priorImage.GetPointer() != nullptr) + if (priorImage != nullptr) { shift.Fill(0.0); shift[direction] = -1 * spacing[direction]; this->ImpartLikelihood(postImage, priorImage, direction, shift); } priorImage = priorImageImageIt.GetNext(direction); - if (priorImage.GetPointer() != nullptr) + if (priorImage != nullptr) { shift.Fill(0.0); shift[direction] = spacing[direction]; diff --git a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h index 5fefb418..0b53d4b6 100644 --- a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h +++ b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h @@ -71,7 +71,7 @@ class ITK_TEMPLATE_EXPORT MetricImageToDisplacementCalculator : public Object /** Type of the metric image (input pixels). */ using MetricImageType = TMetricImage; - using MetricImagePointerType = typename MetricImageType::Pointer; + using MetricImagePointerType = typename MetricImageType *;//::Pointer; using IndexType = typename MetricImageType::IndexType; /** Type of the displacement image (output). */ diff --git a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx index b5e97b0d..fbc4ad22 100644 --- a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx +++ b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx @@ -99,6 +99,7 @@ itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest(int argc, char regularizer->SetStrainSigma(strainSigma); regularizer->SetMaximumIterations(3); registrationMethod->SetMetricImageToDisplacementCalculator(regularizer); + registrationMethod->Update(); // Break the displacement vector image into components. using TensorComponentsFilterType = itk::SplitComponentsImageFilter; diff --git a/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap index a9784043..c65eec25 100644 --- a/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap +++ b/wrapping/itkBlockMatchingMetricImageToDisplacementCalculator.wrap @@ -1,18 +1,27 @@ set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) - -# Wrap for member types itk_wrap_include("itkPoint.h") itk_wrap_include("itkImage.h") -UNIQUE(point_types "${WRAP_ITK_REAL};D") + +# Wrap for member types +UNIQUE(real_types "${WRAP_ITK_REAL};D") itk_wrap_class("itk::Image" POINTER) - foreach(t ${point_types}) + foreach(t ${real_types}) foreach(d ${ITK_WRAP_IMAGE_DIMS}) - itk_wrap_template("P${ITKM_${t}}${d}" + itk_wrap_template("P${ITKM_${t}}${d}${d}" "itk::Point<${ITKT_${t}}, ${d}>, ${d}") endforeach() endforeach() itk_end_wrap_class() +itk_wrap_class("itk::Image" POINTER) + foreach(t ${WRAP_ITK_REAL}) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_${t}}${d}PTR${d}" + "itk::Image<${ITKT_${t}}, ${d}> *, ${d}") + endforeach() + endforeach() +itk_end_wrap_class() + itk_wrap_include("itkBlockMatchingMetricImageToDisplacementCalculator.h") itk_wrap_class("itk::BlockMatching::MetricImageToDisplacementCalculator" POINTER) foreach(t ${WRAP_ITK_REAL}) diff --git a/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap index 34ff4c71..7b0ada9d 100644 --- a/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap +++ b/wrapping/itkBlockMatchingMultiResolutionImageRegistrationMethod.wrap @@ -4,28 +4,6 @@ itk_wrap_include("itkSmartPointer.h") itk_wrap_include("itkImage.h") itk_wrap_include("itkImageRegion.h") -# Wrap base classes for itk::BlockMatching::MetricImageToDisplacementCalculator public members -#itk_wrap_class("itk::SmartPointer") -# foreach(t ${WRAP_ITK_REAL}) -# foreach(d ${ITK_WRAP_IMAGE_DIMS}) -# itk_wrap_template("I${ITKM_${t}}${d}" "itk::Image<${ITKT_${t}},${d}>") -# endforeach() -# endforeach() -#itk_end_wrap_class() - -message(STATUS ${ITK_WRAP_POINT}) -itk_wrap_class("itk::Image" POINTER) - foreach(d ${ITK_WRAP_IMAGE_DIMS}) - #FIXME - foreach(t ${ITK_WRAP_POINT}) - itk_wrap_template("P${ITKM_${t}}${d}${d}" "itk::Point<${ITKT_${t}},${d}>, ${d}") - endforeach() - foreach(t ${WRAP_ITK_REAL}) - itk_wrap_template("SPI${ITKM_${t}}${d}${d}" "itk::SmartPointer>, ${d}") - endforeach() - endforeach() -itk_end_wrap_class() - # Wrap class hierarchy itk_wrap_include("itkImageToImageFilter.h") itk_wrap_class("itk::ImageToImageFilter" POINTER) From 461879fa74ffa499a426186fec3918d820ec4dd7 Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Fri, 30 Jul 2021 13:30:53 -0400 Subject: [PATCH 5/5] WIP: Fix ImageImagePointerType typename issue --- ...ckMatchingBayesianRegularizationDisplacementCalculator.hxx | 4 ++-- include/itkBlockMatchingMetricImageToDisplacementCalculator.h | 2 +- ...tchingBayesianRegularizationDisplacementCalculatorTest.cxx | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx b/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx index 7b9b2427..445bbdd0 100644 --- a/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx +++ b/include/itkBlockMatchingBayesianRegularizationDisplacementCalculator.hxx @@ -342,8 +342,8 @@ BayesianRegularizationDisplacementCalculator:: typename FaceCalculatorType::FaceListType::iterator fit; MetricImageImagePointerType tempMetricImageImagePtr; - MetricImagePointerType postImage; - MetricImagePointerType priorImage; + //MetricImagePointerType postImage; + //MetricImagePointerType priorImage; m_CurrentIteration = 0; // Hack to make the SplitRequestedRegion method operate on the face list // regions; diff --git a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h index 0b53d4b6..9e70f97a 100644 --- a/include/itkBlockMatchingMetricImageToDisplacementCalculator.h +++ b/include/itkBlockMatchingMetricImageToDisplacementCalculator.h @@ -71,7 +71,7 @@ class ITK_TEMPLATE_EXPORT MetricImageToDisplacementCalculator : public Object /** Type of the metric image (input pixels). */ using MetricImageType = TMetricImage; - using MetricImagePointerType = typename MetricImageType *;//::Pointer; + using MetricImagePointerType = MetricImageType*; // TODO ::Pointer using IndexType = typename MetricImageType::IndexType; /** Type of the displacement image (output). */ diff --git a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx index fbc4ad22..631c0f25 100644 --- a/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx +++ b/test/itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest.cxx @@ -98,6 +98,7 @@ itkBlockMatchingBayesianRegularizationDisplacementCalculatorTest(int argc, char strainSigma[1] = 0.04; regularizer->SetStrainSigma(strainSigma); regularizer->SetMaximumIterations(3); + //regularizer->SetCacheMetricImage(true); registrationMethod->SetMetricImageToDisplacementCalculator(regularizer); registrationMethod->Update();