Extract channel→colormap mapping to _colormaps.py (PR1 of #7)#11
Merged
Conversation
The same channel-name → display-color rule was duplicated in _widget.py (used by the napari widget) and _reader.py (used by the drag-and-drop napari reader). The two copies had drifted: the reader mapped DAPI→blue and mCherry→red and was missing Brightfield, EGFP, mStrawberry, Cy3, and Alexa 568 entirely. Both call sites now use the new pyphenix._colormaps.channel_color() helper. The unified mapping follows the widget's (more complete) set, per the wishlist's requirement that the upcoming plate overview match "the colormaps suggested per-channel by the napari widget" (#7, #8). User-visible effect: drag-and-drop reader colors shift for DAPI (blue → cyan) and mCherry (red → magenta), matching what the widget already shows. Widget behavior is unchanged. Also lands the shared design docs the rest of #7 references: - CONTEXT.md (ubiquitous language for plate / well / field / channel combo / plate-wide contrast limits) - docs/adr/0001-plate-wide-contrast-on-downsampled-pixels.md Closes #8. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
src/pyphenix/_colormaps.pyexposeschannel_color(name, idx), the single source of truth for channel→display-color used by the napari widget, the drag-and-drop reader, and the upcoming plate overview (Plate overview images (parent tracking issue) #7)._widget.pyand_reader.pyboth delete their inline dicts and call the helper.User-visible change
The two old dicts had drifted. The reader used to map DAPI → blue and mCherry → red and was missing Brightfield, EGFP, mStrawberry, Cy3, and Alexa 568. After this PR the reader matches the widget: DAPI → cyan, mCherry → magenta, etc. This is the explicit point of the refactor — the wishlist for #7 requires the plate overview to use "the colormaps suggested per-channel by the napari widget" — but it does mean anyone relying on the old drag-and-drop colors will see them shift.
Widget behavior is unchanged.
Also in this PR
The shared design docs the rest of #7 references:
CONTEXT.md— ubiquitous language (plate, well, field, channel combo, plate-wide contrast limits, field choice)docs/adr/0001-plate-wide-contrast-on-downsampled-pixels.md— the single non-obvious overview trade-off worth recordingTest plan
pytest tests/test_colormaps.py— 19/19 passCloses #8. Part of #7.
🤖 Generated with Claude Code