Commit bce8555
authored
fix: detect voxel-cell convention from OME-Zarr LOD translation pattern (#664)
### 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).
<img width="830" height="1017" alt="Screenshot 2026-05-11 at 4 02 40 PM"
src="https://github.com/user-attachments/assets/62bfd649-a951-40df-b56f-bb161906667d"
/>
<img width="830" height="1017" alt="Screenshot 2026-05-11 at 4 02 30 PM"
src="https://github.com/user-attachments/assets/cf572110-0722-4a16-afee-b257af2caac7"
/>
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
exaSPIM1 parent 06bab9c commit bce8555
1 file changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
| |||
199 | 211 | | |
200 | 212 | | |
201 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
0 commit comments