Skip to content
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

Set rgb argument to auto-detect whether image channels are RGB #78

Merged
merged 5 commits into from
Sep 8, 2024

Conversation

aeisenbarth
Copy link
Contributor

Following issue scverse/napari-spatialdata#150, the logic to decide whether channels should be visualized as RGB has been moved from the viewer napari-spatialdata to the parser in spatial-image, which in the case of RGB sets channel names to ["r", "g", "b"]. The default behavior of to_spatial_image is rgb=False (no change of channel names). That means in order to have the auto-detection as it was in the viewer, we now need to opt-in in the readers, either to auto-detect RGB (rgb=None) or explicitly enforce RGB (rgb=True).

This PR modifies readers to opt in for RGB detection, or explicitly set RGB (where the original data-format is known to always be RGB(A) with 3 or 4 channels).

@aeisenbarth
Copy link
Contributor Author

Update:
Now spatialdata==0.2.2 (with scverse/spatialdata#587) includes spatialimage>=1.1.0, (with spatial-image/spatial-image#21).
I believe as soon as spatialdata-io is upgraded to spatialdata>=0.2.2, this PR will be ready to merge.

@LucaMarconato
Copy link
Member

LucaMarconato commented Sep 8, 2024

Thanks for the PR, merging soon!

Btw, I have implemented a more general approach so that users don't have to pass rgb=None: scverse/spatialdata#702, what do you think? Anyway, I'd merge this PR now so that users that install spatialdata-io from GitHub without updating spatialdata would still have the fix.

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 45.82%. Comparing base (54da345) to head (a76de1d).
Report is 175 commits behind head on main.

Files with missing lines Patch % Lines
src/spatialdata_io/readers/mcmicro.py 0.00% 3 Missing ⚠️
src/spatialdata_io/readers/_utils/_utils.py 0.00% 2 Missing ⚠️
src/spatialdata_io/readers/merscope.py 0.00% 1 Missing ⚠️
src/spatialdata_io/readers/steinbock.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
+ Coverage   35.91%   45.82%   +9.90%     
==========================================
  Files          19       22       +3     
  Lines        1715     2132     +417     
==========================================
+ Hits          616      977     +361     
- Misses       1099     1155      +56     
Files with missing lines Coverage Δ
src/spatialdata_io/readers/codex.py 43.47% <ø> (ø)
src/spatialdata_io/readers/cosmx.py 18.93% <ø> (-0.15%) ⬇️
src/spatialdata_io/readers/visium.py 19.67% <ø> (-1.17%) ⬇️
src/spatialdata_io/readers/xenium.py 71.79% <ø> (+49.31%) ⬆️
src/spatialdata_io/readers/merscope.py 24.06% <0.00%> (-0.94%) ⬇️
src/spatialdata_io/readers/steinbock.py 42.22% <0.00%> (ø)
src/spatialdata_io/readers/_utils/_utils.py 42.62% <0.00%> (+15.53%) ⬆️
src/spatialdata_io/readers/mcmicro.py 15.92% <0.00%> (ø)

... and 3 files with indirect coverage changes

@LucaMarconato LucaMarconato changed the title [WIP] Set rgb argument to auto-detect whether image channels are RGB Set rgb argument to auto-detect whether image channels are RGB Sep 8, 2024
@LucaMarconato
Copy link
Member

In merfish I replaced rgb=True with rgb=None, I think it was a typo. Merging.

@LucaMarconato LucaMarconato merged commit 1d031c2 into scverse:main Sep 8, 2024
5 checks passed
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.

3 participants