diff --git a/setup.py b/setup.py index 67b778c..f1aab1f 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ keywords='ITK InsightToolkit ultrasound imaging', url=r'https://www.insight-journal.org/browse/publication/722', install_requires=[ - r'itk>=5.3.0', + r'itk>=5.4.0', r'itk-meshtopolydata>=0.10.0', r'itk-bsplinegradient>=0.2.10', r'itk-higherorderaccurategradient>=1.2.0', diff --git a/test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 b/test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 deleted file mode 100644 index 0a2d3b4..0000000 --- a/test/Baseline/ScanConvertPhasedArray3DITKNearestNeighborTestOutput.mha.sha512 +++ /dev/null @@ -1 +0,0 @@ -8fc8129454b6ec93fb5c133d9835f8a49df0ab14584d44b3454e1b36dee60ef92e29bb9e8c3b9a1340129877fc0ec81d7beb5022eaf3bcbbed8fa3ebab8e6c74 diff --git a/test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 b/test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 deleted file mode 100644 index d5d6f96..0000000 --- a/test/Baseline/ScanConvertPhasedArray3DITKWindowedSincTestOutput.mha.sha512 +++ /dev/null @@ -1 +0,0 @@ -cf4bac01a2692100f1c2b2445f3468b26c754e380f4d0119b466c079639f309ad18f775106f341a72c6126a7a636d55c494ed40edf441de262418ff65b2a792e diff --git a/test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 b/test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 deleted file mode 100644 index d545bf6..0000000 --- a/test/Baseline/ScanConvertPhasedArray3DTestOutput.mha.sha512 +++ /dev/null @@ -1 +0,0 @@ -6e589887b660f79513d1c09479cc70bd815e532e013fcb3bb185a21c641e417210d6a8286199a265b8e6b9159254e6237108539d0c5eb865a7bedb03d64cbf50 diff --git a/test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 b/test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 deleted file mode 100644 index 489744f..0000000 --- a/test/Input/ScanConvertPhasedArray3DTestInput.mha.sha512 +++ /dev/null @@ -1 +0,0 @@ -7d5e6c2b070107a279277c48ead400bab15edd7aaa1b1b2238a8437da1435c41f75c3b2323fdba17f6415d10ea37992ff053f52a5f6d7a0937f78cfaf1f3687a \ No newline at end of file diff --git a/wrapping/CMakeLists.txt b/wrapping/CMakeLists.txt index faddb31..79e888e 100644 --- a/wrapping/CMakeLists.txt +++ b/wrapping/CMakeLists.txt @@ -8,7 +8,6 @@ endif() itk_wrap_module(Ultrasound) set(WRAPPER_SUBMODULE_ORDER - itkSpecialCoordinatesImage itkCurvilinearArraySpecialCoordinatesImage itkCurvilinearArraySpecialCoordinatesImageFilters itkSliceSeriesSpecialCoordinatesImage diff --git a/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap b/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap deleted file mode 100644 index 19f4077..0000000 --- a/wrapping/itkPhasedArray3DSpecialCoordinatesImage.wrap +++ /dev/null @@ -1,50 +0,0 @@ -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 ) { - return self->TransformPhysicalPointToIndex( point ); - } - - itkContinuousIndexD##template_params TransformPhysicalPointToContinuousIndex(const itkPointD##template_params & point ) { - return self->TransformPhysicalPointToContinuousIndex( point ); - } - - itkPointD##template_params TransformContinuousIndexToPhysicalPoint(const itkContinuousIndexD##template_params & idx ) { - return self->TransformContinuousIndexToPhysicalPoint( idx ); - } - - itkPointD##template_params TransformIndexToPhysicalPoint(const itkIndex##template_params & idx ) { - return self->TransformIndexToPhysicalPoint( idx ); - } - } - -%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 deleted file mode 100644 index 2faa512..0000000 --- a/wrapping/itkPhasedArray3DSpecialCoordinatesImageFilters.wrap +++ /dev/null @@ -1,150 +0,0 @@ -# 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) - 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() diff --git a/wrapping/itkSpecialCoordinatesImage.wrap b/wrapping/itkSpecialCoordinatesImage.wrap deleted file mode 100644 index 962e469..0000000 --- a/wrapping/itkSpecialCoordinatesImage.wrap +++ /dev/null @@ -1,13 +0,0 @@ -itk_wrap_include("complex") - -# Wrap underlying class hierarchy -itk_wrap_class("itk::SpecialCoordinatesImage" POINTER) - foreach(d ${ITK_WRAP_IMAGE_DIMS}) - foreach(t ${WRAP_ITK_SCALAR}) - itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}}, ${d}") - endforeach() - foreach(t3 ${WRAP_ITK_COMPLEX_REAL}) - itk_wrap_template("${ITKM_${t3}}${d}" "${ITKT_${t3}}, ${d}") - endforeach() - endforeach() -itk_end_wrap_class() diff --git a/wrapping/test/CMakeLists.txt b/wrapping/test/CMakeLists.txt index 62a27e2..057bce4 100644 --- a/wrapping/test/CMakeLists.txt +++ b/wrapping/test/CMakeLists.txt @@ -73,58 +73,6 @@ itk_python_add_test(NAME PythonSliceSeriesResampleTest -o ${ITK_TEST_OUTPUT_DIR}/itkSliceSeriesSpecialCoordinatesImageTestPython.mha ) -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 deleted file mode 100644 index 70c5598..0000000 --- a/wrapping/test/PythonPhasedArray3DResample.py +++ /dev/null @@ -1,75 +0,0 @@ -#========================================================================== -# -# 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}")