Skip to content

feat(converter): automatic channel color detection#47

Draft
BrianWhitneyAI wants to merge 2 commits into
mainfrom
feature/auto-channel-colors
Draft

feat(converter): automatic channel color detection#47
BrianWhitneyAI wants to merge 2 commits into
mainfrom
feature/auto-channel-colors

Conversation

@BrianWhitneyAI

@BrianWhitneyAI BrianWhitneyAI commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves #25

Adds automatic channel display color detection to the OME-Zarr converter. Previously every channel was written with a hardcoded white (#FFFFFF) OMERO color; now each channel gets a meaningful color derived from its metadata.

This ports the recipe from #42 (the standalone get_channel_colors experiment) and wires it into OmeZarrConverter so colors are assigned during conversion without any caller changes. Targets feature/v3-direct-czi-read since it builds on that branch.

Color policy (applied per channel)

  1. Brightfield / transmitted-light → white, and does not consume a fluorescent palette slot. Detected from OME contrast_method / illumination_type, with a channel-name fallback (BF, TL, DIC, "phase contrast", …).
  2. Recognized fluorophore → its true emission color via the FLUOROPHORE_COLORS table (e.g. GFP → green, TaRFP → orange, AF647 → red). Matches the OME fluor field or the channel name.
  3. Everything else → a count-based, perceptually-distinct fallback palette (green / green+magenta / cyan-yellow-magenta / +Okabe-Ito colorblind-safe), ordered by emission wavelength when all channels expose it. Black is never assigned.

So identity wins when known, and the distinct palette fills the rest.

Changes

  • New bioio_conversion/channel_colors.pyget_channel_colors() plus the fluorophore/brightfield/palette helpers. Exported from the package __init__.
  • Modified OmeZarrConverter._resolve_channels — derives per-channel colors via get_channel_colors instead of hardcoding white. Explicit user-supplied channels= still take precedence; no-channel-axis behavior unchanged.
  • New bioio_conversion/tests/test_channel_colors.py — 24 tests.

Verification

  • End-to-end on s_3_t_1_c_3_z_5.czi: EGFP→green, TaRFP→orange (FFA500), Bright→white — confirmed in the written OMERO metadata.

🤖 Generated with Claude Code

Add bioio_conversion.channel_colors with get_channel_colors(), which
derives an OME-Zarr display color per channel, and wire it into
OmeZarrConverter so channels are colored automatically instead of all
defaulting to white.

Color policy (per channel):
- Brightfield / transmitted-light channels -> white, and do not consume
  a fluorescent palette slot. Detected via OME contrast_method /
  illumination_type with a channel-name fallback.
- Recognized fluorophores -> their true emission color via the
  FLUOROPHORE_COLORS table (e.g. GFP -> green, AF647 -> red).
- Remaining channels -> a count-based, perceptually-distinct palette
  (green / green+magenta / cyan-yellow-magenta / +Okabe-Ito), ordered by
  emission wavelength when available. Black is never assigned.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BrianWhitneyAI BrianWhitneyAI self-assigned this Jun 15, 2026
@BrianWhitneyAI BrianWhitneyAI force-pushed the feature/auto-channel-colors branch from 59b4fd6 to 3ac9b69 Compare June 17, 2026 16:46
Base automatically changed from feature/v3-direct-czi-read to feature/v3-sharding-policy June 17, 2026 19:54
Base automatically changed from feature/v3-sharding-policy to main June 24, 2026 18:35
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.

Feature Request: channel color discovery and default colors

1 participant