Working with tiles and merging polygons

Created on Wed Aug 21 16:25:06 2019.

@author: tageldim

class histomicstk.annotations_and_masks.polygon_merger.Polygon_merger(maskpaths, GTCodes_df, **kwargs)[source]

Bases: Base_HTK_Class

Methods to merge polygons in tiled masks.

get_concatenated_contours()[source]

Get concatenated contours and overall bounding box.

Returns:

  • - pandas DataFrame (has the same structure as output from)

  • get_contours_from_mask().

run()[source]

Run full pipeline to get merged contours.

Returns:

  • - pandas DataFrame (has the same structure as output from)

  • get_contours_from_mask().

set_contours_from_all_masks(monitorPrefix='')[source]

Get contours_df from all masks.

This is a wrapper around get_contours_from_mask(), with the added functionality of separating out contorus at roi edge from those that are not.

Sets: - self.ordinary_contours: dict: indexed by maskname, each entry is a contours dataframe - self.edge_contours: dict: indexed by maskname, each entry is a contours dataframe - self.merged_contours: pandas DataFrame: single dataframe to save all merged contours

set_merged_contours(monitorPrefix='')[source]

Go through each group and merge contours.

Sets: - self.merged_contours: pandas DataFrame: has the same structure as output from get_contours_from_mask().

set_roi_bboxes(roi_offsets=None)[source]

Get dictionary of roi bounding boxes.

Arguments:

  • roi_offsets: dict (default, None): dict indexed by maskname,

each entry is a dict with keys top and left each is an integer. If None, then the x and y offset is inferred from mask name.

Sets: - self.roiinfos: dict: dict indexed by maskname, each entry is a dict with keys top, left, bottom, right, all of which are integers.

set_shared_roi_edges()[source]

Get shared edges between rois in same slide (Internal).

Created on Sat Aug 24 16:01:26 2019.

@author: tageldim

class histomicstk.annotations_and_masks.polygon_merger_v2.Polygon_merger_v2(contours_df, **kwargs)[source]

Bases: Base_HTK_Class

Methods to merge contiguous polygons from whole-slide image.

create_rtree()[source]

Add contour bounding boxes to R-tree.

get_merged_multipolygon()[source]

Get final merged shapely multipolygon by hierarchical merger.

run()[source]

Run sequence for merging polygons & adding contours.

run_for_single_group(group, monitorPrefix='')[source]

Run sequence for merging polygons & adding contours (one group).

set_contours_slice(group)[source]

Slice a single group from self.contours_df.

set_hierarchy()[source]

Get hierarchy of node indices.

set_tree_dict()[source]

Get tree in convenience dict format (dicts inside dicts).