Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap LabelSetMeasures in LabelOverlapMeasuresImageFilter #4221

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dzenanz
Copy link
Member

@dzenanz dzenanz commented Sep 19, 2023

This exposes the return value from itk::LabelOverlapMeasuresImageFilter::GetLabelSetMeasures() as a Python dictionary instead of <Swig Object of type 'std::unordered_map< unsigned char,itkLabelOverlapMeasuresImageFilterIUC3::LabelSetMeasures > *'>. This is needed for convenient use of the class from Python.

PR Checklist

@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Python wrapping Python bindings for a class area:Filtering Issues affecting the Filtering module labels Sep 19, 2023
@dzenanz dzenanz force-pushed the lsmLabelOverlap branch 2 times, most recently from 76a9429 to bf14387 Compare September 20, 2023 15:27
@github-actions github-actions bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct type:Data Changes to testing data labels Sep 27, 2023
@dzenanz
Copy link
Member Author

dzenanz commented Sep 28, 2023

Currently running into:

3024: Loading ITKImageStatistics... done
3024: Running itkLabelOverlapMeasuresImageFilterIUC3... Running itkLabelOverlapMeasuresImageFilterIUC3... done
3024: done
3024: Traceback (most recent call last):
3024:   File "C:\Dev\ITK-git\Modules\Filtering\ImageStatistics\wrapping\test\itkLabelOverlapMeasuresImageFilterTest.py", line 33, in <module>
3024:     for label, measure in lsm.items():
3024:                           ^^^^^^^^^
3024: AttributeError: 'SwigPyObject' object has no attribute 'items'
3024: swig/python detected a memory leak of type 'std::unordered_map< unsigned char,itkLabelOverlapLabelSetMeasures,std::hash< unsigned char >,std::equal_to< unsigned char >,std::allocator< std::pair< unsigned char const,itkLabelOverlapLabelSetMeasures > > > *', no destructor found.
3024: itkTestDriver: Process exited with return value: 1

@thewtex
Copy link
Member

thewtex commented Sep 29, 2023

What is dir(lsm)?

@dzenanz
Copy link
Member Author

dzenanz commented Sep 29, 2023

dir(lsm) is ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'acquire', 'append', 'disown', 'next', 'own']

@dzenanz dzenanz added this to the ITK 5.4.0 milestone Oct 12, 2023
@thewtex
Copy link
Member

thewtex commented May 2, 2024

@dzenanz could you please rebase and push? I am wondering if recent SWIG updates have helped.

dzenanz added 2 commits May 2, 2024 16:47
This exposes the return value from
itk::LabelOverlapMeasuresImageFilter::GetLabelSetMeasures()
as a Python dictionary instead of
<Swig Object of type 'std::unordered_map< unsigned char,itkLabelOverlapMeasuresImageFilterIUC3::LabelSetMeasures > *'>
This is needed for convenient use of the class from Python.
The class has been un-nested to make wrapping easier/possible.
@dzenanz dzenanz force-pushed the lsmLabelOverlap branch from 6962a00 to 828b59a Compare May 2, 2024 20:48
@thewtex thewtex modified the milestones: ITK 5.4.0, ITK 5.4.1 May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Filtering Issues affecting the Filtering module area:Python wrapping Python bindings for a class type:Data Changes to testing data type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants