Fix multi-channel handling
I think the current implementation doesn't correctly handle images with 3+ channels, for example resulting in the following warning when rendering a 5 channel image:
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [0.01870049980776624..2.4537485582468284].
This PR proposes an alternative in which PCA is used to reduce an arbitrary amount of channels to 3 so that we can treat them as RGB:
@Sonja-Stockhaus did we discuss this at one point? I've been ignoring that warning for a long time because it's thrown my matplotlib and doesn't fail
This PR also introduces a bg_threshold parameter based on which we can exclude pixels for the PCA normalisation, f.e. in this composite
@Sonja-Stockhaus did we discuss this at one point? I've been ignoring that warning for a long time because it's thrown my matplotlib and doesn't fail
Nope. I also don't remember ever trying to render sth with 3+ channels
Codecov Report
:x: Patch coverage is 86.59794% with 13 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 85.71%. Comparing base (7716d43) to head (2e991c5).
:warning: Report is 68 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/spatialdata_plot/pl/render.py | 88.05% | 8 Missing :warning: |
| src/spatialdata_plot/pl/utils.py | 81.48% | 5 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #451 +/- ##
==========================================
+ Coverage 84.92% 85.71% +0.79%
==========================================
Files 8 8
Lines 1784 1869 +85
==========================================
+ Hits 1515 1602 +87
+ Misses 269 267 -2
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/spatialdata_plot/pl/basic.py | 89.26% <100.00%> (ø) |
|
| src/spatialdata_plot/pl/render_params.py | 100.00% <100.00%> (ø) |
|
| src/spatialdata_plot/pl/utils.py | 79.39% <81.48%> (+1.19%) |
:arrow_up: |
| src/spatialdata_plot/pl/render.py | 95.52% <88.05%> (-0.86%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.