Skip to content

Conversation

@HelenaLC
Copy link
Owner

No description provided.

@HelenaLC HelenaLC requested a review from Artur-man November 25, 2024 21:21
@HelenaLC
Copy link
Owner Author

@Artur-man general Q: .manage_channels is currently only entered when the image isn't an RGB. But with contrast limits in place, don't we also wanna go there? E.g., for the blobs, I currently can't alter how the image is rendered at all.

@Artur-man
Copy link
Collaborator

Hmmmm, I have never thought about this. I used to only change the saturation and brightness of IF channels before. Perhaps we can deal with this when channels are passed to .ch2rgb, hence pass rgb images there too ? then use .is_rgb function only in .ch2rgb ? I dont know

@HelenaLC
Copy link
Owner Author

changing this line in .df_i() seems to do the trick:

#if (!.is_rgb(x))
if (!is.null(c) || !is.null(cl))
    a <- .chs2rgb(a, ch_i, c, cl)
    
x <- file.path("extdata", "blobs.zarr")
x <- system.file(x, package="SpatialData")
x <- readSpatialData(x, tables=FALSE)
plotSpatialData() + plotImage(x, c=c("cyan", "magenta", "yellow"))

image

@Artur-man
Copy link
Collaborator

Artur-man commented Nov 26, 2024

if (!is.null(c) || !is.null(cl))
    a <- .chs2rgb(a, ch_i, c, cl)

Hmm ... so lets say that colors are null but contrast limits are not, then we go to chsrgb .... if there are colors and contrast limits are null, then we go to chsrgb again, if both are null we go chrsrgb ...

so the only case we dont go to chs2rgb is when both colors and cl are null .... but then the statement before we already pick the first channel when everything is null

if (!.is_rgb(x))
        a <- a[ch_i, , , drop=FALSE]

ok you are right this is ok!

@HelenaLC
Copy link
Owner Author

I realize we need both - !.is_rgb(x) || !is.null(c) || !is.null(cl) - else one-channel (e.g., MERFISH) fails. I also included unit tests now. Updating soon.

@HelenaLC
Copy link
Owner Author

Alright, so actually still need the !.is_rgb, else single-channel images will fail. I also included unit tests now. Let me know if we're happy with this (for now) & I'll merge.

@HelenaLC HelenaLC merged commit c9607a2 into main Nov 27, 2024
2 checks passed
@HelenaLC HelenaLC changed the title in plotImage, add arguments to control contrast limits and saturation in plotImage, add argument to control contrast (cl), unit tests etc. Nov 27, 2024
@HelenaLC HelenaLC changed the title in plotImage, add argument to control contrast (cl), unit tests etc. in plotImage, add argument to control contrast (cl), doc examples, unit tests etc. Nov 27, 2024
@HelenaLC HelenaLC changed the title in plotImage, add argument to control contrast (cl), doc examples, unit tests etc. for plotImage, add argument to control contrast (cl), including doc examples, unit tests etc. Nov 27, 2024
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