Mercurial > repos > bgruening > cp_display_data_on_image
comparison display_data_on_image.xml @ 0:c49a557b4e3e draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author | bgruening |
---|---|
date | Thu, 26 Mar 2020 17:45:44 -0400 |
parents | |
children | 7c70e5268acd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c49a557b4e3e |
---|---|
1 <tool id="cp_display_data_on_image" name="DisplayDataOnImage" version="@CP_VERSION@"> | |
2 <description>produces an image with measured data on top of identified objects</description> | |
3 <macros> | |
4 <import>macros.xml</import> | |
5 <xml name="display_object"> | |
6 <param name="select_input_obj" label="Select the input objects" type="text" /> | |
7 <conditional name="con_obj_measurement_category"> | |
8 <param name="measurement_category" label="Measurement category" type="select"> | |
9 <option value="Location">Location</option> | |
10 <option value="Number">Number</option> | |
11 </param> | |
12 <when value="Number"> | |
13 <param name="measurement" label="Measurement" type="select"> | |
14 <option value="Object_Number">Object_Number</option> | |
15 </param> | |
16 </when> | |
17 <when value="Location"> | |
18 <param name="obj_measurement" label="Measurement" type="select"> | |
19 <option value="Center_X">Center_X</option> | |
20 <option value="Center_Y">Center_Y</option> | |
21 <option value="Center_Z">Center_Z</option> | |
22 </param> | |
23 </when> | |
24 </conditional> | |
25 </xml> | |
26 <xml name="display_image"> | |
27 <conditional name="con_obj_measurement_category"> | |
28 <param name="measurement_category" label="Measurement category" type="select"> | |
29 <option value="Count">Count</option> | |
30 <option value="FileName">FileName</option> | |
31 <option value="Frame">Frame</option> | |
32 <option value="Height">Height</option> | |
33 <option value="MD5Digest">MD5Digest</option> | |
34 <option value="Metadata">Metadata</option> | |
35 <option value="PathName">PathName</option> | |
36 <option value="Scaling">Scaling</option> | |
37 <option value="Series">Series</option> | |
38 <option value="PathName">PathName</option> | |
39 <option value="Threshold">Threshold</option> | |
40 <option value="URL">URL</option> | |
41 <option value="Width">Width</option> | |
42 </param> | |
43 <when value="Count"> | |
44 <param name="measurement" label="Measurement" type="text" /> | |
45 </when> | |
46 <when value="FileName"> | |
47 <param name="measurement" label="Measurement" type="text" /> | |
48 </when> | |
49 <when value="Frame"> | |
50 <param name="measurement" label="Measurement" type="text" /> | |
51 </when> | |
52 <when value="Height"> | |
53 <param name="measurement" label="Measurement" type="text" /> | |
54 </when> | |
55 <when value="MD5Digest"> | |
56 <param name="measurement" label="Measurement" type="text" /> | |
57 </when> | |
58 <when value="Metadata"> | |
59 <param name="measurement" label="Measurement" type="select"> | |
60 <option value="FileLocation">FileLocation</option> | |
61 <option value="Frame">Frame</option> | |
62 <option value="ImageId">ImageId</option> | |
63 <option value="Screen">Screen</option> | |
64 <option value="Series">Series</option> | |
65 </param> | |
66 </when> | |
67 <when value="PathName"> | |
68 <param name="measurement" label="Measurement" type="text" /> | |
69 </when> | |
70 <when value="Scaling"> | |
71 <param name="measurement" label="Measurement" type="text" /> | |
72 </when> | |
73 <when value="Series"> | |
74 <param name="measurement" label="Measurement" type="text" /> | |
75 </when> | |
76 <when value="PathName"> | |
77 <param name="measurement" label="Measurement" type="text" /> | |
78 </when> | |
79 <when value="Threshold"> | |
80 <param name="measurement" label="Measurement" type="text" /> | |
81 <param name="image_thresh_objects" label="Objects" type="text"/> | |
82 </when> | |
83 <when value="URL"> | |
84 <param name="measurement" label="Measurement" type="text" /> | |
85 </when> | |
86 <when value="Width"> | |
87 <param name="measurement" label="Measurement" type="text" /> | |
88 </when> | |
89 </conditional> | |
90 </xml> | |
91 </macros> | |
92 | |
93 <expand macro="py_requirements"/> | |
94 <expand macro="cmd_modules" /> | |
95 | |
96 <configfiles> | |
97 <inputs name="inputs" /> | |
98 <configfile name="script_file"> | |
99 import json | |
100 import sys | |
101 import os | |
102 | |
103 FOURSPACES=@SPACES@ | |
104 | |
105 input_json_path = sys.argv[1] | |
106 input_pipeline= sys.argv[2] | |
107 | |
108 params = json.load(open(input_json_path, "r")) | |
109 | |
110 def writemi(): | |
111 _str = "\nDisplayDataOnImage:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:6|show_window:False|notes:\\x5B\\'Add nuclei id as label\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count | |
112 | |
113 obj_img_params = params['con_display_obj_image'] | |
114 display_mode_params = params['con_display_mode'] | |
115 | |
116 _str += FOURSPACES + "Display object or image measurements?:%s\n" % obj_img_params['display_obj_image'] | |
117 | |
118 input_obj = obj_img_params['select_input_obj'] if obj_img_params['display_obj_image'] == "Object" else "None" | |
119 | |
120 _str += FOURSPACES + "Select the input objects:%s\n" % input_obj | |
121 _str += FOURSPACES + "Measurement to display:%s_%s\n" % (obj_img_params['con_obj_measurement_category'][ | |
122 'measurement_category'],obj_img_params['con_obj_measurement_category']['measurement']) | |
123 _str += FOURSPACES + "Select the image on which to display the measurements:%s\n" % params[ | |
124 'image_to_display_measurements'] | |
125 | |
126 display_mode = display_mode_params['display_mode'] | |
127 | |
128 if display_mode == "Text": | |
129 text_color = display_mode_params['text_color'] | |
130 font_size = display_mode_params['font_size'] | |
131 no_of_decimals = display_mode_params['number_of_decimals'] | |
132 annotation_offset = display_mode_params['annotation_offset'] | |
133 color_map = "Default" | |
134 color_map_scale = "Use this image's measurement range" | |
135 color_map_range = "0.0,1.0" | |
136 else: | |
137 text_color = "#ff0000" | |
138 font_size = 11 | |
139 no_of_decimals = 0 | |
140 annotation_offset = 0 | |
141 color_map = display_mode_params['color_map'] | |
142 color_map_scale = display_mode_params['con_color_map_scale']['color_map_scale'] | |
143 if color_map_scale == "Manual": | |
144 color_map_range ="%.1f,%.1f" % (display_mode_params['con_color_map_scale']['min_color_map_range'], display_mode_params['con_color_map_scale']['max_color_map_range']) | |
145 else: | |
146 color_map_range = "0.0,1.0" | |
147 | |
148 _str += FOURSPACES + "Text color:%s\n" % text_color | |
149 _str += FOURSPACES + "Name the output image that has the measurements displayed:%s\n" % params['name_output_image'] | |
150 _str += FOURSPACES + "Font size (points):%d\n" % font_size | |
151 _str += FOURSPACES + "Number of decimals:%d\n" % no_of_decimals | |
152 _str += FOURSPACES + "Image elements to save:%s\n" % params['element_to_save'] | |
153 _str += FOURSPACES + "Annotation offset (in pixels):%d\n" % annotation_offset | |
154 _str += FOURSPACES + "Display mode:%s\n" % display_mode | |
155 _str += FOURSPACES + "Color map:%s\n" % color_map | |
156 _str += FOURSPACES + "Display background image?:%s\n" % params['display_background_image'] | |
157 _str += FOURSPACES + "Color map scale:%s\n" % color_map_scale | |
158 _str += FOURSPACES + "Color map range:%s\n" % color_map_range | |
159 | |
160 return _str | |
161 | |
162 | |
163 with open(input_pipeline) as fin: | |
164 lines = fin.readlines() | |
165 | |
166 k, v = lines[4].strip().split(':') | |
167 | |
168 module_count = int(v) | |
169 new_count = module_count + 1 | |
170 lines[4] = k + ":%d\n" % new_count | |
171 | |
172 with open("output", "w") as f: | |
173 f.writelines(lines) | |
174 f.write(writemi()) | |
175 | |
176 f.close() | |
177 </configfile> | |
178 </configfiles> | |
179 | |
180 <inputs> | |
181 <expand macro="input_pipeline_macro" /> | |
182 <conditional name="con_display_obj_image"> | |
183 <param name="display_obj_image" type="select" label="Display object or image measurements?"> | |
184 <option value="Object">Object</option> | |
185 <option value="Image">Image</option> | |
186 </param> | |
187 <when value="Object"> | |
188 <expand macro="display_object" /> | |
189 </when> | |
190 <when value="Image"> | |
191 <expand macro="display_image" /> | |
192 </when> | |
193 </conditional> | |
194 | |
195 <param name="display_background_image" label="Display background image?" type="select" display="radio"> | |
196 <option value="Yes">Yes</option> | |
197 <option value="No">No</option> | |
198 </param> | |
199 | |
200 <param name="image_to_display_measurements" label="Select the image on which to display the measurements" type="text"> | |
201 <expand macro="text_validator" /> | |
202 </param> | |
203 | |
204 <conditional name="con_display_mode"> | |
205 <param name="display_mode" type="select" label="Display mode"> | |
206 <option value="Text">Text</option> | |
207 <option value="Color">Color</option> | |
208 </param> | |
209 <when value="Text"> | |
210 <param name="text_color" type="color" label="Text color" /> | |
211 <param name="font_size" type="integer" label="Font size(points)" value="11" min="8"> | |
212 </param> | |
213 <param name="number_of_decimals" type="integer" label="Number of decimals" value="0"/> | |
214 <param name="annotation_offset" type="integer" label="Annotation offset (in pixels)" value="0" /> | |
215 </when> | |
216 <when value="Color"> | |
217 <param name="color_map" label="Color map" type="select" help="DisplayDataOnImage assigns a color to each object’s measurement value from a colormap when in colormap-mode, mapping the value to a color along the colormap’s continuum. This mapping has implicit upper and lower bounds to its range which are the extremes of the colormap. This setting determines whether the extremes are the minimum and maximum "> | |
218 <option value="Default">Default</option> | |
219 </param> | |
220 <conditional name="con_color_map_scale"> | |
221 <param name="color_map_scale" label="Color map scale" type="select" help="assigns a color to each object’s measurement value from a colormap when in colormap-mode, mapping the value to a color along the colormap’s continuum. This mapping has implicit upper and lower bounds to its range which are the extremes of the colormap. This setting determines whether the extremes are the minimum and maximum values of the measurement from among the objects in the current image or manually-entered extremes"> | |
222 <option value="Use this image's measurement range">Use this image's measurement range</option> | |
223 <option value="Manual">Manual</option> | |
224 <sanitizer sanitize="false"/> | |
225 </param> | |
226 <when value="Manual"> | |
227 <param name="min_color_map_range" label="Min. color map range" type="float" help="This setting determines the lower bounds of the values for the color map" value="0.0" min="0.0" /> | |
228 <param name="max_color_map_range" label="Max. color map range" type="float" help="This setting determines the upper bounds of the values for the color map" value="1.0" max="1.0" /> | |
229 </when> | |
230 <when value="Use this image's measurement range" /> | |
231 </conditional> | |
232 </when> | |
233 </conditional> | |
234 | |
235 <param name="name_output_image" label="Name the output image that has the measurements displayed" type="text"> | |
236 <expand macro="text_validator" /> | |
237 </param> | |
238 <param name="element_to_save" type="select" label="Image elements to save"> | |
239 <option value="Image">Image</option> | |
240 <option value="Figure">Figure</option> | |
241 <option value="Axes">Axes</option> | |
242 </param> | |
243 </inputs> | |
244 | |
245 <outputs> | |
246 <expand macro="output_pipeline_macro" /> | |
247 </outputs> | |
248 | |
249 <tests> | |
250 <test> | |
251 <expand macro="test_input_pipeline_param" /> | |
252 <conditional name="con_display_obj_image"> | |
253 <param name="display_obj_image" value="Object" /> | |
254 <param name="select_input_obj" value="Nuclei" /> | |
255 <conditional name="con_obj_measurement_category"> | |
256 <param name="measurement_category" value="Number" /> | |
257 <param name="measurement" value="Object_Number" /> | |
258 </conditional> | |
259 </conditional> | |
260 <param name="display_background_image" value="Yes" /> | |
261 <param name="image_to_display_measurements" value="DNA" /> | |
262 <conditional name="con_display_mode"> | |
263 <param name="display_mode" value="Text" /> | |
264 <param name="text_color" value="#ff0000"/> | |
265 <param name="font_size" value="11" /> | |
266 <param name="number_of_decimals" value="0" /> | |
267 <param name="annotation_offset" value="0" /> | |
268 </conditional> | |
269 <param name="name_output_image" value="ImageDisplay" /> | |
270 <param name="element_to_save" value="Image" /> | |
271 | |
272 <expand macro="test_out_file" file="display_data_on_image.txt" /> | |
273 </test> | |
274 </tests> | |
275 <expand macro="help" module="DisplayDataOnImage"/> | |
276 <expand macro="citations" /> | |
277 </tool> |