# HG changeset patch # User galaxyp # Date 1714058002 0 # Node ID 24ccdcfbabacaf8d6fb62978d1122c858566d80a # Parent 7bee859bbd11e49b89798122e9096181f1266b8e planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 00029e8a3ee400f69a6dbe9e556ec9c27c6979cb diff -r 7bee859bbd11 -r 24ccdcfbabac qupath_roi_splitter.py --- a/qupath_roi_splitter.py Thu Apr 11 07:52:58 2024 +0000 +++ b/qupath_roi_splitter.py Thu Apr 25 15:13:22 2024 +0000 @@ -25,20 +25,22 @@ # Polygon with holes if not isinstance(sub_roi[0][0], list): if first_roi: - input_img = draw_poly(sub_roi, input_img, fill=fill) first_roi = False + col = (0, 0, 0) else: # holes in ROI - input_img = draw_poly(sub_roi, input_img, col=(255, 255, 255), fill=fill) + col = (255, 255, 255) if not fill else (0, 0, 0) + input_img = draw_poly(sub_roi, input_img, col=col, fill=fill) else: # MultiPolygon with holes for sub_coord in sub_roi: if first_roi: - input_img = draw_poly(sub_coord, input_img, fill=fill) first_roi = False + col = (0, 0, 0) else: # holes in ROI - input_img = draw_poly(sub_coord, input_img, col=(255, 255, 255), fill=fill) + col = (255, 255, 255) if not fill else (0, 0, 0) + input_img = draw_poly(sub_coord, input_img, col=col, fill=fill) return input_img @@ -89,6 +91,10 @@ coords_df.to_csv("{}_{}.txt".format(tma_name, cell_type), sep='\t', index=False) + # img save + if args.img: + cv2.imwrite("{}_{}.png".format(tma_name, cell_type), img) + if __name__ == "__main__": parser = argparse.ArgumentParser(description="Split ROI coordinates of QuPath TMA annotation by cell type (classfication)") @@ -96,6 +102,7 @@ parser.add_argument("--fill", action="store_true", required=False, help="Fill pixels in ROIs") parser.add_argument('--version', action='version', version='%(prog)s 0.1.0') parser.add_argument("--all", action="store_true", required=False, help="Extracts all ROIs") + parser.add_argument("--img", action="store_true", required=False, help="Generates image of ROIs") args = parser.parse_args() if args.qupath_roi: diff -r 7bee859bbd11 -r 24ccdcfbabac qupath_roi_splitter.xml --- a/qupath_roi_splitter.xml Thu Apr 11 07:52:58 2024 +0000 +++ b/qupath_roi_splitter.xml Thu Apr 25 15:13:22 2024 +0000 @@ -1,14 +1,14 @@ Split ROI coordinates of QuPath TMA annotation by cell type (classification) - 0.2.0 + 0.2.1 0 geojson numpy opencv - pandas + pandas
+
- + + + + @@ -43,9 +49,10 @@
+
- + @@ -54,6 +61,13 @@ + + + + + + +