Skip to content

COMP: Keep GeodesicActiveContour example working on ITK 5.4 and 6.0 - #476

Draft
hjmjohnson wants to merge 2 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix/levelsetnode-container-index-type
Draft

COMP: Keep GeodesicActiveContour example working on ITK 5.4 and 6.0#476
hjmjohnson wants to merge 2 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix/levelsetnode-container-index-type

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

SegmentWithGeodesicActiveContourLevelSet/Code.py hard-codes itk.VectorContainer[itk.UI, LevelSetNode], which ITK 6.0 no longer wraps after InsightSoftwareConsortium/ITK#6803. Selecting the index type at runtime keeps the example working on both 5.4 and 6.0.

Stacked on #475 — that PR fixes an unrelated pre-commit deadlock that blocks --all-files on main. Review only the second commit here; this becomes a one-commit PR once #475 merges.

Why a single spelling cannot cover both

ITK#6803 changes LevelSetTypeDefault::NodeContainer from VectorContainer<unsigned int, NodeType> to the one-argument VectorContainer<NodeType>, whose index type is SizeValueType, and updates ITKFastMarchingBase.wrap accordingly.

The wrapping registry is keyed by the mangled name emitted by that one itk_wrap_template call, so the two spellings are strictly disjoint across the version boundary — there is no release where both resolve:

ITK itk.VectorContainer[itk.UI, LevelSetNode] itk.VectorContainer[itk.IT, LevelSetNode]
5.4.x resolves TemplateTypeError
6.0 TemplateTypeError resolves

Confirmed empirically against ITK 5.4.6, and ITKFastMarchingBase.wrap is byte-identical at v5.4.7, release-5.4 and main-before-#6803. itk.TemplateTypeError subclasses TypeError, which is what the guard catches.

Test

Ran the example end to end against ITK 5.4.6 on BrainProtonDensitySlice.png (the except branch, which ITK's own CI cannot reach): exit 0, 171 iterations, RMS change 0.0198, output written.

NodeType is also hoisted so the template is spelled once rather than twice.

…ists

src/External and src/GPU hold no examples yet, but src/CMakeLists.txt
calls add_subdirectory() on both, so each needs a CMakeLists.txt. With
those files empty, gersemi wrote a lone newline and end-of-file-fixer
stripped it back, so `pre-commit run --all-files` never converged.
Documenting why the files exist gives both hooks something to agree on.

Also applies gersemi's pending reformat of
ComputeCurvatureAnisotropicDiffusion/CMakeLists.txt.
ITK 6.0 wraps VectorContainer<IdentifierType, LevelSetNode<...>>; ITK 5.4
wraps VectorContainer<unsigned int, LevelSetNode<...>>. The two mangled
template keys are disjoint, so a single spelling cannot run on both.

Verified against ITK 5.4.6: the example completes in 171 iterations with
RMS change 0.0198.
@github-actions github-actions Bot added area:Filtering Issues affecting the Filtering module area:Segmentation Issues affecting the Segmentation module type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots language:Python Changes to Python examples labels Sep 2, 2026
@hjmjohnson
hjmjohnson marked this pull request as ready for review September 2, 2026 14:01
@hjmjohnson
hjmjohnson marked this pull request as draft September 2, 2026 16:22

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Rebase on main before merging.

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:Segmentation Issues affecting the Segmentation module language:Python Changes to Python examples type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants