Skip to content

fix: detect voxel-cell convention from OME-Zarr LOD translation pattern#664

Merged
aganders3 merged 2 commits into
mainfrom
aganders3/voxel-cell-convention
May 12, 2026
Merged

fix: detect voxel-cell convention from OME-Zarr LOD translation pattern#664
aganders3 merged 2 commits into
mainfrom
aganders3/voxel-cell-convention

Conversation

@aganders3

@aganders3 aganders3 commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Multiscale pyramids may use one of two conventions for the origin of each LOD: the corner or the center of the first voxel. To correct for this offset, a zarr will include a half-voxel-per-LOD translation pattern ("voxel-center" convention trans_k = trans_{k-1} + 0.5 * (scale_k - scale_{k-1})) or with constant translations across LODs ("voxel-corner" convention). Both are valid; the choice is set by the dataset author, but not declared anywhere explicitly.

Without normalization, downstream code (chunk visibility, rendering placement) gets the wrong extent for one or the other convention. We see both conventions in our sample data.

This fix detects the convention per-axis in inferSourceDimensionMap by checking whether each LOD's translation delta matches the half-voxel prediction. For center-convention dimensions, we shift translations by -0.5 * scale per-axis per-LOD. After this, chunk.offset = trans + chunkIdx * chunkSize * scale is always the voxel-cell corner, and the rest of our code can use [offset, offset + shape * scale] without regard for the source data convention.

See here the before/after of the "marmoset neurons" dataset. Note the offset in the corner, resolved by this PR (all corners look good after this change). The effect can be severe in 3D datasets with many levels (e.g. the exaSPIM dataset added in #662).

Screenshot 2026-05-11 at 4 02 40 PM Screenshot 2026-05-11 at 4 02 30 PM

This effect can be especially jarring in 3D data where the "fallback" chunks show a very different slice compared to the current LOD.

Related Issue

Closes #369

Tests & Checks

Tested four datasets: zebrahub, ca wave dynamics, marmoset neurons, and exaSPIM

@aganders3 aganders3 requested a review from shlomnissan May 12, 2026 13:36
@aganders3

Copy link
Copy Markdown
Collaborator Author

Here is a demonstration where the effect when zooming is quite jarring:

on main

Screen.Recording.2026-05-12.at.11.57.42.AM.mov

with this PR

Screen.Recording.2026-05-12.at.11.58.00.AM.mov

@shlomnissan shlomnissan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@aganders3 aganders3 merged commit bce8555 into main May 12, 2026
11 checks passed
@czi-github-helper

Copy link
Copy Markdown

🎉 This PR is included in version 0.21.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@aganders3 aganders3 deleted the aganders3/voxel-cell-convention branch May 12, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow image layers rendering offset to be configured

2 participants