annotate qupath_roi_splitter.py @ 2:3282b4920a34 draft

planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
author galaxyp
date Fri, 19 Jul 2024 14:33:33 +0000
parents f955895aed01
children 180b6dc5735a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
1 import argparse
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
2
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
3 import cv2
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
4 import geojson
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
5 import numpy as np
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
6 import pandas as pd
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
7
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
8
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
9 def collect_coords(input_coords, feature_index, coord_index=0):
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
10 coords_with_index = []
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
11 for coord in input_coords:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
12 coords_with_index.append((coord[0], coord[1], feature_index, coord_index))
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
13 coord_index += 1
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
14 return coords_with_index
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
15
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
16
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
17 def collect_roi_coords(input_roi, feature_index):
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
18 all_coords = []
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
19 if len(input_roi["geometry"]["coordinates"]) == 1:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
20 # Polygon w/o holes
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
21 all_coords.extend(collect_coords(input_roi["geometry"]["coordinates"][0], feature_index))
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
22 else:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
23 coord_index = 0
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
24 for sub_roi in input_roi["geometry"]["coordinates"]:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
25 # Polygon with holes or MultiPolygon
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
26 if not isinstance(sub_roi[0][0], list):
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
27 all_coords.extend(collect_coords(sub_roi, feature_index, coord_index))
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
28 coord_index += len(sub_roi)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
29 else:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
30 # MultiPolygon with holes
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
31 for sub_coord in sub_roi:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
32 all_coords.extend(collect_coords(sub_coord, feature_index, coord_index))
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
33 coord_index += len(sub_coord)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
34 return all_coords
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
35
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
36
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
37 def split_qupath_roi(in_roi):
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
38 with open(in_roi) as file:
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
39 qupath_roi = geojson.load(file)
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
40
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
41 # HE dimensions
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
42 dim_plt = [int(qupath_roi["dim"]["width"]), int(qupath_roi["dim"]["height"])]
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
43
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
44 tma_name = qupath_roi["name"]
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
45 cell_types = [ct.rsplit(" - ", 1)[-1] for ct in qupath_roi["featureNames"]]
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
46
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
47 coords_by_cell_type = {ct: [] for ct in cell_types}
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
48 coords_by_cell_type['all'] = [] # For storing all coordinates if args.all is True
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
49
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
50 for feature_index, roi in enumerate(qupath_roi["features"]):
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
51 feature_coords = collect_roi_coords(roi, feature_index)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
52
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
53 if args.all:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
54 coords_by_cell_type['all'].extend(feature_coords)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
55 elif "classification" in roi["properties"]:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
56 cell_type = roi["properties"]["classification"]["name"]
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
57 if cell_type in cell_types:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
58 coords_by_cell_type[cell_type].extend(feature_coords)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
59
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
60 for cell_type, coords in coords_by_cell_type.items():
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
61 if coords:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
62 # Generate image (white background)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
63 img = np.ones((dim_plt[1], dim_plt[0]), dtype="uint8") * 255
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
64
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
65 # Convert to numpy array and ensure integer coordinates
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
66 coords_arr = np.array(coords).astype(int)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
67
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
68 # Sort by feature_index first, then by coord_index
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
69 coords_arr = coords_arr[np.lexsort((coords_arr[:, 3], coords_arr[:, 2]))]
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
70
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
71 # Get filled pixel coordinates
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
72 if args.fill:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
73 filled_coords = np.column_stack(np.where(img == 0))
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
74 all_coords = np.unique(np.vstack((coords_arr[:, :2], filled_coords[:, ::-1])), axis=0)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
75 else:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
76 all_coords = coords_arr[:, :2]
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
77
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
78 # Save all coordinates to CSV
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
79 coords_df = pd.DataFrame(all_coords, columns=['x', 'y'], dtype=int)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
80 coords_df.to_csv("{}_{}.txt".format(tma_name, cell_type), sep='\t', index=False)
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
81
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
82 # Generate image for visualization if --img is specified
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
83 if args.img:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
84 # Group coordinates by feature_index
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
85 features = {}
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
86 for x, y, feature_index, coord_index in coords_arr:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
87 if feature_index not in features:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
88 features[feature_index] = []
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
89 features[feature_index].append((x, y))
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
90
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
91 # Draw each feature separately
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
92 for feature_coords in features.values():
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
93 pts = np.array(feature_coords, dtype=np.int32)
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
94 if args.fill:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
95 cv2.fillPoly(img, [pts], color=0) # Black fill
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
96 else:
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
97 cv2.polylines(img, [pts], isClosed=True, color=0, thickness=1) # Black outline
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
98
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
99 cv2.imwrite("{}_{}.png".format(tma_name, cell_type), img)
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
100
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
101
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
102 if __name__ == "__main__":
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
103 parser = argparse.ArgumentParser(description="Split ROI coordinates of QuPath TMA annotation by cell type (classification)")
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
104 parser.add_argument("--qupath_roi", default=False, help="Input QuPath annotation (GeoJSON file)")
2
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
105 parser.add_argument("--fill", action="store_true", required=False, help="Fill pixels in ROIs (order of coordinates will be lost)")
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
106 parser.add_argument('--version', action='version', version='%(prog)s 0.3.0')
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
107 parser.add_argument("--all", action="store_true", required=False, help="Extracts all ROIs")
3282b4920a34 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit 918ae25f84e7042ed36461219ff068633c1c2427
galaxyp
parents: 1
diff changeset
108 parser.add_argument("--img", action="store_true", required=False, help="Generates image of ROIs")
0
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
109 args = parser.parse_args()
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
110
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
111 if args.qupath_roi:
bd60d4542fd4 planemo upload for repository hhttps://github.com/npinter/ROIsplitter commit cdf3e9652b10c7a0b179202129a797e32fd95909
galaxyp
parents:
diff changeset
112 split_qupath_roi(args.qupath_roi)