From 76a94292f4f145c24b5aff6dd705dc0159c35acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 19 Sep 2023 16:01:10 -0400 Subject: [PATCH] ENH: Wrap LabelSetMeasures in LabelOverlapMeasuresImageFilter This exposes the return value from itk::LabelOverlapMeasuresImageFilter::GetLabelSetMeasures() as a Python dictionary instead of *'> This is needed for convenient use of the class from Python. --- .../Filtering/ImageStatistics/wrapping/CMakeLists.txt | 4 ++++ .../wrapping/itkLabelOverlapMeasuresImageFilter.i | 10 ++++++++++ ...belOverlapMeasuresImageFilter_LabelSetMeasures.wrap | 4 ++++ Wrapping/Generators/Python/PyBase/pyBase.i | 1 + 4 files changed, 19 insertions(+) create mode 100644 Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter.i create mode 100644 Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter_LabelSetMeasures.wrap diff --git a/Modules/Filtering/ImageStatistics/wrapping/CMakeLists.txt b/Modules/Filtering/ImageStatistics/wrapping/CMakeLists.txt index 61d2168cffbd..52986d8dd3ed 100644 --- a/Modules/Filtering/ImageStatistics/wrapping/CMakeLists.txt +++ b/Modules/Filtering/ImageStatistics/wrapping/CMakeLists.txt @@ -1,2 +1,6 @@ itk_wrap_module(ITKImageStatistics) +if(ITK_WRAP_PYTHON) + set(WRAPPER_SUBMODULE_ORDER itkLabelOverlapMeasuresImageFilter_LabelSetMeasures) + list(APPEND WRAPPER_SWIG_LIBRARY_FILES "${CMAKE_CURRENT_LIST_DIR}/itkLabelOverlapMeasuresImageFilter.i") +endif() itk_auto_load_and_end_wrap_submodules() diff --git a/Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter.i b/Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter.i new file mode 100644 index 000000000000..1a4d5b89109f --- /dev/null +++ b/Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter.i @@ -0,0 +1,10 @@ +%include + +%template(hashmapUCLOMIFLSM) std::unordered_map< unsigned char, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapSCLOMIFLSM) std::unordered_map< signed char, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapUSLOMIFLSM) std::unordered_map< unsigned short, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapSSLOMIFLSM) std::unordered_map< signed short, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapULLOMIFLSM) std::unordered_map< unsigned long, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapSLLOMIFLSM) std::unordered_map< signed long, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapULLLOMIFLSM) std::unordered_map< unsigned long long, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; +%template(hashmapSLLLOMIFLSM) std::unordered_map< signed long long, itk::LabelOverlapMeasuresImageFilter::LabelSetMeasures >; diff --git a/Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter_LabelSetMeasures.wrap b/Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter_LabelSetMeasures.wrap new file mode 100644 index 000000000000..1536ec1612ca --- /dev/null +++ b/Modules/Filtering/ImageStatistics/wrapping/itkLabelOverlapMeasuresImageFilter_LabelSetMeasures.wrap @@ -0,0 +1,4 @@ +set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) +itk_wrap_include("itkLabelOverlapMeasuresImageFilter.h") +itk_wrap_simple_class("itk::LabelOverlapMeasuresImageFilter >::LabelSetMeasures") +set(WRAPPER_AUTO_INCLUDE_HEADERS ON) diff --git a/Wrapping/Generators/Python/PyBase/pyBase.i b/Wrapping/Generators/Python/PyBase/pyBase.i index 431f4632d43a..b69b0fbf0e61 100644 --- a/Wrapping/Generators/Python/PyBase/pyBase.i +++ b/Wrapping/Generators/Python/PyBase/pyBase.i @@ -23,6 +23,7 @@ from . import _ITKCommonPython %include %include %include +%include %include %include