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

make multicolor images #326

Open
mezwick opened this issue Oct 23, 2024 · 3 comments
Open

make multicolor images #326

mezwick opened this issue Oct 23, 2024 · 3 comments

Comments

@mezwick
Copy link

mezwick commented Oct 23, 2024

Thanks for all your work on spatialdata and napari viewer.

Unless i have missed it, one missing aspect i would like is the ability to make multicolor images of image elemtns in spatialdata objects, within the spatial-data napari viewer plugin. So far as i can tell, this is not possible.

Expected behaviour

  1. Load spatial data in napari with spatialdata plugin
  2. Select coordinate system, load image element
  3. Select a channel, adjust colormap and contrast limits
  4. Select another channel, repeat step 3 until showing all channels as one would like
  5. Have multichannel view of image, on which can overlay mask elements

Issue
Selecting a second channel, resets the whole image. Can only view one image at a time

Potential solutions
Option to load channels as individual image layers?

@LucaMarconato
Copy link
Member

LucaMarconato commented Jan 5, 2025

Thanks @mezwick for reporting this. @melonora @kevinyamauchi @Czaki does napari support this or is this in the roadmap? What do you think about the workaround? Thanks!

@mezwick
Copy link
Author

mezwick commented Jan 13, 2025

Just to add in case useful for others. My current workaround is to load channels into sdata objects as individual images. Though this gets cumbersome for 40 channel high-plex images

@LucaMarconato
Copy link
Member

Thanks for sharing your workaround. Maybe you'll find the code below useful. It can be used to programmatically set a colormap, and it could be extended for other settings, like contrast limits.

# the 'rasterize_002um' image, and the `new_cmap` variable have been created ealier in the notebook
# below we open napari in headless-mode and preload a layer, then we programmatically set a custom colormap

from napari.utils.colormaps import Colormap
from napari_spatialdata import Interactive

napari_cmap = Colormap(new_cmap.colors, "viridis_zero_transparent")

interactive = Interactive(sdata, headless=True)
interactive.add_element(f"rasterized_002um", "global", view_element_system=True)
interactive.get_layer(f"rasterized_002um").colormap = napari_cmap
interactive.run()

The code is from the Visium HD notebook (at the end).

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

No branches or pull requests

2 participants