Skip to content

Shapes with string indices cannot be displayed #404

Open

Description

@pakiessling

In a lot of my datasets the segmentation polygons have the barcode of the cell they describe.

This leads to an error here:

is there a reason this needs to be converted? Seems to display fine without this step.

I think there is also a pull request about this #397

Name: napari-spatialdata
Version: 0.7.2

Error message:
ValueError Traceback (most recent call last) File ~/mambaforge/envs/napari/lib/python3.12/site-packages/napari_spatialdata/_sdata_widgets.py:162, in DataLoadThread.run(self) 158 layer = self.sdata_widget.viewer_model.get_sdata_points( 159 self._sdata, self._text, self._selected_cs, self._multi 160 ) 161 elif self._data_type == "shapes": --> 162 layer = self.sdata_widget._get_shapes( 163 self._sdata, 164 self._text, 165 self._selected_cs, 166 self._multi, 167 ) File ~/mambaforge/envs/napari/lib/python3.12/site-packages/napari_spatialdata/_sdata_widgets.py:322, in SdataWidget._get_shapes(self, sdata, key, selected_cs, multi) 318 return self.viewer_model.get_sdata_circles( 319 sdata, key, selected_cs, multi 320 ) 321 if isinstance( 322 sdata.shapes[original_name].iloc[0].geometry, 323 (shapely.geometry.Polygon, shapely.geometry.MultiPolygon), 324 ): --> 325 return self.viewer_model.get_sdata_shapes( 326 sdata, key, selected_cs, multi 327 ) File ~/mambaforge/envs/napari/lib/python3.12/site-packages/napari_spatialdata/_viewer.py:621, in SpatialDataViewer.get_sdata_shapes(self, sdata, key, selected_cs, multi) 618 df = df.sort_index() 620 simplify = len(df) > config.POLYGON_THRESHOLD --> 621 polygons, indices = _get_polygons_properties( 622 df, simplify, include_z=include_z 623 ) File ~/mambaforge/envs/napari/lib/python3.12/site-packages/napari_spatialdata/utils/_viewer_utils.py:21, in _get_polygons_properties(df, simplify, include_z) 18 add_z = include_z and "z" in axes 20 for i in range(len(df)): ---> 21 indices.append(int(df.index[i])) ValueError: invalid literal for int() with base 10: 'aaaaaaaa-1'

Activity

  1. changed the title [-]Conversion of shape indices to int makes shape dsiplay impossilble when they are strings[/-] [+]Shapes with string indices cannot be displayed[/+] on Sep 23, 2026
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