Skip to content

Commit 629076d

Browse files
tbirdsodzenanz
authored andcommitted
BUG: Resolve curvilinear image template method wrapping conflicts
Changes: - Updated wrapping for `itk::CurvilinearArraySpecialCoordinatesImage` with explicit overrides for template methods for transforming between physical and image space. - Moved image filters wrapped for `itk::CurvilinearArraySpecialCoordinatesImage` into a separate wrap file so that template method generation no longer conficts with explict override generated from curvilinear image wrap file. - Re-enabled `itk::ResampleImageFilter` wrapping for curvilinear image input. - Added Python test to verify output from fixed `itk::CurvilinearArraySpecialCoordinatesImage` template methods matches in both C++ and Python Resolves #171. Depends on #202.
1 parent 58e4bcc commit 629076d

5 files changed

Lines changed: 242 additions & 96 deletions

wrapping/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ endif()
99
itk_wrap_module(Ultrasound)
1010
set(WRAPPER_SUBMODULE_ORDER
1111
itkCurvilinearArraySpecialCoordinatesImage
12+
itkCurvilinearArraySpecialCoordinatesImageFilters
1213
itkAttenuationImageFilter
1314
itkBlockMatchingMetricImageFilter
1415
itkBlockMatchingNormalizedCrossCorrelationMetricImageFilter
@@ -21,9 +22,10 @@ set(WRAPPER_SUBMODULE_ORDER
2122
itkAnalyticSignalImageFilter
2223
itkBModeImageFilter
2324
itkSpeckleReducingAnisotropicDiffusionImageFilter
24-
itkImageToImageFilter
25+
itkImageToImageFilter # Extra wrappings for Spectra1D filters
2526
itkSpectra1DAveragingImageFilter
2627
itkSpectra1DNormalizeImageFilter
27-
)
28+
)
29+
2830
itk_auto_load_submodules()
2931
itk_end_wrap_module()
Lines changed: 46 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
itk_wrap_include("list")
22
itk_wrap_include("complex")
33

4-
itk_wrap_class("itk::CurvilinearArraySpecialCoordinatesImage" POINTER_WITH_SUPERCLASS)
4+
# Wrap underlying class hierarchy
5+
itk_wrap_class("itk::SpecialCoordinatesImage" POINTER)
56
foreach(d ${ITK_WRAP_IMAGE_DIMS})
67
foreach(t ${WRAP_ITK_SCALAR})
78
itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}}, ${d}")
@@ -12,110 +13,61 @@ itk_wrap_class("itk::CurvilinearArraySpecialCoordinatesImage" POINTER_WITH_SUPER
1213
endforeach()
1314
itk_end_wrap_class()
1415

15-
itk_wrap_include("itkImageSource.h")
16-
itk_wrap_class("itk::ImageSource" POINTER)
17-
foreach(d ${ITK_WRAP_IMAGE_DIMS})
18-
foreach(real_type ${WRAP_ITK_SCALAR})
19-
itk_wrap_template("CASCI${ITKM_${real_type}}${d}" "itk::CurvilinearArraySpecialCoordinatesImage<${ITKT_${real_type}},${d}>")
20-
endforeach()
21-
foreach(complex_type ${WRAP_ITK_COMPLEX_REAL})
22-
itk_wrap_template("CASCI${ITKM_${complex_type}}${d}" "itk::CurvilinearArraySpecialCoordinatesImage<${ITKT_${complex_type}},${d}>")
23-
endforeach()
24-
endforeach()
25-
itk_end_wrap_class()
2616

27-
itk_wrap_include("itkCastImageFilter.h")
28-
itk_wrap_class("itk::CastImageFilter" POINTER_WITH_2_SUPERCLASSES)
29-
foreach(d ${ITK_WRAP_IMAGE_DIMS})
30-
foreach(t1 ${WRAP_ITK_SCALAR})
31-
foreach(t2 ${WRAP_ITK_SCALAR})
32-
itk_wrap_template("CASCI${ITKM_${t1}}${d}CASCI${ITKM_${t2}}${d}"
33-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t1}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t2}}, ${d} >")
34-
itk_wrap_template("CASCI${ITKM_${t1}}${d}I${ITKM_${t2}}${d}"
35-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t1}}, ${d} >, itk::Image< ${ITKT_${t2}}, ${d} >")
36-
endforeach()
37-
endforeach()
38-
endforeach()
39-
itk_end_wrap_class()
17+
# Explicitly override template method wrappings so that implicit
18+
# scalar type is always `double` for greatest precision.
19+
# Adds wrapping overrides to `itkCurvilinearArraySpecialCoordinatesImage_ext.i` configured with
20+
# CMake for input to SWIG wrapping generation.
21+
# See `DECL_PYTHON_IMAGEBASE_CLASS` definition in `ITK/Wrapping/Generators/Python/PyBase/pyBase.i`
22+
# for precedent.
23+
string(APPEND ITK_WRAP_PYTHON_SWIG_EXT "
24+
%inline %{
25+
#include \"itkContinuousIndexSwigInterface.h\"
26+
%}
4027

41-
itk_wrap_include("itkRescaleIntensityImageFilter.h")
42-
itk_wrap_class("itk::RescaleIntensityImageFilter" POINTER_WITH_2_SUPERCLASSES)
43-
foreach(d ${ITK_WRAP_IMAGE_DIMS})
44-
foreach(t ${WRAP_ITK_SCALAR})
45-
foreach(ut ${WRAP_ITK_INT})
46-
itk_wrap_template("I${ITKM_${t}}${d}CASCI${ITKM_${ut}}${d}"
47-
"itk::Image< ${ITKT_${t}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ut}}, ${d} >")
48-
endforeach()
49-
endforeach()
50-
endforeach()
51-
itk_end_wrap_class()
28+
%define DECL_PYTHON_CURVILINEARARRAYSPECIALCOORDINATESIMAGE_CLASS(swig_name, template_params)
5229

53-
itk_wrap_class("itk::ImageToImageFilter" POINTER)
54-
foreach(d ${ITK_WRAP_IMAGE_DIMS})
55-
foreach(t ${WRAP_ITK_SCALAR})
56-
foreach(ut ${WRAP_ITK_INT})
57-
itk_wrap_template("I${ITKM_${t}}${d}CASCI${ITKM_${ut}}${d}"
58-
"itk::Image< ${ITKT_${t}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ut}}, ${d} >")
59-
endforeach()
60-
foreach(t2 ${WRAP_ITK_SCALAR})
61-
itk_wrap_template("CASCI${ITKM_${t}}${d}CASCI${ITKM_${t2}}${d}"
62-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t2}}, ${d} >")
63-
endforeach()
64-
endforeach()
30+
%extend swig_name {
31+
itkIndex##template_params TransformPhysicalPointToIndex(const itkPointD##template_params & point ) {
32+
itkIndex##template_params idx;
33+
self->TransformPhysicalPointToIndex<double>( point, idx );
34+
return idx;
35+
}
6536

