okunator / cellseg_gsontools

Feature extraction from GEOJson nuclei and tissue segmentation maps
https://okunator.github.io/cellseg_gsontools/
MIT License
12 stars 0 forks source link

weights2gdf not working #25

Closed fxpopp closed 1 month ago

fxpopp commented 5 months ago

I have segmented a WSI and extracted a 512x512 patch from it by hap_cells = cells.cx[x:x+512, y:y+512].

image

image

Following the user guide "Cell/Nuclei Neighborhood Distances and Characteristics", I would like to fit a connectivity graph to the resulting 157 cells. When executing w = fit_graph(hap_cells, type="delaunay", thresh=200, id_col="uid") I get many warnings like this:

  1. passing a BlockManager to GeoDataFrame is deprecated and will be removed in a future version. Use public APIs instead.
  2. the geometry is in a geographic CRS. The results of 'centroid' are probably wrong. Use 'GeoSeries.to_crs()' to reproject geometries to a projected CRS before this operation. image

When running wdf = weights2gdf(hap_cells, w) I get an error:

TypeError: sequence item 0: expected str instance, NoneType found

image

What could be the reason for this and what have I done wrong? Can you help me?

okunator commented 4 months ago

Hi, seems like your cell type column is called 'classification'. If you rename that column to 'class_name', then I believe your code would start working. All the methods in this library expect that the cell type class info is under the 'class_name' column.

okunator commented 4 months ago

Also, the warnings you get are nothing major. The second warning especially can be avoided by setting the crs of the gdf for example hap_cells.set_crs(4328, inplace=True, allow_override=True)