Skip to content

Is "polygon_query" function working properly? #327

Open

Description

@yt723

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

Activity

  1. LucaMarconato commented on Jan 5, 2025

    @LucaMarconato
    Member

    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!

  2. sanderson6445 commented on Feb 23, 2025

    @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
  3. Pancreas-Pratik commented on Jul 16, 2025

    @Pancreas-Pratik

    @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?

  4. melonora commented on Jul 17, 2025

    @melonora
    Collaborator

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions