fix(omero): default channel window to array dtype range, not 0-255#59
Merged
Conversation
The OME-Zarr `omero.channels[i].window` block was hardcoded to
`{min: 0, max: 255, start: 0, end: 255}` on every store because
zarrmony constructed `bioio_ome_zarr.writers.Channel(...)` without
passing `window=`. Every uint16 / uint32 / float32 store therefore
shipped with a display window clamped to 8-bit range and appeared
black on first open in napari and OMERO — the acquisition's real
intensities lived far outside the window, so viewers rendered
everything above 255 as saturated white and everything else as noise
near zero.
Fix: derive the window from the reader's dtype at the three
`Channel(...)` construction sites (`api._lif_scene_channels`,
`api._channels_for_scene`, `writers.scene._default_channels`). Integer
dtypes use `np.iinfo(min, max)`; float dtypes use `0.0`/`1.0` (OMERO
convention for normalized floats). `start` / `end` mirror `min` / `max`
so first-open viewers see the full range unclipped — percentile-based
auto-contrast is a separate concern, not this bug.
Closes #50.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
…ndow-dtype-range # Conflicts: # CHANGELOG.md # src/zarrmony/api.py
…ndow-dtype-range # Conflicts: # CHANGELOG.md # src/zarrmony/api.py # src/zarrmony/writers/scene.py
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
omero.channels[i].windowwas hardcoded to{min: 0, max: 255, start: 0, end: 255}on every store because the threebioio_ome_zarr.writers.Channel(...)construction sites in zarrmony passed nowindow=argument. uint16 / uint32 / float32 stores therefore appeared black on first open in napari / OMERO — the display window clamped intensities into an 8-bit band while the acquisition's real pixels lived far outside it.api._lif_scene_channels,api._channels_for_scene,writers.scene._default_channels) via a new_dtype_window(dtype)helper. Integer dtypes usenp.iinfo(min, max); float dtypes use0.0/1.0(OMERO convention for normalized floats).start/endmirrormin/max— percentile-based auto-contrast is a separate concern, out of scope for this fix.FakeReadernow honors adtype=kwarg and exposes a.dtypeproperty mirroring bioio'sReader.dtype, so tests can vary the array dtype without allocating the pixel buffer.Test plan
uv run pytest -q— 347 tests pass_dtype_windowcoveringuint8,uint16,uint32,int16,float32,float64write_scene(parametrized onuint8/uint16/float32) reads backzarr.json'sattributes.ome.omero.channels[i].windowand asserts it matches the dtype range — the acceptance-criteria fixture from the issueconvert()covering the_channels_for_scenename-based path (parametrized dtypes)convert()covering the LIF_lif_scene_channelspath with the 7-channel confocal fixture (parametrized dtypes)uint8still ships{0, 255, 0, 255}(asserted in every parametrized batch)[Unreleased]/FixedCloses #50.
🤖 Generated with Claude Code