From 979aa24d1217769d6dbdb442c3bf182a263d4fc0 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 14 Sep 2026 12:44:51 -0500 Subject: [PATCH] STYLE: Remove ITK version guards from Python examples The examples require ITK 6, so checks for ITK 4.7 through 5.2 can never fail. Drop them, along with the sys import they alone used. --- .../VtkGlue/ConvertAnRGBitkImageTovtkImageData/Code.py | 5 ----- src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Code.py | 5 ----- src/Core/Common/AddOffsetToIndex/Code.py | 5 ----- src/Core/Common/StreamAPipeline/Code.py | 5 ----- src/Filtering/Colormap/CreateACustomColormap/Code.py | 5 ----- src/Filtering/ImageFeature/SegmentBloodVessels/Code.py | 5 ----- .../ImageGradient/ApplyGradientRecursiveGaussian/Code.py | 5 ----- .../ApplyGradientRecursiveGaussianWithVectorInput/Code.py | 5 ----- .../Code.py | 5 ----- .../Perform2DTranslationRegistrationWithMeanSquares/Code.py | 5 ----- 10 files changed, 50 deletions(-) diff --git a/src/Bridge/VtkGlue/ConvertAnRGBitkImageTovtkImageData/Code.py b/src/Bridge/VtkGlue/ConvertAnRGBitkImageTovtkImageData/Code.py index e091c134e..d23556f8c 100755 --- a/src/Bridge/VtkGlue/ConvertAnRGBitkImageTovtkImageData/Code.py +++ b/src/Bridge/VtkGlue/ConvertAnRGBitkImageTovtkImageData/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (5, 2, 0): - print("ITK 5.2.0 is required.") - sys.exit(1) - parser = argparse.ArgumentParser( description="Convert An RBG itk Image to vtk Image Data." ) diff --git a/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Code.py b/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Code.py index 3583275bf..f911a6aeb 100755 --- a/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Code.py +++ b/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (5, 2, 0): - print("ITK 5.2.0 is required.") - sys.exit(1) - parser = argparse.ArgumentParser(description="Convert An itk Image to vtk Image Data.") parser.add_argument("input_image") args = parser.parse_args() diff --git a/src/Core/Common/AddOffsetToIndex/Code.py b/src/Core/Common/AddOffsetToIndex/Code.py index 20e827662..0f67a69c7 100755 --- a/src/Core/Common/AddOffsetToIndex/Code.py +++ b/src/Core/Common/AddOffsetToIndex/Code.py @@ -14,13 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 9, 0): - print("ITK 4.9.0 is required.") - sys.exit(1) - Dimension = 2 index = itk.Index[Dimension]() diff --git a/src/Core/Common/StreamAPipeline/Code.py b/src/Core/Common/StreamAPipeline/Code.py index 4b2c4ea52..73a7200d8 100755 --- a/src/Core/Common/StreamAPipeline/Code.py +++ b/src/Core/Common/StreamAPipeline/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 10, 0): - print("ITK 4.10.0 is required.") - sys.exit(1) - parser = argparse.ArgumentParser(description="Stream A Pipeline.") parser.add_argument("number_of_splits", type=int) args = parser.parse_args() diff --git a/src/Filtering/Colormap/CreateACustomColormap/Code.py b/src/Filtering/Colormap/CreateACustomColormap/Code.py index dd084c810..dfb0b6b3f 100755 --- a/src/Filtering/Colormap/CreateACustomColormap/Code.py +++ b/src/Filtering/Colormap/CreateACustomColormap/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 8, 0): - print("ITK 4.8.0 is required (see example documentation).") - sys.exit(1) - parser = argparse.ArgumentParser(description="Create A Custom Colormap.") parser.add_argument("input_image") parser.add_argument("output_image") diff --git a/src/Filtering/ImageFeature/SegmentBloodVessels/Code.py b/src/Filtering/ImageFeature/SegmentBloodVessels/Code.py index 426a3a2c4..afd9f71c0 100755 --- a/src/Filtering/ImageFeature/SegmentBloodVessels/Code.py +++ b/src/Filtering/ImageFeature/SegmentBloodVessels/Code.py @@ -16,13 +16,8 @@ import argparse -import sys import itk -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (5, 0, 0): - print("ITK 5.0.0 or newer is required.") - sys.exit(1) - parser = argparse.ArgumentParser(description="Segment blood vessels.") parser.add_argument("input_image") parser.add_argument("output_image") diff --git a/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussian/Code.py b/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussian/Code.py index eb11c9b64..5ee355e14 100755 --- a/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussian/Code.py +++ b/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussian/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 7, 0): - print("ITK 4.7.0 is required (see example documentation).") - sys.exit(1) - parser = argparse.ArgumentParser(description="Apply Gradient Recursive Gaussian.") parser.add_argument("input_image") parser.add_argument("output_image_x") diff --git a/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussianWithVectorInput/Code.py b/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussianWithVectorInput/Code.py index ae36c87ca..7c1f2c78a 100755 --- a/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussianWithVectorInput/Code.py +++ b/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussianWithVectorInput/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 8, 0): - print("ITK 4.8.0 is required (see example documentation).") - sys.exit(1) - parser = argparse.ArgumentParser( description="Apply Gradient Recursive Gaussian With Vector Input." ) diff --git a/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Code.py b/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Code.py index dd2ff60f8..26799676a 100755 --- a/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Code.py +++ b/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Code.py @@ -16,13 +16,8 @@ import argparse -import sys import itk -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (5, 0, 0): - print("ITK 5.0.0 or newer is required.") - sys.exit(1) - parser = argparse.ArgumentParser( description="Segment blood vessels with multi-scale Hessian-based measure." ) diff --git a/src/Registration/Common/Perform2DTranslationRegistrationWithMeanSquares/Code.py b/src/Registration/Common/Perform2DTranslationRegistrationWithMeanSquares/Code.py index c06cc2dcd..d14750e6a 100755 --- a/src/Registration/Common/Perform2DTranslationRegistrationWithMeanSquares/Code.py +++ b/src/Registration/Common/Perform2DTranslationRegistrationWithMeanSquares/Code.py @@ -14,14 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys import itk import argparse -if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 9, 0): - print("ITK 4.9.0 is required.") - sys.exit(1) - parser = argparse.ArgumentParser( description="Perform 2D Translation Registration With Mean Squares." )