spatialdata-plot
spatialdata-plot copied to clipboard
Reproduce Napari visualizations
I would like to generate static images files from NGFF/SpatialData datasets and presets stored in their NGFF Omero metadata, so that one can preview datasets without opening them interactively in Napari.
This combines the idea that SpatialData's data model resembles Napari's, and that datasets can store visualization presets for a reasonable default visualization.
For this, we still need some basic rendering properties:
blending:additive|opaque… Typically, images contain multiple channel, and their visualization is different depending on the microscopy illumination type. Several fluorescence channels can be visualized in a single image by additive blending. However, currently spatialdata-plot "overwrites" pixels of channels underneath.color: Napari allows to provide a color name for maximum intensity values and generates a corresponding color map.contrast_limits(Napari) orwindow(Omero): Typically, the value range of images can differ greatly, and in order to avoid reading all pixels to compute limits, Omero stores absolute limits in the metadata. However, spatialdata-plot currently supports only Matplotlib's relative limitspmin/pmax(asquantiles_for_norm).
Hey @aeisenbarth, I'm definitely in favor of aligning the different visualization backends across static/dynamic plotting. I had a similar discussion with the Gehlenborg lab. I'd be very happy to follow up on this maybe through a short call to understand your concrete needs and then see how we can best put them into code.
Thanks for the discussion!
I thoroughly tested again the different options and figured out how to achieve what I need (and drop lots of custom rendering code).
- blending: If fluorescence channels are part of the same SpatialData element, passing selected channel names as
channels=[…](besides #203) and channel colors aspalette=[…]does what I need. From what I understood from that part of the code, it implements additive blending for all channels within the same image. It mostly achieves the same result as if the bottom channel was opaque. - color: The channel color is here
palette, although images have continuous, not categorical values. - contrast_limits: We agreed that
quantiles_for_normachieves this better and is more practical because absolute limits would need to be set per channel.-
Tutorials should have a highlighted note like:
"If your plot looks very wrong or spatialdata-plot seems not to work for you, you should make sure you set
quantiles_for_norm."Maybe even it should have as default something like
(1, 99), requiring to opt-out with(None, None)if someone wants the full range rendered. -
The naming should be changed to
percentiles_for_norm(or the values to actual quantiles in the range 0.0–1.0). I first passed quantiles(0.01, 0.99), but it actually should be percentiles.
-
Nevertheless we can further discuss aligning names of common rendering parameters in Napari/NGFF/SpatialData.
Hi @aeisenbarth, that's a great idea, thanks for the discussion. I also agree that the best would be to have a call with other developers of visualization tools like Vitessce, napari, bento-tools and OMERO, to identify common settings for visualization and coordinate on naming. Also these settings could be considered for serialization in NGFF.