Skip to content

Commit

Permalink
Solved TypeError: 'Polygon' object is not iterable when trying to b…
Browse files Browse the repository at this point in the history
…uild a MultiPolygon from a list with only a single Polygon in it.
  • Loading branch information
jjhbw committed Apr 26, 2021
1 parent c0cfb16 commit 65963c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions infer_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ def construct_tissue_polygon(foreground_contours, hole_contours, min_area):

polys.append(poly)

# Combine all polygons into a MultiPolygon
return MultiPolygon(unary_union(polys))
if len(polys) == 0:
raise Exception("Raw tissue mask consists of 0 polygons")

# If we have multiple polygons, we merge any overlap between them using unary_union().
# This will result in a Polygon or MultiPolygon with most tissue masks.
return unary_union(polys)


def make_tile_QC_fig(tile_sets, slide, level, line_width_pix):
Expand Down

0 comments on commit 65963c1

Please sign in to comment.