comparison qupath_roi_splitter.py @ 1:064b53fd3131 draft

planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit e08a178a7c35c0673f6bfc163614a8fc730ffc6c
author galaxyp
date Wed, 14 Jun 2023 16:37:01 +0000
parents b5e9cebb27e3
children 7bee859bbd11
comparison
equal deleted inserted replaced
0:b5e9cebb27e3 1:064b53fd3131
20 dim_plt = [qupath_roi["dim"]["width"], qupath_roi["dim"]["height"]] 20 dim_plt = [qupath_roi["dim"]["width"], qupath_roi["dim"]["height"]]
21 21
22 tma_name = qupath_roi["name"] 22 tma_name = qupath_roi["name"]
23 cell_types = [ct.rsplit(" - ", 1)[-1] for ct in qupath_roi["featureNames"]] 23 cell_types = [ct.rsplit(" - ", 1)[-1] for ct in qupath_roi["featureNames"]]
24 24
25 # create numpy array with white background 25 for cell_type in cell_types:
26 img = np.zeros((dim_plt[1], dim_plt[0], 3), dtype="uint8") 26 # create numpy array with white background
27 img.fill(255) 27 img = np.zeros((dim_plt[1], dim_plt[0], 3), dtype="uint8")
28 img.fill(255)
28 29
29 for cell_type in cell_types:
30 for i, roi in enumerate(qupath_roi["features"]): 30 for i, roi in enumerate(qupath_roi["features"]):
31 if roi["properties"]["classification"]["name"] == cell_type: 31 if roi["properties"]["classification"]["name"] == cell_type:
32 if len(roi["geometry"]["coordinates"]) == 1: 32 if len(roi["geometry"]["coordinates"]) == 1:
33 # Polygon w/o holes 33 # Polygon w/o holes
34 img = draw_poly(roi["geometry"]["coordinates"][0], img) 34 img = draw_poly(roi["geometry"]["coordinates"][0], img)