saeyslab / napari-sparrow

Other
17 stars 0 forks source link

create_voronoi_boundaries() throws TopologyException #114

Closed SilverViking closed 2 months ago

SilverViking commented 1 year ago

The function sdata=fc.create_voronoi_boundaries( sdata,radius=20, shapes_layer='segmentation_mask_boundaries' ) sometimes throws this exception: GEOSException: TopologyException: unable to assign free hole to a shell at 7562.2586206896549 5066.9482758620688

This happens in script_liver_sparrow_generalized_update.ipynb, when crop_segment=True and crop_param=[ 5000, 3000, 4000 ] on the Resolve liver dataset.

It seems that the segmentation polygons are valid (sdata['segmentation_mask_boundaries'].is_valid is True for all rows in the GeoDataFrame).

What causes the exception and what can be done about it?

SilverViking commented 1 year ago

Most likely an issue in the voronoi library, and not easy to get a fix for. Does the exception disappear when no cropping is done? Does it disappear for other crop locations/sizes?

SilverViking commented 1 year ago

Does the exception disappear when no cropping is done? Still needs to be tested.

Does it disappear for other crop locations/sizes? The exception indeed disappears when a different crop region is selected.