Skip to content

Clipping warning when plotting images #416

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

Open
LucaMarconato opened this issue Jan 30, 2025 · 2 comments
Open

Clipping warning when plotting images #416

LucaMarconato opened this issue Jan 30, 2025 · 2 comments

Comments

@LucaMarconato
Copy link
Member

To reproduce, please run the notebook from this PR, which doesn't require any data (it uses the one from squidpy).

The code cell

fig, axs = plt.subplots(1, 3, figsize=(18, 5))

sdata.pl.render_images().pl.render_shapes(color="array_row").pl.show(ax=axs[0], title="Row")

sdata.pl.render_images().pl.render_shapes(color="array_col").pl.show(ax=axs[1], title="Col")

sdata.pl.render_images().pl.render_shapes(color="mt-Cytb").pl.show(ax=axs[2], title="mt-Cytb")

leads to me to these warnings. Here I would like to report the one on the clipped data range.

Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [-0.04347826..1.0].
[/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py:105](http://localhost:8888/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py#line=104): UserWarning: Key `spots` already exists. Overwriting it in-memory.
  self._check_key(key, self.keys(), self._shared_keys)
[/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py:125](http://localhost:8888/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py#line=124): UserWarning: Key `adata` already exists. Overwriting it in-memory.
  self._check_key(key, self.keys(), self._shared_keys)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [-0.04347826..1.0].
[/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py:105](http://localhost:8888/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py#line=104): UserWarning: Key `spots` already exists. Overwriting it in-memory.
  self._check_key(key, self.keys(), self._shared_keys)
[/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py:125](http://localhost:8888/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py#line=124): UserWarning: Key `adata` already exists. Overwriting it in-memory.
  self._check_key(key, self.keys(), self._shared_keys)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [-0.04347826..1.0].
[/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py:105](http://localhost:8888/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py#line=104): UserWarning: Key `spots` already exists. Overwriting it in-memory.
  self._check_key(key, self.keys(), self._shared_keys)
[/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py:125](http://localhost:8888/Users/macbook/embl/projects/basel/spatialdata/src/spatialdata/_core/_elements.py#line=124): UserWarning: Key `adata` already exists. Overwriting it in-memory.
  self._check_key(key, self.keys(), self._shared_keys)

@timtreis reported that he cannot reproduce.

@LucaMarconato
Copy link
Member Author

LucaMarconato commented May 13, 2025

@MeyerBender could reproduce this in spatialproteomics.

This occurs in the first plot here. It should look like the first plot here.

Original comment from Meyer:

  • right at the start, when rendering the image, spatialdata-plot throws this warning: Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [0.0..1.4367858515955403]. The images are originally 16-bit integers. I have checked the maximum value of the image, and it is certainly not 1.43… I am not sure if this is an issue with 16-bit support, but in any case the warning seems misleading.

@timtreis
Copy link
Member

related: #451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants