Use ChannelFiller so that indexed data is read as RGB#57
Merged
tlambert03 merged 7 commits intoimaging-formats:mainfrom Feb 23, 2026
Merged
Use ChannelFiller so that indexed data is read as RGB#57tlambert03 merged 7 commits intoimaging-formats:mainfrom
tlambert03 merged 7 commits intoimaging-formats:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
tlambert03
reviewed
Feb 22, 2026
Member
|
thanks! I've done my homework now and I agree it's the right fix. just to leave an escape hatch though, I added a |
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.
Closes:
#41
Copilot (GPT-5.3-Codex) originally identified the source of the issue with GIF handling. It suggested a pretty complex refactor to mimic Fiji behavior, by checking the file name or metadata and then using the ChannelFiller plus ChannelSeparator. This yielded C=3, rgb False, but I dont think it's actually the correct behavior. As the palette consists of RGB values, the returned image should be RGB not multichannel. If we skip the ChannelSeparator requirement, it makes it much simpler to implement, because ChannelFiller should be safe to use on non-indexed data:
https://downloads.openmicroscopy.org/bio-formats/8.4.0/api/loci/formats/ChannelFiller.html
I added some tests and did some testing of my own with napari and everything seems good.
Some
np.asarray(data)timing tests, e.g. with CMU-1 do show a 30-200 ms hit, but my LIF don't show any 🤷Alternatives would be to just use extension to check for gif? i think png can also be indexed? not sure what else honestly. Checking using the reader and core_metadata can work but that's essentially what ChannelFiller checks:
https://github.com/ome/bioformats/blob/eddfa670652145530db288bc8d4aa2f3b245c75a/components/formats-bsd/src/loci/formats/ChannelFiller.java#L49
Edit: Also fixes an issue caught by copilot that
rgb_countwas not set properly in core_metadata.