Skip to content

Handling Annotations from QuPath #430

@rushin682

Description

@rushin682

Certain issues noticed:

  • Geometry type not validated from QuPath (i.e Polygons are sometimes just multi polygons. So analysis only considered first array of coords)
  • MultiPolygons are not being plotted (Possibly intersecting points issue.)

Attached test geojson file : test_geojson.txt

Fix possibilities:

  • Coordinate based Validator for geometry type
  • Recompute polygons in Multipolygon setting

All Polygons plot:

Image

Single Multipolygon plot error:

ValueError                                Traceback (most recent call last)
Cell In[116], [line 1](vscode-notebook-cell:?execution_count=116&line=1)
----> [1](vscode-notebook-cell:?execution_count=116&line=1) sdata.pl.render_images("he_image").pl.render_shapes(f"multipolygon_single", fill_alpha=0, outline_alpha=1.0, outlide_width=0.5).pl.show()

File ~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:918, in PlotAccessor.show(self, coordinate_systems, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, na_in_legend, colorbar, wspace, hspace, ncols, frameon, figsize, dpi, fig, title, share_extent, pad_extent, ax, return_ax, save)
    [913](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:913)     wanted_elements, wanted_shapes_on_this_cs, wants_shapes = _get_wanted_render_elements(
    [914](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:914)         sdata, wanted_elements, params_copy, cs, "shapes"
    [915](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:915)     )
    [917](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:917)     if wanted_shapes_on_this_cs:
--> [918](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:918)         _render_shapes(
    [919](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:919)             sdata=sdata,
    [920](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:920)             render_params=params_copy,
    [921](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:921)             coordinate_system=cs,
    [922](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:922)             ax=ax,
    [923](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:923)             fig_params=fig_params,
    [924](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:924)             scalebar_params=scalebar_params,
    [925](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:925)             legend_params=legend_params,
    [926](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:926)         )
    [928](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:928) elif cmd == "render_points" and has_points:
    [929](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:929)     wanted_elements, wanted_points_on_this_cs, wants_points = _get_wanted_render_elements(
    [930](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:930)         sdata, wanted_elements, params_copy, cs, "points"
    [931](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/basic.py:931)     )

File ~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/spatialdata_plot/pl/render.py:312, in _render_shapes(sdata, render_params, coordinate_system, ax, fig_params, scalebar_params, legend_params)
...
    [140](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/matplotlib/path.py:140)     raise ValueError("The first element of 'code' must be equal "
    [141](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/matplotlib/path.py:141)                      f"to 'MOVETO' ({self.MOVETO}).  "
    [142](https://file+.vscode-resource.vscode-cdn.net/Users/rushin.gindra/Documents/scverse_x_owkin/notebooks/~/miniforge3/envs/spatialdata/lib/python3.10/site-packages/matplotlib/path.py:142)                      f"Your first code is {codes[0]}")

ValueError: 'codes' must be a 1D list or array with the same length of 'vertices'. Your vertices have shape (168, 2) but your codes have shape (44,)

@LucaMarconato @timtreis

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