66-
foreach(rt ${WRAP_ITK_REAL})
67-
foreach(ct ${WRAP_ITK_COMPLEX_REAL})
68-
itk_wrap_template("CASCI${ITKM_${rt}}${d}CASCI${ITKM_${ct}}${d}"
69-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${rt}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ct}}, ${d} >")
70-
itk_wrap_template("CASCI${ITKM_${ct}}${d}CASCI${ITKM_${rt}}${d}"
71-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ct}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${rt}}, ${d} >")
72-
endforeach()
73-
endforeach()
37+
itkContinuousIndexD##template_params TransformPhysicalPointToContinuousIndex(const itkPointD##template_params & point ) {
38+
itkContinuousIndexD##template_params idx;
39+
self->TransformPhysicalPointToContinuousIndex<double>( point, idx );
40+
return idx;
41+
}
7442

75-
foreach(t3 ${WRAP_ITK_COMPLEX_REAL})
76-
itk_wrap_template("CASCI${ITKM_${t3}}${d}CASCI${ITKM_${t3}}${d}"
77-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t3}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t3}}, ${d} >")
78-
endforeach()
79-
endforeach()
80-
itk_end_wrap_class()
43+
itkPointD##template_params TransformContinuousIndexToPhysicalPoint(const itkContinuousIndexD##template_params & idx ) {
44+
itkPointD##template_params point;
45+
self->TransformContinuousIndexToPhysicalPoint<double>( idx, point );
46+
return point;
47+
}
8148

82-
itk_wrap_class("itk::ImageFileReader" POINTER_WITH_SUPERCLASS)
83-
foreach(d ${ITK_WRAP_IMAGE_DIMS})
84-
foreach(t ${WRAP_ITK_SCALAR})
85-
itk_wrap_template("CASCI${ITKM_${t}}${d}"
86-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >")
87-
endforeach()
88-
endforeach()
89-
itk_end_wrap_class()
49+
itkPointD##template_params TransformIndexToPhysicalPoint(const itkIndex##template_params & idx ) {
50+
itkPointD##template_params point;
51+
self->TransformIndexToPhysicalPoint<double>( idx, point );
52+
return point;
53+
}
54+
}
55+
56+
%enddef
57+
")
9058

91-
itk_wrap_class("itk::ImageFileWriter" POINTER)
59+
# Wrap class for real and complex pixel types
60+
itk_wrap_class("itk::CurvilinearArraySpecialCoordinatesImage" POINTER_WITH_SUPERCLASS)
9261
foreach(d ${ITK_WRAP_IMAGE_DIMS})
9362
foreach(t ${WRAP_ITK_SCALAR})
94-
itk_wrap_template("CASCI${ITKM_${t}}${d}"
95-
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >")
63+
itk_wrap_template("${ITKM_${t}}${d}" "${ITKT_${t}}, ${d}")
64+
string(APPEND ITK_WRAP_PYTHON_SWIG_EXT "DECL_PYTHON_CURVILINEARARRAYSPECIALCOORDINATESIMAGE_CLASS(${WRAPPER_SWIG_NAME}${ITKM_${t}}${d}, ${d})\n")
9665
endforeach()
97-
endforeach()
98-
itk_end_wrap_class()
99-
100-
#itk_wrap_include("itkResampleImageFilter.h")
101-
#itk_wrap_class("itk::ResampleImageFilter" POINTER_WITH_2_SUPERCLASSES)
102-
# foreach(d ${ITK_WRAP_IMAGE_DIMS})
103-
# foreach(t1 ${WRAP_ITK_SCALAR})
104-
# foreach(t2 ${WRAP_ITK_SCALAR})
105-
# itk_wrap_template("CASCI${ITKM_${t1}}${d}I${ITKM_${t2}}${d}"
106-
# "itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t1}}, ${d} >, itk::Image< ${ITKT_${t2}}, ${d} >")
107-
# endforeach()
108-
# endforeach()
109-
# endforeach()
110-
#itk_end_wrap_class()
111-
112-
itk_wrap_include("itkSpectra1DSupportWindowToMaskImageFilter.h")
113-
itk_wrap_class("itk::Spectra1DSupportWindowToMaskImageFilter" POINTER_WITH_2_SUPERCLASSES)
114-
foreach(d ${ITK_WRAP_IMAGE_DIMS})
115-
foreach(t ${WRAP_ITK_INT})
116-
itk_wrap_template("IlistitkIndex${d}${d}CASCI${ITKM_${t}}${d}"
117-
"itk::Image< std::list< itk::Index< ${d} > >, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >")
66+
foreach(t3 ${WRAP_ITK_COMPLEX_REAL})
67+
itk_wrap_template("${ITKM_${t3}}${d}" "${ITKT_${t3}}, ${d}")
68+
string(APPEND ITK_WRAP_PYTHON_SWIG_EXT "DECL_PYTHON_CURVILINEARARRAYSPECIALCOORDINATESIMAGE_CLASS(${WRAPPER_SWIG_NAME}${ITKM_${t3}}${d}, ${d})\n")
11869
endforeach()
11970
endforeach()
12071
itk_end_wrap_class()
12172

73+
# Then wrap consuming filters in itkCurvilinearArraySpecialCoordinatesImageFilters.wrap
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# ITK image filters wrapped for ITKUltrasound `itk::CurvilinearArraySpecialCoordinatesImage` inputs.
2+
# Must be wrapped in a separate file after `itkCurvilinearArraySpecialCoordinates.wrap` so that
3+
# SWIG does not implicitly define erroneous overrides for template methods such as
4+
# `TransformPhysicalPointToContinuousIndex`, etc.
5+
6+
# See `WRAPPER_SUBMODULE_ORDER` in CMakeLists.txt for where `itkCASCIFilters.wrap` is set to
7+
# always be wrapped after `itkCurvilinearArraySpecialCoordinatesImage.wrap`.
8+
9+
itk_wrap_include("itkCurvilinearArraySpecialCoordinatesImage.h")
10+
itk_wrap_class("itk::ImageSource" POINTER)
11+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
12+
foreach(real_type ${WRAP_ITK_SCALAR})
13+
itk_wrap_template("CASCI${ITKM_${real_type}}${d}" "itk::CurvilinearArraySpecialCoordinatesImage<${ITKT_${real_type}},${d}>")
14+
endforeach()
15+
foreach(complex_type ${WRAP_ITK_COMPLEX_REAL})
16+
itk_wrap_template("CASCI${ITKM_${complex_type}}${d}" "itk::CurvilinearArraySpecialCoordinatesImage<${ITKT_${complex_type}},${d}>")
17+
endforeach()
18+
endforeach()
19+
itk_end_wrap_class()
20+
21+
itk_wrap_include("itkImage.h")
22+
itk_wrap_class("itk::ImageToImageFilter" POINTER)
23+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
24+
foreach(t ${WRAP_ITK_SCALAR})
25+
foreach(ut ${WRAP_ITK_INT})
26+
itk_wrap_template("I${ITKM_${t}}${d}CASCI${ITKM_${ut}}${d}"
27+
"itk::Image< ${ITKT_${t}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ut}}, ${d} >")
28+
endforeach()
29+
foreach(t2 ${WRAP_ITK_SCALAR})
30+
itk_wrap_template("CASCI${ITKM_${t}}${d}CASCI${ITKM_${t2}}${d}"
31+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t2}}, ${d} >")
32+
endforeach()
33+
itk_wrap_template("CASCI${ITKM_${t}}${d}I${ITKM_${t}}${d}"
34+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >, itk::Image< ${ITKT_${t}}, ${d}>")
35+
endforeach()
36+
37+
foreach(rt ${WRAP_ITK_REAL})
38+
foreach(ct ${WRAP_ITK_COMPLEX_REAL})
39+
itk_wrap_template("CASCI${ITKM_${rt}}${d}CASCI${ITKM_${ct}}${d}"
40+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${rt}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ct}}, ${d} >")
41+
itk_wrap_template("CASCI${ITKM_${ct}}${d}CASCI${ITKM_${rt}}${d}"
42+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ct}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${rt}}, ${d} >")
43+
endforeach()
44+
endforeach()
45+
46+
foreach(t3 ${WRAP_ITK_COMPLEX_REAL})
47+
itk_wrap_template("CASCI${ITKM_${t3}}${d}CASCI${ITKM_${t3}}${d}"
48+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t3}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t3}}, ${d} >")
49+
endforeach()
50+
endforeach()
51+
itk_end_wrap_class()
52+
53+
itk_wrap_class("itk::ImageFileReader" POINTER_WITH_SUPERCLASS)
54+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
55+
foreach(t ${WRAP_ITK_SCALAR})
56+
itk_wrap_template("CASCI${ITKM_${t}}${d}"
57+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >")
58+
endforeach()
59+
endforeach()
60+
itk_end_wrap_class()
61+
62+
itk_wrap_class("itk::ImageFileWriter" POINTER)
63+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
64+
foreach(t ${WRAP_ITK_SCALAR})
65+
itk_wrap_template("CASCI${ITKM_${t}}${d}"
66+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >")
67+
endforeach()
68+
endforeach()
69+
itk_end_wrap_class()
70+
71+
itk_wrap_class("itk::CastImageFilter" POINTER_WITH_2_SUPERCLASSES)
72+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
73+
foreach(t1 ${WRAP_ITK_SCALAR})
74+
foreach(t2 ${WRAP_ITK_SCALAR})
75+
itk_wrap_template("CASCI${ITKM_${t1}}${d}CASCI${ITKM_${t2}}${d}"
76+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t1}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t2}}, ${d} >")
77+
itk_wrap_template("CASCI${ITKM_${t1}}${d}I${ITKM_${t2}}${d}"
78+
"itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t1}}, ${d} >, itk::Image< ${ITKT_${t2}}, ${d} >")
79+
endforeach()
80+
endforeach()
81+
endforeach()
82+
itk_end_wrap_class()
83+
84+
itk_wrap_class("itk::RescaleIntensityImageFilter" POINTER_WITH_2_SUPERCLASSES)
85+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
86+
foreach(t ${WRAP_ITK_SCALAR})
87+
foreach(ut ${WRAP_ITK_INT})
88+
itk_wrap_template("I${ITKM_${t}}${d}CASCI${ITKM_${ut}}${d}"
89+
"itk::Image< ${ITKT_${t}}, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${ut}}, ${d} >")
90+
endforeach()
91+
endforeach()
92+
endforeach()
93+
itk_end_wrap_class()
94+
95+
itk_wrap_include("itkResampleImageFilter.h")
96+
itk_wrap_class("itk::ResampleImageFilter" POINTER)
97+
itk_wrap_template("CASCIF2IF2"
98+
"itk::CurvilinearArraySpecialCoordinatesImage< float, 2 >, itk::Image< float, 2 >")
99+
itk_end_wrap_class()
100+
101+
itk_wrap_include("itkSpectra1DSupportWindowToMaskImageFilter.h")
102+
itk_wrap_class("itk::Spectra1DSupportWindowToMaskImageFilter" POINTER_WITH_2_SUPERCLASSES)
103+
foreach(d ${ITK_WRAP_IMAGE_DIMS})
104+
foreach(t ${WRAP_ITK_INT})
105+
itk_wrap_template("IlistitkIndex${d}${d}CASCI${ITKM_${t}}${d}"
106+
"itk::Image< std::list< itk::Index< ${d} > >, ${d} >, itk::CurvilinearArraySpecialCoordinatesImage< ${ITKT_${t}}, ${d} >")
107+
endforeach()
108+
endforeach()
109+
itk_end_wrap_class()

