From f5cc8f87cc3c1e5dfd1436e0608ea9ef28668fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Fri, 30 Jun 2023 15:41:44 -0400 Subject: [PATCH 1/5] DOC: Correct itkCurvilinearArraySpecialCoordinatesImageFilters.wrap --- .../itkCurvilinearArraySpecialCoordinatesImageFilters.wrap | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wrapping/itkCurvilinearArraySpecialCoordinatesImageFilters.wrap b/wrapping/itkCurvilinearArraySpecialCoordinatesImageFilters.wrap index 79eea72..e32b332 100644 --- a/wrapping/itkCurvilinearArraySpecialCoordinatesImageFilters.wrap +++ b/wrapping/itkCurvilinearArraySpecialCoordinatesImageFilters.wrap @@ -1,10 +1,11 @@ # ITK image filters wrapped for ITKUltrasound `itk::CurvilinearArraySpecialCoordinatesImage` inputs. -# Must be wrapped in a separate file after `itkCurvilinearArraySpecialCoordinates.wrap` so that +# Must be wrapped in a separate file after `itkCurvilinearArraySpecialCoordinatesImage.wrap` so that # SWIG does not implicitly define erroneous overrides for template methods such as # `TransformPhysicalPointToContinuousIndex`, etc. -# See `WRAPPER_SUBMODULE_ORDER` in CMakeLists.txt for where `itkCASCIFilters.wrap` is set to -# always be wrapped after `itkCurvilinearArraySpecialCoordinatesImage.wrap`. +# See `WRAPPER_SUBMODULE_ORDER` in CMakeLists.txt for where +# `itkCurvilinearArraySpecialCoordinatesImageFilters.wrap` is set to +# be wrapped after `itkCurvilinearArraySpecialCoordinatesImage.wrap`. itk_wrap_include("itkCurvilinearArraySpecialCoordinatesImage.h") itk_wrap_class("itk::ImageSource" POINTER) From 8808f7a605287d097c6a40a5f39d1c4c7351efca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Fri, 30 Jun 2023 14:59:17 -0400 Subject: [PATCH 2/5] ENH: Add wrapping for PhasedArray3DSpecialCoordinatesImage and filters --- wrapping/CMakeLists.txt | 1 + ...kPhasedArray3DSpecialCoordinatesImage.wrap | 58 +++++++ ...Array3DSpecialCoordinatesImageFilters.wrap | 150 ++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap create mode 100644 wrapping/itkPhasedArray3DSpecialCoordinatesImageFilters.wrap diff --git a/wrapping/CMakeLists.txt b/wrapping/CMakeLists.txt index 8871650..bbea9ec 100644 --- a/wrapping/CMakeLists.txt +++ b/wrapping/CMakeLists.txt @@ -11,6 +11,7 @@ set(WRAPPER_SUBMODULE_ORDER itkCurvilinearArraySpecialCoordinatesImage itkImageUltrasound # Extra itk::Image wrappings for SupportWindow filters itkCurvilinearArraySpecialCoordinatesImageFilters + itkPhasedArray3DSpecialCoordinatesImage # CASCI needs to come before itkAttenuationImageFilter itkBlockMatchingMetricImageFilter itkBlockMatchingNormalizedCrossCorrelationMetricImageFilter diff --git a/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap b/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap new file mode 100644 index 0000000..50d2d40 --- /dev/null +++ b/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap @@ -0,0 +1,58 @@ +itk_wrap_include("list") +itk_wrap_include("complex") + +# Explicitly override template method wrappings so that implicit +# scalar type is always `double` for greatest precision. +# Adds wrapping overrides to `itkPhasedArray3DSpecialCoordinatesImage_ext.i` configured with +# CMake for input to SWIG wrapping generation. +# See `DECL_PYTHON_IMAGEBASE_CLASS` definition in `ITK/Wrapping/Generators/Python/PyBase/pyBase.i` +# for precedent. +string(APPEND ITK_WRAP_PYTHON_SWIG_EXT " +%inline %{ +#include \"itkContinuousIndexSwigInterface.h\" +%} + +%define DECL_PYTHON_PHASEDARRAY3DSPECIALCOORDINATESIMAGE_CLASS(swig_name, template_params) + + %extend swig_name { + itkIndex##template_params TransformPhysicalPointToIndex(const itkPointD##template_params & point ) { + itkIndex##template_params idx; + self->TransformPhysicalPointToIndex( point, idx ); + return idx; + } + + itkContinuousIndexD##template_params TransformPhysicalPointToContinuousIndex(const itkPointD##template_params & point ) { + itkContinuousIndexD##template_params idx; + self->TransformPhysicalPointToContinuousIndex( point, idx ); + return idx; + } + + itkPointD##template_params TransformContinuousIndexToPhysicalPoint(const itkContinuousIndexD##template_params & idx ) { + itkPointD##template_params point; + self->TransformContinuousIndexToPhysicalPoint( idx, point ); + return point; + } + + itkPointD##template_params TransformIndexToPhysicalPoint(const itkIndex##template_params & idx ) { + itkPointD##template_params point; + self->TransformIndexToPhysicalPoint( idx, point ); + return point; + } + } + +%enddef +") + +# Wrap class for real and complex pixel types. Dimension is always 3. +itk_wrap_class("itk::PhasedArray3DSpecialCoordinatesImage" POINTER_WITH_SUPERCLASS) + foreach(t ${WRAP_ITK_SCALAR}) + itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}") + string(APPEND ITK_WRAP_PYTHON_SWIG_EXT "DECL_PYTHON_PHASEDARRAY3DSPECIALCOORDINATESIMAGE_CLASS(${WRAPPER_SWIG_NAME}${ITKM_${t}}, 3)\n") + endforeach() + foreach(t3 ${WRAP_ITK_COMPLEX_REAL}) + itk_wrap_template("${ITKM_${t3}}" "${ITKT_${t3}}") + string(APPEND ITK_WRAP_PYTHON_SWIG_EXT "DECL_PYTHON_PHASEDARRAY3DSPECIALCOORDINATESIMAGE_CLASS(${WRAPPER_SWIG_NAME}${ITKM_${t3}}, 3)\n") + endforeach() +itk_end_wrap_class() + +# Then wrap consuming filters in itkPhasedArray3DSpecialCoordinatesImageFilters.wrap diff --git a/wrapping/itkPhasedArray3DSpecialCoordinatesImageFilters.wrap b/wrapping/itkPhasedArray3DSpecialCoordinatesImageFilters.wrap new file mode 100644 index 0000000..30e4d34 --- /dev/null +++ b/wrapping/itkPhasedArray3DSpecialCoordinatesImageFilters.wrap @@ -0,0 +1,150 @@ +# ITK image filters wrapped for ITKUltrasound `itk::PhasedArray3DSpecialCoordinatesImage` inputs. +# Must be wrapped in a separate file after `itkPhasedArray3DSpecialCoordinatesImage.wrap` so that +# SWIG does not implicitly define erroneous overrides for template methods such as +# `TransformPhysicalPointToContinuousIndex`, etc. + +# See `WRAPPER_SUBMODULE_ORDER` in CMakeLists.txt for where +# `itkPhasedArray3DSpecialCoordinatesImageFilters.wrap` is set to +# be wrapped after `itkPhasedArray3DSpecialCoordinatesImage.wrap`. + +itk_wrap_include("itkPhasedArray3DSpecialCoordinatesImage.h") +itk_wrap_class("itk::ImageSource" POINTER) + foreach(real_type ${WRAP_ITK_SCALAR}) + itk_wrap_template("PA3DSCI${ITKM_${real_type}}" "itk::PhasedArray3DSpecialCoordinatesImage<${ITKT_${real_type}}>") + endforeach() + foreach(complex_type ${WRAP_ITK_COMPLEX_REAL}) + itk_wrap_template("PA3DSCI${ITKM_${complex_type}}" "itk::PhasedArray3DSpecialCoordinatesImage<${ITKT_${complex_type}}>") + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkImage.h") +itk_wrap_class("itk::ImageToImageFilter" POINTER) + foreach(t ${WRAP_ITK_SCALAR}) + foreach(ut ${WRAP_ITK_INT}) + itk_wrap_template("I${ITKM_${t}}3PA3DSCI${ITKM_${ut}}" + "itk::Image< ${ITKT_${t}}, 3 >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${ut}} >") + endforeach() + foreach(t2 ${WRAP_ITK_SCALAR}) + itk_wrap_template("PA3DSCI${ITKM_${t}}PA3DSCI${ITKM_${t2}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t2}} >") + endforeach() + itk_wrap_template("PA3DSCI${ITKM_${t}}I${ITKM_${t}}3" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, itk::Image< ${ITKT_${t}}, 3>") + endforeach() + + foreach(rt ${WRAP_ITK_REAL}) + foreach(ct ${WRAP_ITK_COMPLEX_REAL}) + itk_wrap_template("PA3DSCI${ITKM_${rt}}PA3DSCI${ITKM_${ct}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${rt}} >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${ct}} >") + itk_wrap_template("PA3DSCI${ITKM_${ct}}PA3DSCI${ITKM_${rt}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${ct}} >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${rt}} >") + endforeach() + endforeach() + + foreach(t3 ${WRAP_ITK_COMPLEX_REAL}) + itk_wrap_template("PA3DSCI${ITKM_${t3}}PA3DSCI${ITKM_${t3}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t3}} >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t3}} >") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::ImageFileReader" POINTER_WITH_SUPERCLASS) + foreach(t ${WRAP_ITK_SCALAR}) + itk_wrap_template("PA3DSCI${ITKM_${t}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::ImageFileWriter" POINTER) + foreach(t ${WRAP_ITK_SCALAR}) + itk_wrap_template("PA3DSCI${ITKM_${t}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::CastImageFilter" POINTER_WITH_2_SUPERCLASSES) + foreach(t1 ${WRAP_ITK_SCALAR}) + foreach(t2 ${WRAP_ITK_SCALAR}) + itk_wrap_template("PA3DSCI${ITKM_${t1}}PA3DSCI${ITKM_${t2}}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t1}} >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t2}} >") + itk_wrap_template("PA3DSCI${ITKM_${t1}}I${ITKM_${t2}}3" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t1}} >, itk::Image< ${ITKT_${t2}}, 3 >") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::RescaleIntensityImageFilter" POINTER_WITH_2_SUPERCLASSES) + foreach(t ${WRAP_ITK_SCALAR}) + foreach(ut ${WRAP_ITK_INT}) + itk_wrap_template("I${ITKM_${t}}3PA3DSCI${ITKM_${ut}}" + "itk::Image< ${ITKT_${t}}, 3 >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${ut}} >") + endforeach() + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkSpectra1DSupportWindowToMaskImageFilter.h") +itk_wrap_class("itk::Spectra1DSupportWindowToMaskImageFilter" POINTER_WITH_2_SUPERCLASSES) + foreach(t ${WRAP_ITK_INT}) + itk_wrap_template("IlistitkIndex33PA3DSCI${ITKM_${t}}" + "itk::Image< std::list< itk::Index< 3 > >, 3 >, itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >") + endforeach() +itk_end_wrap_class() + +# The rest is needed for ResampleImageFilter and interpolator functions +set(resample_filter_pixel_types "F") +if(ITK_WRAP_unsigned_char) + list(APPEND resample_filter_pixel_types "UC") +endif() +itk_wrap_include("itkResampleImageFilter.h") +itk_wrap_class("itk::ResampleImageFilter" POINTER) + foreach(t ${resample_filter_pixel_types}) + itk_wrap_template("PA3DSCI${ITKM_${t}}I${ITKM_${t}}3" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, itk::Image< ${ITKT_${t}}, 3 >") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::ImageFunction" POINTER) + foreach(t ${resample_filter_pixel_types}) + itk_wrap_template("PA3DSCI${ITKM_${t}}${ITKM_D}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, ${ITKT_D}, ${ITKT_D}") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::InterpolateImageFunction" POINTER) + foreach(t ${resample_filter_pixel_types}) + itk_wrap_template("PA3DSCI${ITKM_${t}}${ITKM_D}" "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, ${ITKT_D}") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::NearestNeighborInterpolateImageFunction" POINTER) + foreach(t ${resample_filter_pixel_types}) + itk_wrap_template("PA3DSCI${ITKM_${t}}${ITKM_D}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, ${ITKT_D}") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::LinearInterpolateImageFunction" POINTER) + foreach(t ${resample_filter_pixel_types}) + itk_wrap_template("PA3DSCI${ITKM_${t}}${ITKM_D}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, ${ITKT_D}") + endforeach() +itk_end_wrap_class() + +itk_wrap_class("itk::GaussianInterpolateImageFunction" POINTER) + foreach(t ${resample_filter_pixel_types}) + itk_wrap_template("PA3DSCI${ITKM_${t}}${ITKM_D}" + "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, ${ITKT_D}") + endforeach() +itk_end_wrap_class() + +itk_wrap_include("itkWindowedSincInterpolateImageFunction.h") +set(window_functions "Hamming" "Cosine" "Welch" "Lanczos") +set(radii 2 3) +itk_wrap_class("itk::WindowedSincInterpolateImageFunction" POINTER) + foreach(t ${resample_filter_pixel_types}) + foreach(r ${radii}) # radius + foreach(function ${window_functions}) + itk_wrap_template("PA3DSCI${ITKM_${t}}${r}${function}" "itk::PhasedArray3DSpecialCoordinatesImage< ${ITKT_${t}} >, ${r}, itk::Function::${function}WindowFunction< ${r} >") + endforeach() + endforeach() + endforeach() +itk_end_wrap_class() From ce02933c8d81ccd91233dbe6e33fe1268baa7d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Fri, 30 Jun 2023 16:21:02 -0400 Subject: [PATCH 3/5] COMP: Fix warning C4834: discarding return value Warnings of style: C:\Dev\ITKUltrasound-22\Wrapping\Modules\Ultrasound\itkPhasedArray3DSpecialCoordinatesImagePython.cpp(5263,54): warning C4834: discarding return value of function with 'nodiscard' attribute --- ...kCurvilinearArraySpecialCoordinatesImage.wrap | 16 ++++------------ .../itkPhasedArray3DSpecialCoordinatesImage.wrap | 16 ++++------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/wrapping/itkCurvilinearArraySpecialCoordinatesImage.wrap b/wrapping/itkCurvilinearArraySpecialCoordinatesImage.wrap index 449188a..31feee1 100644 --- a/wrapping/itkCurvilinearArraySpecialCoordinatesImage.wrap +++ b/wrapping/itkCurvilinearArraySpecialCoordinatesImage.wrap @@ -29,27 +29,19 @@ string(APPEND ITK_WRAP_PYTHON_SWIG_EXT " %extend swig_name { itkIndex##template_params TransformPhysicalPointToIndex(const itkPointD##template_params & point ) { - itkIndex##template_params idx; - self->TransformPhysicalPointToIndex( point, idx ); - return idx; + return self->TransformPhysicalPointToIndex( point ); } itkContinuousIndexD##template_params TransformPhysicalPointToContinuousIndex(const itkPointD##template_params & point ) { - itkContinuousIndexD##template_params idx; - self->TransformPhysicalPointToContinuousIndex( point, idx ); - return idx; + return self->TransformPhysicalPointToContinuousIndex( point ); } itkPointD##template_params TransformContinuousIndexToPhysicalPoint(const itkContinuousIndexD##template_params & idx ) { - itkPointD##template_params point; - self->TransformContinuousIndexToPhysicalPoint( idx, point ); - return point; + return self->TransformContinuousIndexToPhysicalPoint( idx ); } itkPointD##template_params TransformIndexToPhysicalPoint(const itkIndex##template_params & idx ) { - itkPointD##template_params point; - self->TransformIndexToPhysicalPoint( idx, point ); - return point; + return self->TransformIndexToPhysicalPoint( idx ); } } diff --git a/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap b/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap index 50d2d40..19f4077 100644 --- a/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap +++ b/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap @@ -16,27 +16,19 @@ string(APPEND ITK_WRAP_PYTHON_SWIG_EXT " %extend swig_name { itkIndex##template_params TransformPhysicalPointToIndex(const itkPointD##template_params & point ) { - itkIndex##template_params idx; - self->TransformPhysicalPointToIndex( point, idx ); - return idx; + return self->TransformPhysicalPointToIndex( point ); } itkContinuousIndexD##template_params TransformPhysicalPointToContinuousIndex(const itkPointD##template_params & point ) { - itkContinuousIndexD##template_params idx; - self->TransformPhysicalPointToContinuousIndex( point, idx ); - return idx; + return self->TransformPhysicalPointToContinuousIndex( point ); } itkPointD##template_params TransformContinuousIndexToPhysicalPoint(const itkContinuousIndexD##template_params & idx ) { - itkPointD##template_params point; - self->TransformContinuousIndexToPhysicalPoint( idx, point ); - return point; + return self->TransformContinuousIndexToPhysicalPoint( idx ); } itkPointD##template_params TransformIndexToPhysicalPoint(const itkIndex##template_params & idx ) { - itkPointD##template_params point; - self->TransformIndexToPhysicalPoint( idx, point ); - return point; + return self->TransformIndexToPhysicalPoint( idx ); } } From 43179d3f1ebfea774801d54efc0ef95d84a81317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 4 Jul 2023 10:05:31 -0400 Subject: [PATCH 4/5] ENH: Add Python tests for PhasedArray3DSpecialCoordinatesImage --- ...y3DITKNearestNeighborTestOutput.mha.sha512 | 1 + ...rray3DITKWindowedSincTestOutput.mha.sha512 | 1 + ...nConvertPhasedArray3DTestOutput.mha.sha512 | 1 + ...anConvertPhasedArray3DTestInput.mha.sha512 | 1 + wrapping/test/CMakeLists.txt | 54 ++++++++++++- wrapping/test/PythonPhasedArray3DResample.py | 75 +++++++++++++++++++ 6 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 create mode 100644 test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 create mode 100644 test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 create mode 100644 test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 create mode 100644 wrapping/test/PythonPhasedArray3DResample.py diff --git a/test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 b/test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 new file mode 100644 index 0000000..0a2d3b4 --- /dev/null +++ b/test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 @@ -0,0 +1 @@ +8fc8129454b6ec93fb5c133d9835f8a49df0ab14584d44b3454e1b36dee60ef92e29bb9e8c3b9a1340129877fc0ec81d7beb5022eaf3bcbbed8fa3ebab8e6c74 diff --git a/test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 b/test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 new file mode 100644 index 0000000..d5d6f96 --- /dev/null +++ b/test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 @@ -0,0 +1 @@ +cf4bac01a2692100f1c2b2445f3468b26c754e380f4d0119b466c079639f309ad18f775106f341a72c6126a7a636d55c494ed40edf441de262418ff65b2a792e diff --git a/test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 b/test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 new file mode 100644 index 0000000..d545bf6 --- /dev/null +++ b/test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 @@ -0,0 +1 @@ +6e589887b660f79513d1c09479cc70bd815e532e013fcb3bb185a21c641e417210d6a8286199a265b8e6b9159254e6237108539d0c5eb865a7bedb03d64cbf50 diff --git a/test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 b/test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 new file mode 100644 index 0000000..489744f --- /dev/null +++ b/test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 @@ -0,0 +1 @@ +7d5e6c2b070107a279277c48ead400bab15edd7aaa1b1b2238a8437da1435c41f75c3b2323fdba17f6415d10ea37992ff053f52a5f6d7a0937f78cfaf1f3687a \ No newline at end of file diff --git a/wrapping/test/CMakeLists.txt b/wrapping/test/CMakeLists.txt index 1931366..b1ee703 100644 --- a/wrapping/test/CMakeLists.txt +++ b/wrapping/test/CMakeLists.txt @@ -40,7 +40,7 @@ itk_python_add_test(NAME PythonCurvilinearArraySpecialCoordinatesImageTemplateMe COMMAND PythonCurvilinearArraySpecialCoordinatesImageTemplateMethodsTest.py ) -itk_python_expression_add_test(NAME PythonInstantiateGaussianInterpolateImageFunction +itk_python_expression_add_test(NAME PythonInstantiateGaussianInterpolateImageFunctionCASCI EXPRESSION "iFunc = itk.GaussianInterpolateImageFunction[itk.CurvilinearArraySpecialCoordinatesImage[itk.UC, 2], itk.D].New()" ) @@ -58,6 +58,58 @@ itk_python_add_test(NAME PythonCurvilinearResampleTest --first-sample-distance 26.4 ) +itk_python_expression_add_test(NAME PythonInstantiateGaussianInterpolateImageFunctionPA3DSCI + EXPRESSION "iFunc = itk.GaussianInterpolateImageFunction[itk.PhasedArray3DSpecialCoordinatesImage[itk.F], itk.D].New()" + ) + +itk_python_add_test(NAME PythonPhasedArray3DResampleNearestTest + TEST_DRIVER_ARGS + --compareIntensityTolerance 1 + --compare + DATA{${test_baseline_dir}/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha} + ${ITK_TEST_OUTPUT_DIR}/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha + COMMAND PythonPhasedArray3DResample.py + -i DATA{${test_input_dir}/ScanConvertPhasedArray3DTestInput.mha} + -o ${ITK_TEST_OUTPUT_DIR}/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha + --azimuth-angular-separation 0.0872665 + --elevation-angular-separation 0.0174533 + --radius-sample-size 0.2 + --first-sample-distance 8.0 + --interpolation-type nearest + ) + +itk_python_add_test(NAME PythonPhasedArray3DResampleLinearTest + TEST_DRIVER_ARGS + --compareIntensityTolerance 1 + --compare + DATA{${test_baseline_dir}/ScanConvertPhasedArray3DTestOutput.mha} + ${ITK_TEST_OUTPUT_DIR}/ScanConvertPhasedArray3DTestOutput.mha + COMMAND PythonPhasedArray3DResample.py + -i DATA{${test_input_dir}/ScanConvertPhasedArray3DTestInput.mha} + -o ${ITK_TEST_OUTPUT_DIR}/ScanConvertPhasedArray3DTestOutput.mha + --azimuth-angular-separation 0.0872665 + --elevation-angular-separation 0.0174533 + --radius-sample-size 0.2 + --first-sample-distance 8.0 + # --interpolation-type linear # linear is the default + ) + +itk_python_add_test(NAME PythonPhasedArray3DResampleSincTest + TEST_DRIVER_ARGS + --compareIntensityTolerance 1 + --compare + DATA{${test_baseline_dir}/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha} + ${ITK_TEST_OUTPUT_DIR}/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha + COMMAND PythonPhasedArray3DResample.py + -i DATA{${test_input_dir}/ScanConvertPhasedArray3DTestInput.mha} + -o ${ITK_TEST_OUTPUT_DIR}/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha + --azimuth-angular-separation 0.0872665 + --elevation-angular-separation 0.0174533 + --radius-sample-size 0.2 + --first-sample-distance 8.0 + --interpolation-type sinc + ) + itk_python_add_test(NAME PythonBackscatterImageFilterTest0 TEST_DRIVER_ARGS --compareIntensityTolerance 0.01 diff --git a/wrapping/test/PythonPhasedArray3DResample.py b/wrapping/test/PythonPhasedArray3DResample.py new file mode 100644 index 0000000..70c5598 --- /dev/null +++ b/wrapping/test/PythonPhasedArray3DResample.py @@ -0,0 +1,75 @@ +#========================================================================== +# +# 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 +# +# https://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 math +import argparse + +import itk + +parser = argparse.ArgumentParser(description="Estimate three back-scatter coefficients.") +parser.add_argument("-i", "--input-image", required=True) +parser.add_argument("-o", "--output-image", required=True) +parser.add_argument("-a", "--azimuth-angular-separation", type=float, required=True) +parser.add_argument("-e", "--elevation-angular-separation", type=float, required=True) +parser.add_argument("-r", "--radius-sample-size", type=float, required=True) +parser.add_argument("-f", "--first-sample-distance", type=float, required=True) +parser.add_argument("-t", "--interpolation-type", choices=["nearest", "linear", "sinc"], default="linear") +args = parser.parse_args() + +itk.auto_progress(2) + +pixel_type = itk.UC +dimension = 3 +image_type = itk.PhasedArray3DSpecialCoordinatesImage[pixel_type] +reader = itk.ImageFileReader[image_type].New() +reader.SetFileName(args.input_image) +reader.Update() +image = reader.GetOutput() +image.DisconnectPipeline() + +image.SetAzimuthAngularSeparation(args.azimuth_angular_separation) +image.SetElevationAngularSeparation(args.elevation_angular_separation) +image.SetFirstSampleDistance(args.first_sample_distance) +image.SetRadiusSampleSize(args.radius_sample_size) +print(image) + +print("Verify resampling works with PhasedArray3DSpecialCoordinatesImage input") +output_size = [128] * dimension +output_spacing = [0.2] * dimension +origin0 = -1 * output_spacing[0] * output_size[0] / 2.0 +origin1 = -1 * output_spacing[1] * output_size[1] / 2.0 +origin2 = 0.0; +output_origin = [origin0, origin1, origin2] + +if args.interpolation_type == "nearest": + interpolator = itk.NearestNeighborInterpolateImageFunction.New(image) +elif args.interpolation_type == "linear": + interpolator = itk.LinearInterpolateImageFunction.New(image) +elif args.interpolation_type == "sinc": + window_type = itk.LanczosWindowFunction[dimension] + interpolator = itk.WindowedSincInterpolateImageFunction[type(image), dimension, window_type].New() + +result = itk.resample_image_filter( + image, + size=output_size, + output_spacing=output_spacing, + output_origin=output_origin, + interpolator=interpolator, + ) +itk.imwrite(result, args.output_image, compression=True) +print(f"Result image written to: {args.output_image}") From 6f6fc8f6d2fac00bbe3b505d8ba00164884891da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 4 Jul 2023 12:57:09 -0400 Subject: [PATCH 5/5] ENH: Bump version number to 0.6.2 --- .github/workflows/build-test-package.yml | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml index 252f6cc..1a9d073 100644 --- a/.github/workflows/build-test-package.yml +++ b/.github/workflows/build-test-package.yml @@ -4,13 +4,13 @@ on: [push,pull_request] jobs: cxx-build-workflow: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@f2191a014a93c0d0e7b9e7ffb32d2e1118fb2876 + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@edd0a4350396f533e9ec3755ed6c5af5ddfedb97 with: itk-module-deps: 'MeshToPolyData@v0.10.0:BSplineGradient@v0.3.0:HigherOrderAccurateGradient@v1.2.0:SplitComponents@v2.1.0:Strain@v0.4.0' warnings-to-ignore: "\"pointer is null\" \"in a call to non-static member function\"" python-build-workflow: - uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@f2191a014a93c0d0e7b9e7ffb32d2e1118fb2876 + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@edd0a4350396f533e9ec3755ed6c5af5ddfedb97 with: itk-module-deps: 'InsightSoftwareConsortium/ITKMeshToPolyData@v0.10.0:InsightSoftwareConsortium/ITKBSplineGradient@v0.3.0:InsightSoftwareConsortium/ITKHigherOrderAccurateGradient@v1.2.0:InsightSoftwareConsortium/ITKSplitComponents@v2.1.0:KitwareMedical/ITKStrain@v0.4.0' secrets: diff --git a/setup.py b/setup.py index 2d88456..67b778c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='itk-ultrasound', - version='0.6.1', + version='0.6.2', author='Matthew McCormick', author_email='matt.mccormick@kitware.com', packages=['itk'],