Skip to content

ENH: Adding filter and wrapping for casting within SO hierarchy#1576

Merged
aylward merged 4 commits intoInsightSoftwareConsortium:masterfrom
aylward:CastSpatialObject
Jan 29, 2020
Merged

ENH: Adding filter and wrapping for casting within SO hierarchy#1576
aylward merged 4 commits intoInsightSoftwareConsortium:masterfrom
aylward:CastSpatialObject

Conversation

@aylward
Copy link
Member

@aylward aylward commented Jan 27, 2020

This new Cast filter allows all of a specific type of children of a
SpatialObjuct to be returned in a list, where the list elements are typed to
specifically match the type requested. Compare with the existing
GetChildren() function, where the return list's elements are cast to
the top level SpatialObject class.

The modifications to the CMakeLists.txt file in the wrapping directory
allows lists of spatial objects and lists of spatial object points to be
accessed via array indexes.

When wrapped for python, these changes enable the following code:

castSO = itk.CastSpatialObjectFilter[3].New()
castSO.SetInput(myGroup)
tubesList = castSO.GetTubes()

tube = tubesList[0]

print(tube.GetPoints()[0].GetPositionInObjectSpace())

This new Cast filter allows all of a specific type of children of a
SpatialObjuct to be returned in a list, where the list elements are typed to
specifically match the type requested.    Compare with the existing
GetChildren() function, where the return list's elements are cast to
the top level SpatialObject class.

The modifications to the CMakeLists.txt file in the wrapping directory
allows lists of spatial objects and lists of spatial object points to be
accessed via array indexes.

When wrapped for python, these changes enable the following code:

> castSO = itk.CastSpatialObjectFilter[3].New()
> castSO.SetInput(myGroup)
> tubesList = castSO.GetTubes()
>
> tube = tubesList[0]
>
> print(tube.GetPoints()[0].GetPositionInObjectSpace())
Use ITK_DISALLOW macro.
Improve variable naming.
Remove commented code.
Reduce cmake code redundancy via loop.
@aylward
Copy link
Member Author

aylward commented Jan 29, 2020

Failing tests seem to be unrelated. Python.GetClassName and Python.Extras failures seem unrelated.

Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be squashed upon merge.

@blowekamp
Copy link
Member

blowekamp commented Jan 29, 2020

I see the CastSpatialObjectFilter is only derived from itk::Object and not the itk::ProcessObject. I believe the naming convention would say the class should be called a Calculator or maybe Converter but not filter.

@aylward aylward merged commit b8b70a2 into InsightSoftwareConsortium:master Jan 29, 2020
@aylward
Copy link
Member Author

aylward commented Jan 29, 2020 via email

@blowekamp
Copy link
Member

Per the ITK style guide:

  • Filter A class that participates in the data processing pipeline. Filters typically take one or more inputs and produce one or more outputs.

This class is not pipelined and does not meet the concept of a Filter. Therefore it goes against ITK's naming conventions. I don't think Calculator is particularly good either. Maybe Mapper?
Caster? Do you have any alternatives?

@aylward
Copy link
Member Author

aylward commented Jan 29, 2020 via email

@blowekamp
Copy link
Member

That would be OK to me or maybe SpatialObjectCaster.

Thanks.

@aylward
Copy link
Member Author

aylward commented Jan 29, 2020 via email

@aylward
Copy link
Member Author

aylward commented Jan 29, 2020 via email

@thewtex
Copy link
Member

thewtex commented Jan 30, 2020

@aylward nice work on this!! 🥇

Anyone have an opinion on CastSpatialObject vs SpatialObjectCaster?

It is an odd duck, 🦆 but CastSpatialObjectFilter is better than the proposed alternatives. It does not inherit from ProcessObject; but, this transforms objects from inputs to outputs, so it fits the general definition of "filter". We do not have any other Caster's in the toolkit.

@aylward
Copy link
Member Author

aylward commented Jan 30, 2020 via email

@aylward aylward deleted the CastSpatialObject branch April 7, 2020 19:35
hjmjohnson added a commit that referenced this pull request Sep 21, 2025
Closed issues:
  CMake configure warning with CMake 3.30 and newer #1579

Merged pull requests:

pkgconfig: drop unused libraries from Libs.private #1591 (bgilbert)
Fix CMake warning: Compatibility with CMake < 3.10 will be removed #1580 (dzenanz)
code documentation updates #1576 (weanti)
Fixed ICC profile copy failure on write #1574 (mircomir)
opj_jp2_read_header: Check for error after parsing header. #1573 (sebras) (CVE-2025-54874)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants