ENH: Add ConvertCompositionToItkTransform to ElastixRegistrationMethod - #1464
Conversation
The existing `ConvertToItkTransform` appears inconvenient for composition transforms, as it may cause end-users to "downcast" the return value to `itk::CompositeTransform`.
|
Interesting compile errors on Azure Pipelines, from MacOS, at https://dev.azure.com/kaspermarstal/d9c40921-2d83-43b7-b98b-be691988c03a/_apis/build/builds/6261/logs/52 However, I'll ignore them for now, as they appear unrelated to this PR! |
|
@N-Dekker Thanks for flagging this! The issue is that the newer libtorch requires C++20, while ImpactElastix is currently built with C++17. I think the clean fix is to enable C++20 only for the IMPACT component: if(USE_ImpactMetric) That way we don’t need to move all of Elastix to C++20. |
Thanks @vboussot ! Just wondering:
Do you have a clue?
Indeed, because I'm not sure if it is already time for Elastix to drop C++17, and move to C++20. Elastix usually "follows" the latest released version of ITK with compiler/language upgrades. |
|
@N-Dekker Yes, I think the difference is simply that both CI systems build LibTorch from source on macOS, because recent PyTorch binaries are not available for macOS Intel. GitHub Actions pins PyTorch to v2.8.0, while Azure currently clones PyTorch without a tag, so it builds the latest main, which now requires C++20. So pinning the Azure macOS build to the same PyTorch version should fix it. |
|
Thanks for explaining, @vboussot Is this somehow related to your PR #1463? I mean, when Elastix would use https://github.com/InsightSoftwareConsortium/ITKIMPACT, would the Elastix CI no longer need to pin the PyTorch version? |
|
@N-Dekker Yes, it is related to #1463, but using ITKIMPACT does not remove the PyTorch dependency. In that PR I improved the LibTorch setup for Linux and Windows: the appropriate PyTorch/LibTorch package is now provided through pip instead of manually downloading the binaries. Unfortunately macOS remains a special case. The CI runners are Intel, and recent PyTorch wheels are no longer provided for macOS x86_64, so LibTorch still has to be built from source there. We therefore still need to pin the PyTorch version for the macOS build. |
Are you sure these CI runners are still Intel? Pull request #1387 commit d189229 (merged on Dec 5, 2025) has upgraded the CI from macos-13 to macos-14, and as far as I understand, the macos-14 VM of Azure and GitHub Actions is ARM64! Would that make things easier? Maybe I should have informed you about pull request #1387 before🤷 I still opened a discussion of elastix Intel support, though: #1322 |
|
@N-Dekker I actually tried using the macOS PyTorch wheels, but ran into issues with the current CI setup. At the moment, building LibTorch from source is the only approach I found that works reliably there. |
|
@vboussot Do you mean that even on ARM64 runners like macos-14, it is still necessary to build LibTorch from source? |
|
Only on Azure, and the image name is misleading: both CIs run GitHub Actions is ARM64, and the wheel already works there. In #1463 all three OSes get LibTorch from That job passes, so the source build is gone from GitHub Actions. The Azure agent is x86_64 throughout. From the LibTorch configure step of the same PR's Azure build: NEON is ARM's SIMD, SSE2/SSE4 are x86's. So this is not a matter of picking a different Python interpreter: the whole toolchain is x86_64, and pip resolves x86_64 wheels for every package there ( PyTorch publishes no macOS x86_64 wheel past 2.2.2, so there is nothing to install on that agent. It keeps building LibTorch from source, now pinned to That pin is also what fixes the failure you reported: cloning |
…t in Example 23 Comment what block_info[0]["array-location"] holds in resample_block, note that elastix's ConvertCompositionToItkTransform (SuperElastix/elastix#1464) removes the need for the cast once ITKElastix ships it, and state that a single scale factor is enough for registration alone. Re-executed with saved outputs.
The existing
ConvertToItkTransformappears inconvenient for composition transforms, as it may cause end-users to "downcast" the return value toitk::CompositeTransform.