Repository navigation
ENH: Write the demo's OME-Zarr transform as a sequence of elastix stages - #417
Merged
Merged
Conversation
The registered image's OZX and the standalone transform OZX now write the fixed-to-moving transform as an RFC-5 `sequence` of elastix's stages, in the order a point passes through them, instead of the single affine they compose to: - `translation`: a `translation`; - `rigid`: a nested `sequence` of a `rotation` and then a `translation`, since RFC-5 has no rigid type and a `rotation` carries no offset; - `affine`: an `affine`. Each stage is converted on its own. The translation and rigid stages are expressed in the fixed image's intrinsic frame and the affine stage also carries the change into the moving image's, so the translation stays a pure translation and the rotation a proper rotation (RFC-5 requires a determinant of one) even when the two images disagree about an axis direction. The sequence composes to the previous affine up to rounding. For a caller-supplied stage list, the change of frame goes on the last affine stage, with later stages in the moving frame, or onto a trailing `change_of_frame` affine when no stage is an affine. `assertTransformMatchesSystems` now validates every stage, including the rotation's orthonormal rows and determinant, which the v0.6 writer does not check. The decision note, README, and architecture overview describe the new layout, and the unit and Playwright tests check the stage structure and that the stages compose to the whole-list affine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
@N-Dekker splitting the OME-Zarr transform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The demo app writes the fixed-to-moving transform as an RFC-5 coordinate transformation in two places: the registered image's
.ozxand the standalone transform.ozx. Until now that was a singleaffine, the product of all the elastix stages. It is now asequencewith one named entry per stage, listed in the order a point passes through them:translationtranslationrigidsequenceof arotation, then atranslationaffineaffineWhy
translationover an equivalentaffine. It has no rigid type, and itsrotationcarries no offset, so the rigid stage is a nestedrotation+translationsequence.Implementation details
buildFixedToMovingTransform(src/io/rfc5-transform.ts) converts each stage separately with ngff-zarr'sitkTransformToNgffTransform. ITK applies the last transform in its composite list first, so the list is reversed into RFC-5 order, where the first entry is applied first.change_of_frameaffine is appended, unless the change is exactly the identity.assertTransformMatchesSystemsnow checks every stage, nested ones included. It checks matrix sizes, finite values, and that each rotation is orthonormal with determinant 1, which the v0.6 writer does not check.docs/decisions/ome-zarr-transform-output.mdgains sections on the one-transformation-per-stage layout and on the frame each stage is written in. The README and architecture overview are updated to match.Testing
pnpm test:unit): all 310 pass.rfc5-transform.tscoverage is 98.5% of lines and 100% of functions. The new tests cover:ngffTransformToItkTransformwith a flipped axis;change_of_frameis appended;test/outputs.spec.ts,test/register-3d.spec.ts, Chromium): 15/15 pass. They check the written stage structure for 2D and 3D registrations and that the embedded and standalone transforms match.🤖 Generated with Claude Code