wrapping/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ itk_python_add_test(NAME PythonSpectra1DNormalizeImageFilterTest
3535
DATA{${test_input_dir}/spectra_pixel_image.mha}
3636
${ITK_TEST_OUTPUT_DIR}/itkSpectra1DNormalizeImageFilterTest.mha
3737
)
38+
39+
itk_python_add_test(NAME PythonCurvilinearArraySpecialCoordinatesImageTemplateMethodsTest
40+
COMMAND PythonCurvilinearArraySpecialCoordinatesImageTemplateMethodsTest.py
41+
)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#==========================================================================
2+
#
3+
# Copyright NumFOCUS
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0.txt
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#==========================================================================*/
18+
19+
# Verify itk.CurvilinearArraySpecialCoordinatesImage template methods
20+
# are properly wrapped and behave correctly
21+
22+
import math
23+
import itk
24+
itk.auto_progress(2)
25+
26+
pixel_type = itk.F
27+
dimension = 2
28+
image_type = itk.CurvilinearArraySpecialCoordinatesImage[pixel_type, dimension]
29+
30+
# Set up image
31+
image = image_type.New()
32+
image_size = [2048, 241]
33+
image.SetRegions(image_size)
34+
image.Allocate()
35+
36+
# Metadata is taken from itkCurvilinearArraySpecialCoordinatesImageTest.cxx
37+
lateral_angular_separation = (math.pi / 2.0 + 0.5) / (itk.size(image)[1] - 1)
38+
radius_start = 26.4
39+
radius_stop = 131.5
40+
radius_sample_size = (radius_stop - radius_start) / (itk.size(image)[0] - 1)
41+
42+
image.SetLateralAngularSeparation(lateral_angular_separation)
43+
image.SetFirstSampleDistance(radius_start)
44+
image.SetRadiusSampleSize(radius_sample_size)
45+
print(image)
46+
47+
# Try transforming first index [0,0]
48+
continuous_index = itk.ContinuousIndex[itk.D, 2]()
49+
print(f'Continuous index: {continuous_index}')
50+
51+
expected_point = itk.Point[itk.D,2]([-22.7057, 13.4688])
52+
point = image.TransformContinuousIndexToPhysicalPoint(continuous_index)
53+
print(f'Expected point: Transformed point: {point}')
54+
assert all([abs(el1 - el2) < 1e-3 for el1, el2 in zip(list(point), list(expected_point))]), f'Output point {point} differs from expectation {expected_point}'
55+
56+
transformed_continuous_index = image.TransformPhysicalPointToContinuousIndex(point)
57+
print(f'Transformed continuous index: {continuous_index}')
58+
assert transformed_continuous_index == continuous_index, f'Output {transformed_continuous_index} differs from expectation {continuous_index}'
59+
60+
# Try transforming last index [2047, 240]
61+
continuous_index[0] = 2047
62+
continuous_index[1] = 240
63+
print(f'Continuous index: {continuous_index}')
64+
65+
expected_point = itk.Point[itk.D,2]([113.099, 67.0891])
66+
point = image.TransformContinuousIndexToPhysicalPoint(continuous_index)
67+
print(f'Transformed point: {point}')
68+
assert all([abs(el1 - el2) < 1e-3 for el1, el2 in zip(list(point), list(expected_point))]), f'Output point {point} differs from expectation {expected_point}'
69+
70+
transformed_continuous_index = image.TransformPhysicalPointToContinuousIndex(point)
71+
print(f'Transformed continuous index: {continuous_index}')
72+
assert transformed_continuous_index == continuous_index, f'Output {transformed_continuous_index} differs from expectation {continuous_index}'
73+
74+
# Verify resampling works with curvilinear image input
75+
output_size = [800] * dimension
76+
output_spacing = [0.15] * dimension
77+
output_origin = [output_size[0] * output_spacing[0] / -2.0,
78+
radius_start * math.cos(math.pi / 4.0)]
79+
_ = itk.resample_image_filter(image, size=output_size, output_spacing=output_spacing, output_origin=output_origin)

0 commit comments

Comments
 (0)