Mercurial > repos > bgruening > cp_enhance_or_suppress_features
comparison enhance_or_suppress_features.xml @ 0:e28d0b4ed79a draft
"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 6d73056a625002d0275b5a9a90a9fae329ce47f1"
author | bgruening |
---|---|
date | Thu, 26 Mar 2020 20:07:02 +0000 |
parents | |
children | b7014aafa455 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e28d0b4ed79a |
---|---|
1 <tool id="cp_enhance_or_suppress_features" name="EnhanceOrSuppressFeatures" version="@CP_VERSION@"> | |
2 <description>enhances or suppresses certain image features, which can improve subsequent identification of objects</description> | |
3 | |
4 <macros> | |
5 <import>macros.xml</import> | |
6 | |
7 <xml name="feature_speckles"> | |
8 <param name="speckles_feature_size" label="Feature size" type="integer" value="10" /> | |
9 <param name="speed_accuracy" label="Speed and accuracy" type="select"> | |
10 <option value="Fast">Fast</option> | |
11 <option value="Slow">Slow</option> | |
12 </param> | |
13 </xml> | |
14 <xml name="feature_neurites"> | |
15 <conditional name="con_feature_neurites"> | |
16 <param name="enhancement_method" label="Enhancement method" type="select"> | |
17 <option value="Tubeness">Tubeness</option> | |
18 <option value="Line structures">Line structures</option> | |
19 </param> | |
20 <when value="Tubeness"> | |
21 <param name="tube_smoothing_scale" label="Smoothing scale" type="float" value="2.0" min="0.0" /> | |
22 </when> | |
23 <when value="Line structures"> | |
24 <param name="line_structures_feature_size" label="Feature size" type="integer" value="10" /> | |
25 </when> | |
26 </conditional> | |
27 </xml> | |
28 <xml name="feature_darkholes"> | |
29 <param name="min_hole_size" label="Minimum hole size" type="integer" value="1" min="0"/> | |
30 <param name="max_hole_size" label="Maximum hole size" type="integer" value="15"/> | |
31 </xml> | |
32 <xml name="feature_circle"> | |
33 <param name="circle_feature_size" label="Feature size" type="integer" value="10"/> | |
34 </xml> | |
35 <xml name="feature_texture"> | |
36 <param name="texture_smoothing_scale" label="Smoothing scale" type="float" value="2.0" min="0.0"/> | |
37 </xml> | |
38 <xml name="feature_dic"> | |
39 <param name="dic_smoothing_scale" label="Smoothing scale" type="float" value="2.0" min="0.0" /> | |
40 <param name="dic_shear_angle" label="Shear angle" type="float" value="0.0" min="0.0" /> | |
41 <param name="dic_decay" label="Decay" type="float" value="0.95" min="0.0" /> | |
42 </xml> | |
43 </macros> | |
44 | |
45 <expand macro="py_requirements"/> | |
46 <expand macro="cmd_modules" /> | |
47 | |
48 <configfiles> | |
49 <inputs name="inputs" /> | |
50 <configfile name="script_file"> | |
51 import json | |
52 import sys | |
53 import os | |
54 | |
55 FOURSPACES=@SPACES@ | |
56 | |
57 input_json_path = sys.argv[1] | |
58 input_pipeline= sys.argv[2] | |
59 | |
60 params = json.load(open(input_json_path, "r")) | |
61 | |
62 def writeesf(): | |
63 _str = "\nEnhanceOrSuppressFeatures:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:6|show_window:False|notes:\\x5B\\'Identify nucleoli\\', \\'PARAMS\\x3A Range of hole sizes\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count | |
64 _str += FOURSPACES + "Select the input image:%s\n" % params['input_image'] | |
65 _str += FOURSPACES + "Name the output image:%s\n" % params['name_output_image'] | |
66 | |
67 operation = params['con_enhance_suppress']['select_operation'] | |
68 _str += FOURSPACES + "Select the operation:%s\n" % operation | |
69 | |
70 con_feature_type = params['con_enhance_suppress']['con_feature_type'] | |
71 | |
72 if operation == "Suppress": | |
73 _str += FOURSPACES + "Feature size:%s\n" % params['con_enhance_suppress']['feature_size'] | |
74 ## Below values are not used in this case, but required by CP pipeline file to be | |
75 ## present as some sorts of "default" values | |
76 _str += FOURSPACES + "Feature type:Speckles" | |
77 _str += FOURSPACES + "Range of hole sizes:1,10" | |
78 _str += FOURSPACES + "Smoothing scale:2.0" | |
79 _str += FOURSPACES + "Shear angle:0.0" | |
80 _str += FOURSPACES + "Decay:0.95" | |
81 _str += FOURSPACES + "Enhancement method:Tubeness" | |
82 _str += FOURSPACES + "Speed and accuracy:Fast" | |
83 elif operation == "Enhance": | |
84 feature_type = con_feature_type['feature_type'] | |
85 | |
86 if feature_type == "Speckles": | |
87 _str += FOURSPACES + "Feature size:%d\n" % con_feature_type['speckles_feature_size'] | |
88 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
89 _str += FOURSPACES + "Range of hole sizes:1,10\n" | |
90 _str += FOURSPACES + "Smoothing scale:2.0\n" | |
91 _str += FOURSPACES + "Shear angle:0.0\n" | |
92 _str += FOURSPACES + "Decay:0.95\n" | |
93 _str += FOURSPACES + "Enhancement method:Tubeness\n" | |
94 _str += FOURSPACES + "Speed and accuracy:%s\n" % con_feature_type['speed_accuracy'] | |
95 elif feature_type == "Neurites": | |
96 enhancement_method = con_feature_type['con_feature_neurites']['enhancement_method'] | |
97 if enhancement_method == "Tubeness": | |
98 _str += FOURSPACES + "Feature size:10\n" | |
99 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
100 _str += FOURSPACES + "Range of hole sizes:1,10\n" | |
101 _str += FOURSPACES + "Smoothing scale:%.1f\n" % con_feature_type['con_feature_neurites']['tube_smoothing_scale'] | |
102 _str += FOURSPACES + "Shear angle:0.0\n" | |
103 _str += FOURSPACES + "Decay:0.95\n" | |
104 _str += FOURSPACES + "Enhancement method:%s\n" % enhancement_method | |
105 _str += FOURSPACES + "Speed and accuracy:Fast\n" | |
106 elif enhancement_method == "Line structures": | |
107 _str += FOURSPACES + "Feature size:%s\n" % con_feature_type['con_feature_neurites']['line_structures_feature_size'] | |
108 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
109 _str += FOURSPACES + "Range of hole sizes:1,10\n" | |
110 _str += FOURSPACES + "Smoothing scale:2.0\n" | |
111 _str += FOURSPACES + "Shear angle:0.0\n" | |
112 _str += FOURSPACES + "Decay:0.9\n5" | |
113 _str += FOURSPACES + "Enhancement method:%s\n" % enhancement_method | |
114 _str += FOURSPACES + "Speed and accuracy:Fast\n" | |
115 elif feature_type == "Dark holes": | |
116 _str += FOURSPACES + "Feature size:10\n" | |
117 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
118 _str += FOURSPACES + "Range of hole sizes:%d,%d\n" %(con_feature_type['min_hole_size'],con_feature_type['max_hole_size']) | |
119 _str += FOURSPACES + "Smoothing scale:2.0\n" | |
120 _str += FOURSPACES + "Shear angle:0.0\n" | |
121 _str += FOURSPACES + "Decay:0.95\n" | |
122 _str += FOURSPACES + "Enhancement method:Tubeness\n" | |
123 _str += FOURSPACES + "Speed and accuracy:Fast\n" | |
124 elif feature_type == "Circles": | |
125 _str += FOURSPACES + "Feature size:%d\n" % con_feature_type['circle_feature_size'] | |
126 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
127 _str += FOURSPACES + "Range of hole sizes:1,10\n" | |
128 _str += FOURSPACES + "Smoothing scale:2.0\n" | |
129 _str += FOURSPACES + "Shear angle:0.0\n" | |
130 _str += FOURSPACES + "Decay:0.95\n" | |
131 _str += FOURSPACES + "Enhancement method:Tubeness\n" | |
132 _str += FOURSPACES + "Speed and accuracy:Fast\n" | |
133 elif feature_type == "Texture": | |
134 _str += FOURSPACES + "Feature size:%d\n" % con_feature_type['circle_feature_size'] | |
135 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
136 _str += FOURSPACES + "Range of hole sizes:1,10\n" | |
137 _str += FOURSPACES + "Smoothing scale:%.1f\n" % con_feature_type['texture_smoothing_scale'] | |
138 _str += FOURSPACES + "Shear angle:0.0\n" | |
139 _str += FOURSPACES + "Decay:0.95\n" | |
140 _str += FOURSPACES + "Enhancement method:Tubeness\n" | |
141 _str += FOURSPACES + "Speed and accuracy:Fast\n" | |
142 elif feature_type == "DIC": | |
143 _str += FOURSPACES + "Feature size:10\n" | |
144 _str += FOURSPACES + "Feature type:%s\n" % feature_type | |
145 _str += FOURSPACES + "Range of hole sizes:1,10\n" | |
146 _str += FOURSPACES + "Smoothing scale:%.1f\n" % con_feature_type['texture_smoothing_scale'] | |
147 _str += FOURSPACES + "Shear angle:%.1f\n" % con_feature_type['dic_shear_angle'] | |
148 _str += FOURSPACES + "Decay:%.2f\n" % con_feature_type['dic_decay'] | |
149 _str += FOURSPACES + "Enhancement method:Tubeness\n" | |
150 _str += FOURSPACES + "Speed and accuracy:Fast\n" | |
151 | |
152 return _str | |
153 | |
154 | |
155 with open(input_pipeline) as fin: | |
156 lines = fin.readlines() | |
157 | |
158 k, v = lines[4].strip().split(':') | |
159 | |
160 module_count = int(v) | |
161 new_count = module_count + 1 | |
162 lines[4] = k + ":%d\n" % new_count | |
163 | |
164 with open("output", "w") as f: | |
165 f.writelines(lines) | |
166 f.write(writeesf()) | |
167 | |
168 f.close() | |
169 </configfile> | |
170 </configfiles> | |
171 | |
172 <inputs> | |
173 | |
174 <expand macro="input_pipeline_macro"/> | |
175 <param name="input_image" type="text" label="Select the input image" /> | |
176 | |
177 <param name="name_output_image" type="text" label="Name the output image" /> | |
178 | |
179 <conditional name="con_enhance_suppress"> | |
180 <param name="select_operation" label="Select the operation" type="select"> | |
181 <option value="Enhance">Enhance</option> | |
182 <option value="Suppress">Suppress</option> | |
183 </param> | |
184 | |
185 <when value="Enhance"> | |
186 <conditional name="con_feature_type"> | |
187 <param name="feature_type" type="select" label="Feature type"> | |
188 <option value="Speckles">Speckles</option> | |
189 <option value="Neurites">Neurites</option> | |
190 <option value="Dark holes">Dark holes</option> | |
191 <option value="Circles">Circles</option> | |
192 <option value="Texture">Texture</option> | |
193 <option value="DIC">DIC</option> | |
194 </param> | |
195 <when value="Speckles"> | |
196 <expand macro="feature_speckles" /> | |
197 </when> | |
198 <when value="Neurites"> | |
199 <expand macro="feature_neurites" /> | |
200 </when> | |
201 <when value="Dark holes"> | |
202 <expand macro="feature_darkholes" /> | |
203 </when> | |
204 <when value="Circles"> | |
205 <expand macro="feature_circle" /> | |
206 </when> | |
207 <when value="Texture"> | |
208 <expand macro="feature_texture" /> | |
209 </when> | |
210 <when value="DIC"> | |
211 <expand macro="feature_dic" /> | |
212 </when> | |
213 </conditional> | |
214 </when> | |
215 | |
216 <when value="Suppress"> | |
217 <param name="feature_size" type="integer" label="Feature size" value="10"/> | |
218 </when> | |
219 | |
220 </conditional> | |
221 | |
222 </inputs> | |
223 | |
224 <outputs> | |
225 <expand macro="output_pipeline_macro" /> | |
226 </outputs> | |
227 | |
228 | |
229 <tests> | |
230 <test> | |
231 <expand macro="test_input_pipeline_param" /> | |
232 <param name="input_image" value="DNA" /> | |
233 <param name="name_output_image" value="DNAdarkholes" /> | |
234 <conditional name="con_enhance_suppress"> | |
235 <param name="select_operation" value="Enhance" /> | |
236 <conditional name="con_feature_type"> | |
237 <param name="feature_type" value="Dark holes" /> | |
238 <param name="min_hole_size" value="1" /> | |
239 <param name="max_hole_size" value="15" /> | |
240 </conditional> | |
241 </conditional> | |
242 | |
243 <expand macro="test_out_file" file="enhance_or_suppress_features.txt" /> | |
244 </test> | |
245 </tests> | |
246 | |
247 <expand macro="help" module="EnhanceOrSuppressFeatures" /> | |
248 <expand macro="citations" /> | |
249 </tool> |