-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-image overlay #25
Multi-image overlay #25
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
=======================================
Coverage 99.71% 99.72%
=======================================
Files 18 18
Lines 708 720 +12
=======================================
+ Hits 706 718 +12
Misses 2 2 ☔ View full report in Codecov by Sentry. |
2285283
to
5bc3771
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general comment on the approach in multi_view_frame
for multiple overlays, which probably also applies elsewhere. Continuing to extend this function to support richer composite images might be adding some debt in the longer term. For example, you can feel some complexity in the logic for associating overlays and overlay colormaps. We might consider moving toward some way to compose images of multiple "layers" using multiple calls, as in eg matplotlib where multiple calls to plt.imshow
stack on top of each other. (In fact, the function internally does some layer composition with noimg.overlay
. So implementing this might not be too hard.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree, though I don't anticipate overlays getting more complex than this. With the colormaps, I don't love handling it this way either. The idea of layering is sounds like a good approach to me. Would need to take a look into what this might look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked into this a little more - should be doable, though I might push this down the road and implement in a separate PR. Seems like that might be a bigger change and want to avoid this one getting too large + resolve multi-image overlays not working.
panel_height: int | None = 256, | ||
cmap: str = "gray", | ||
overlay_cmap: str = "brg", | ||
overlay_cmap: list[str] = ["brg"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the default overlay cmap change? I would guess it would be shared across functions, as in matplotlib with the default cmap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're providing multiple overlays, you may not want to have the same cmap for them (e.g. multiple binary overlays of different tissue types). I don't think there are a lot of situations where you would want a different cmap, but the option is there if it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just mean "brg" here vs "turbo" elsewhere. Very minor point though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I was actually going to ask you that 😅, those were the defaults from before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so I did this 😅 😅? Ya I can't remember any reason for doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to leave this as is for now unless you really feel strongly about it 😛
5bb9787
to
2ca8e39
Compare
A few changes here. The main ones since last review:
Also addressed a number of the previous comments, except for:
|
e495d43
to
4af812e
Compare
- Also update tests - For videos, kept using a single overlay cmap as the mapping is done in a separate function, where as static images are not.
Instead of setting a single cmap and cycling through (which only really works for binary images), the user is to pass a list of color maps to use, one for each overlay. If there are more overlays than color maps, warn the user and use the previously set default of 'turbo'. This cause an issue if there are 2+ overlays don't have corresponding images - this will also serve as an additional warning for the user when they check the images.
4af812e
to
80d691f
Compare
Merging this one with note (see below from offline discussion) to tackle some of challenges in a subsequent PR. From @clane9
|
* Add multi-overlay support in multi_view.py * Color maps need to be passed as a list matching the number of overlays provided, otherwise will be set to default. * Replace missed 'generators' variations * Simplify generation of output figure file path * Avoid having to set "extra_entities" key - b2t will automatically put these in there. Ensure staticmethods will accept additional kwargs. * Rather than manipulate entities before updating, create a new figure_entities that first updates the existing record entities with the figure entities of the generator. If "figure" is provided in the view_kwargs, update the figure entities with this.
* Add multi-overlay support in multi_view.py * Color maps need to be passed as a list matching the number of overlays provided, otherwise will be set to default. * Replace missed 'generators' variations
* Add multi-overlay support in multi_view.py * Color maps need to be passed as a list matching the number of overlays provided, otherwise will be set to default. * Replace missed 'generators' variations
Minor one here, following up on #21 - enables multi-image overlay capabilities.