napari-spatialdata icon indicating copy to clipboard operation
napari-spatialdata copied to clipboard

Is "polygon_query" function working properly?

Open yt723 opened this issue 1 year ago • 4 comments

Hi,

I'm using napari_spatialdata to segment regions of interest. It seems the filtered table doesn't include the correct cell IDs. I noticed all polygon shapes changed into rectangles. I attached an example below. The triangle is the ROI I placed and the blue rectangle area shows cells obtained by polygon_query. I'm using Seurat for clustering etc. So, I export the filtered table and add annotations as metadata. This happens no matter what shapes of polygon I create. However, "sdata.pl.render_images().pl.render_shapes(color='annotation').pl.show(coordinate_systems=["x"])" displays the actual polygon.

Why does this discrepancy happen (is this happening only to me?) and is there any way to solve this problem? Thank you so much for your help!

Image

yt723 avatar Oct 23 '24 18:10 yt723

Hi @yt723 thanks for reporting and happy to look into this but I will need some help in reproducing the bug please.

  1. Does the bug appear also with the latest main of spatialdata and napari-spatialdata?

  2. Could you please try reproducing the bug with the following dataset:

from spatialdata.datasets import blobs_annotating_element

sdata = blobs_annotating_element('blobs_polygons')
  1. If you can't reproduce with the dataset above, is there any change you could share the dataset you are using in your screenshot?

Thanks!

LucaMarconato avatar Jan 05 '25 20:01 LucaMarconato

@LucaMarconato I also have this problem. Any updates on how to resolve? I am using the Nanostring CosMx sample data available from their website (https://nanostring.com/products/cosmx-spatial-molecular-imager/ffpe-dataset/cosmx-smi-human-pancreas-ffpe-dataset/) and am following along with this tutorial to annotate ROIs: https://spatialdata.scverse.org/en/latest/tutorials/notebooks/notebooks/examples/napari_rois.html.

Everything works as expected, code wise, just the final annotation is... off by quite a margin. See attached image for the polygon I drew (white-transparent) and the subsequent polygon_querry annotations (green and red). Blue cells are not annotated by polygon_query. I have this problem regardless of what kind of shape I draw (triangle, lasso, etc).

Thanks!

Image

sanderson6445 avatar Feb 23 '25 19:02 sanderson6445

@LucaMarconato I also have this problem. Any updates on how to resolve? I am using the Nanostring CosMx sample data available from their website (https://nanostring.com/products/cosmx-spatial-molecular-imager/ffpe-dataset/cosmx-smi-human-pancreas-ffpe-dataset/) and am following along with this tutorial to annotate ROIs: https://spatialdata.scverse.org/en/latest/tutorials/notebooks/notebooks/examples/napari_rois.html.

Everything works as expected, code wise, just the final annotation is... off by quite a margin. See attached image for the polygon I drew (white-transparent) and the subsequent polygon_querry annotations (green and red). Blue cells are not annotated by polygon_query. I have this problem regardless of what kind of shape I draw (triangle, lasso, etc).

Thanks!

Image

@yt723 @sanderson6445 I may have to try what you are doing soon (labeling and subsampling ROIs). Have you had success with resolving your issues?

Pancreas-Pratik avatar Jul 16 '25 19:07 Pancreas-Pratik

@Pancreas-Pratik Sorry this issue skipped my attention. I will have a look and report back by the weekend.

melonora avatar Jul 17 '25 08:07 melonora