Skip to content

Add ByDimension.to_affine() - #93

Merged
clbarnes merged 1 commit into
clbarnes:mainfrom
ccp-volume-em:by-dimension-to-affine
Nov 1, 2026
Merged

clbarnes merged 1 commit into
clbarnes:mainfrom
ccp-volume-em:by-dimension-to-affine

Conversation

@folterj

@folterj folterj commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Add ByDimension.to_affine()

ByDimension inherits Transform.to_affine(), which returns None, so any TransformSequence containing it can't be simplified to an affine. This shows up with OME-Zarr 0.6 byDimension coordinate transformations: ome-zarr-py builds the scene graph with transformnd, and napari-ome-zarr's Scene needs seq.simplify().to_affine(), so it raises "Affine transformation could not be computed" for scenes using byDimension.

This adds ByDimension.to_affine(): each subtransform's linear map and translation are placed in the rows of its output axes and the columns of its input axes. It returns None if any subtransform can't be converted to affine.

Tests compare to_affine().apply() with apply() for filled-in identity, map axis + scale, a sequence with translation onto swapped axes, and crossed axes. They also cover use within a TransformSequence, and the None case.

With this change, a byDimension scene opens in napari-ome-zarr.

🤖 Generated with Claude Code

Combine the subtransforms' affines, placing each linear map and translation
in the rows of its output axes and the columns of its input axes; None if
any subtransform can't be converted to affine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clbarnes

clbarnes commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Thanks Joost! This will presumably be particularly important for multi-channel images. I'll get this released ASAP so that the downstream packages can update their dependency, as I'm sure some people would like to play with it this week!

@clbarnes
clbarnes merged commit 788cd3c into clbarnes:main Nov 1, 2026
9 checks passed
@folterj
folterj deleted the by-dimension-to-affine branch November 2, 2026 09:24
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.

2 participants