comparison gray_to_color.xml @ 3:bbf1ef17c01b draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit c3917e27eb1c1deeb381aa0dc8161c07699562fb"
author bgruening
date Mon, 11 May 2020 07:56:38 -0400
parents e5870c434f28
children ad271f78a87a
comparison
equal deleted inserted replaced
2:e5870c434f28 3:bbf1ef17c01b
1 <tool id="cp_gray_to_color" name="GrayToColor" version="@CP_VERSION@"> 1 <tool id="cp_gray_to_color" name="GrayToColor" version="@CP_VERSION@">
2 <description>take grayscale images and produces a color image from them</description> 2 <description>take grayscale images and produces a color image from them</description>
3 <macros> 3 <macros>
4 <import>macros.xml</import> 4 <import>macros.xml</import>
5 <xml name="rgb"> 5 <xml name="rgb">
6 <param name="rgb_red" label="Select the image to be colored red" value="Leave this black" type="text"/> 6 <param name="rgb_red" label="Enter the name of the image to be colored red" value="Leave this black" type="text"/>
7 <param name="rgb_red_weight" label="Relative weight for the red image" optional="true" type="float" value="0.8"/> 7 <param name="rgb_red_weight" label="Relative weight for the red image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
8 8
9 <param name="rgb_green" label="Select the image to be colored green" value="Leave this black" type="text"/> 9 <param name="rgb_green" label="Enter the name of the image to be colored green" value="Leave this black" type="text"/>
10 <param name="rgb_green_weight" label="Relative weight for the green image" optional="true" type="float" value="1.0" /> 10 <param name="rgb_green_weight" label="Relative weight for the green image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
11 11
12 <param name="rgb_blue" label="Select the image to be colored blue" value="Leave this black" type="text"/> 12 <param name="rgb_blue" label="Enter the name of the image to be colored blue" value="Leave this black" type="text"/>
13 <param name="rgb_blue_weight" label="Relative weight for the blue image" optional="true" type="float" value="0.5"/> 13 <param name="rgb_blue_weight" label="Relative weight for the blue image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
14
15 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"/>
16 </xml> 14 </xml>
17 <xml name="cmyk"> 15 <xml name="cmyk">
18 <param name="cmyk_cyan" label="Select the image to be colored cyan" value="Leave this black" type="text"/> 16 <param name="cmyk_cyan" label="Enter the name of the image to be colored cyan" value="Leave this black" type="text"/>
19 <param name="cmyk_cyan_weight" label="Relative weight for the cyan image" optional="true" type="float" value="0.5"/> 17 <param name="cmyk_cyan_weight" label="Relative weight for the cyan image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
20 18
21 <param name="cmyk_magenta" label="Select the image to be colored magenta" value="Leave this black" type="text"/> 19 <param name="cmyk_magenta" label="Enter the name of the image to be colored magenta" value="Leave this black" type="text"/>
22 <param name="rgb_green_weight" label="Relative weight for the green image" optional="true" type="float" value="0.0"/> 20 <param name="rgb_green_weight" label="Relative weight for the green image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
23 21
24 <param name="cmyk_yellow" label="Select the image to be colored yellow" value="Leave this black" type="text"/> 22 <param name="cmyk_yellow" label="Enter the name of the image to be colored yellow" value="Leave this black" type="text"/>
25 <param name="cmyk_yellow_weight" label="Relative weight for the yellow image" optional="true" type="float" value="0.0"/> 23 <param name="cmyk_yellow_weight" label="Relative weight for the yellow image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
26 24
27 <param name="cmyk_brightness" label="Select the image that determines brightness" value="Leave this black" type="text"/> 25 <param name="cmyk_brightness" label="Enter the name of the image that determines brightness" value="Leave this black" type="text"/>
28 <param name="cmyk_brightness_weight" label="Relative weight for the brightness image" optional="true" type="float" value="0.5"/> 26 <param name="cmyk_brightness_weight" label="Relative weight for the brightness image" optional="true" type="float" min="0.0" max="1.0" value="1.0" />
29
30 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text">
31 <expand macro="text_validator" />
32 </param>
33
34 </xml> 27 </xml>
35 <xml name="stack"> 28 <xml name="stack">
36 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"> 29 <repeat name="rpt_image_name" title="another channel" min="1">
37 <expand macro="text_validator" /> 30 <param name="image_name" type="text" label="Enter the image name">
38 </param>
39 <repeat name="rpt_image_name" title="Add another channel">
40 <param name="image_name" type="text" label="Image name" >
41 <expand macro="text_validator" /> 31 <expand macro="text_validator" />
42 </param> 32 </param>
43 </repeat> 33 </repeat>
44 </xml> 34 </xml>
45 <xml name="composite"> 35 <xml name="composite">
46 <param name="name_output_image" label="Name the output image" value="ColorImage" type="text"> 36 <repeat name="rpt_image_name" title="another channel" min="1">
47 <expand macro="text_validator" />
48 </param>
49 <repeat name="rpt_image_name" title="Add another channel">
50 <param name="image_name" type="text" label="Image name"> 37 <param name="image_name" type="text" label="Image name">
51 <expand macro="text_validator" /> 38 <expand macro="text_validator" />
52 </param> 39 </param>
53 <param name="color" type="color" label="Color" /> 40 <param name="color" type="color" label="Color" />
54 <param name="weight" type="float" label="Weight" value="0.8" min="0.0" max="1.0" /> 41 <param name="weight" type="float" label="Weight" value="1.0" min="0.0" max="1.0"/>
55 </repeat> 42 </repeat>
56 </xml> 43 </xml>
57 </macros> 44 </macros>
58 45
59 <expand macro="py_requirements"/> 46 <expand macro="py_requirements"/>
60 <expand macro="cmd_modules" /> 47 <expand macro="cmd_modules" />
77 def writegtc(): 64 def writegtc():
78 _str = "\nGrayToColor:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:3|show_window:False|notes:\\x5B\\'Combine masks nuclei + nucleoli with colors\\'\\x5D|batch_state:array(\\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count 65 _str = "\nGrayToColor:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:3|show_window:False|notes:\\x5B\\'Combine masks nuclei + nucleoli with colors\\'\\x5D|batch_state:array(\\x5B\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count
79 66
80 color_scheme = params['con_color_scheme']['color_scheme'] 67 color_scheme = params['con_color_scheme']['color_scheme']
81 68
82 rgb_blue = params['con_color_scheme']['rgb_blue'] if 'rgb_blue' in params[ 69 rgb_blue = params['con_color_scheme']['rgb_blue'] if 'rgb_blue' in params['con_color_scheme'] else 'Leave this black'
83 'con_color_scheme'] else 'Leave this black' 70 rgb_blue_weight = 1.0 if params['con_color_scheme']['rgb_blue_weight'] == "" else params['con_color_scheme']['rgb_blue_weight']
84 rgb_blue_weight = 1.0 if params['con_color_scheme']['rgb_blue_weight'] == "" else params['con_color_scheme'][ 71
85 'rgb_blue_weight'] 72 rgb_green = params['con_color_scheme']['rgb_green'] if 'rgb_green' in params['con_color_scheme'] else 'Leave this black'
86 73 rgb_green_weight = 1.0 if params['con_color_scheme']['rgb_green_weight'] == "" else params['con_color_scheme']['rgb_green_weight']
87 rgb_green = params['con_color_scheme']['rgb_green'] if 'rgb_green' in params[
88 'con_color_scheme'] else 'Leave this black'
89 rgb_green_weight = 1.0 if params['con_color_scheme']['rgb_green_weight'] == "" else params['con_color_scheme'][
90 'rgb_green_weight']
91 74
92 rgb_red = params['con_color_scheme']['rgb_red'] if 'rgb_red' in params['con_color_scheme'] else 'Leave this black' 75 rgb_red = params['con_color_scheme']['rgb_red'] if 'rgb_red' in params['con_color_scheme'] else 'Leave this black'
93 rgb_red_weight = 1.0 if params['con_color_scheme']['rgb_red_weight'] == "" else params['con_color_scheme'][ 76 rgb_red_weight = 1.0 if params['con_color_scheme']['rgb_red_weight'] == "" else params['con_color_scheme']['rgb_red_weight']
94 'rgb_red_weight'] 77
95 78 name_output_image = params['name_output_image']
96 name_output_image = params['con_color_scheme']['name_output_image'] 79
97 80 cmyk_cyan = params['con_color_scheme']['cmyk_cyan'] if 'cmyk_cyan' in params['con_color_scheme'] else 'Leave this black'
98 cmyk_cyan = params['con_color_scheme']['cmyk_cyan'] if 'cmyk_cyan' in params[
99 'con_color_scheme'] else 'Leave this black'
100 81
101 if 'cmyk_cyan_weight' in params['con_color_scheme']: 82 if 'cmyk_cyan_weight' in params['con_color_scheme']:
102 if params['con_color_scheme']['cmyk_cyan_weight'] == "": 83 if params['con_color_scheme']['cmyk_cyan_weight'] == "":
103 cmyk_cyan_weight = 1.0 84 cmyk_cyan_weight = 1.0
104 else: 85 else:
105 cmyk_cyan_weight = params['con_color_scheme']['cmyk_cyan_weight'] 86 cmyk_cyan_weight = params['con_color_scheme']['cmyk_cyan_weight']
106 else: 87 else:
107 cmyk_cyan_weight = 1.0 88 cmyk_cyan_weight = 1.0
108 89
109 cmyk_magenta = params['con_color_scheme']['cmyk_magenta'] if 'cmyk_magenta' in params[ 90 cmyk_magenta = params['con_color_scheme']['cmyk_magenta'] if 'cmyk_magenta' in params['con_color_scheme'] else 'Leave this black'
110 'con_color_scheme'] else 'Leave this black'
111 91
112 if 'cmyk_magenta_weight' in params['con_color_scheme']: 92 if 'cmyk_magenta_weight' in params['con_color_scheme']:
113 if params['con_color_scheme']['cmyk_magenta_weight'] == "": 93 if params['con_color_scheme']['cmyk_magenta_weight'] == "":
114 cmyk_magenta_weight = 1.0 94 cmyk_magenta_weight = 1.0
115 else: 95 else:
116 cmyk_magenta_weight = params['con_color_scheme']['cmyk_cyan_weight'] 96 cmyk_magenta_weight = params['con_color_scheme']['cmyk_cyan_weight']
117 else: 97 else:
118 cmyk_magenta_weight = 1.0 98 cmyk_magenta_weight = 1.0
119 99
120 cmyk_yellow = params['con_color_scheme']['cmyk_yellow'] if 'cmyk_yellow' in params[ 100 cmyk_yellow = params['con_color_scheme']['cmyk_yellow'] if 'cmyk_yellow' in params['con_color_scheme'] else 'Leave this black'
121 'con_color_scheme'] else 'Leave this black'
122 101
123 if 'cmyk_yellow_weight' in params['con_color_scheme']: 102 if 'cmyk_yellow_weight' in params['con_color_scheme']:
124 if params['con_color_scheme']['cmyk_yellow_weight'] == "": 103 if params['con_color_scheme']['cmyk_yellow_weight'] == "":
125 cmyk_yellow_weight = 1.0 104 cmyk_yellow_weight = 1.0
126 else: 105 else:
127 cmyk_yellow_weight = params['con_color_scheme']['cmyk_yellow_weight'] 106 cmyk_yellow_weight = params['con_color_scheme']['cmyk_yellow_weight']
128 else: 107 else:
129 cmyk_yellow_weight = 1.0 108 cmyk_yellow_weight = 1.0
130 109
131 cmyk_brightness = params['con_color_scheme']['cmyk_brightness'] if 'cmyk_brightness' in params[ 110 cmyk_brightness = params['con_color_scheme']['cmyk_brightness'] if 'cmyk_brightness' in params['con_color_scheme'] else 'Leave this black'
132 'con_color_scheme'] else 'Leave this black'
133 111
134 if 'cmyk_brightness_weight' in params['con_color_scheme']: 112 if 'cmyk_brightness_weight' in params['con_color_scheme']:
135 if params['con_color_scheme']['cmyk_brightness_weight'] == "": 113 if params['con_color_scheme']['cmyk_brightness_weight'] == "":
136 cmyk_brightness_weight = 1.0 114 cmyk_brightness_weight = 1.0
137 else: 115 else:
192 170
193 module_count = int(v) 171 module_count = int(v)
194 new_count = module_count + 1 172 new_count = module_count + 1
195 lines[4] = k + ":%d\n" % new_count 173 lines[4] = k + ":%d\n" % new_count
196 174
197 with open("output", "w") as f: 175 with open("output.cppipe", "w") as f:
198 f.writelines(lines) 176 f.writelines(lines)
199 f.write(writegtc()) 177 f.write(writegtc())
200 178
201 f.close() 179 f.close()
202 </configfile> 180 </configfile>
203 </configfiles> 181 </configfiles>
204 182
205 <inputs> 183 <inputs>
206 <expand macro="input_pipeline_macro" /> 184 <expand macro="input_pipeline_param" />
185 <param name="name_output_image" label="Enter the name of the resulting image" value="ColorImage" type="text">
186
187 <expand macro="text_validator" />
188 </param>
207 <conditional name="con_color_scheme"> 189 <conditional name="con_color_scheme">
208 <param name="color_scheme" label="Select a color scheme" type="select"> 190 <param name="color_scheme" label="Select a color scheme" type="select">
191 <help>
192 <![CDATA[
193 This tool can use one of two color schemes to combine images:
194 <br> - RGB: Each input image determines the intensity of one of the color channels: red, green, and blue.
195 <br> - CMYK: Three of the input images are combined to determine the colors (cyan, magenta, and yellow) and a fourth is used only for brightness. The cyan image adds equally to the green and blue intensities. The magenta image adds equally to the red and blue intensities. The yellow image adds equally to the red and green intensities.
196 <br> - Stack: The channels are stacked in the order listed, from top to bottom. An arbitrary number of channels is allowed.
197 For example, you could create a 5-channel image by providing 5 grayscale images. The first grayscale image you provide will fill the first channel, the second grayscale image you provide will fill the second channel, and so on.
198 <br> - Composite: A color is assigned to each grayscale image. Each grayscale image is converted to color by multiplying the intensity by the color and the resulting color images are added together. An arbitrary number of channels can be composited into a single color image.
199 ]]>
200 </help>
209 <option value="RGB">RGB</option> 201 <option value="RGB">RGB</option>
210 <option value="CMYK">CMYK</option> 202 <option value="CMYK">CMYK</option>
211 <option value="Stack">Stack</option> 203 <option value="Stack">Stack</option>
212 <option value="Composite">Composite</option> 204 <option value="Composite">Composite</option>
213 </param> 205 </param>
225 </when> 217 </when>
226 </conditional> 218 </conditional>
227 </inputs> 219 </inputs>
228 220
229 <outputs> 221 <outputs>
230 <expand macro="output_pipeline_macro" /> 222 <expand macro="output_pipeline_param" />
231 </outputs> 223 </outputs>
232 224
233 <tests> 225 <tests>
234 <test> 226 <test>
235 <expand macro="test_input_pipeline_param" /> 227 <expand macro="test_input_pipeline_param" />
236 <conditional name="con_color_scheme">
237 <param name="color_scheme" value="RGB" />
238 <param name="rgb_red" value="MaskNucleoli" />
239 <param name="rgb_red_weight" value="0.8" />
240 <param name="rgb_green" value="Leave this black" />
241 <param name="rgb_blue" value="MaskNuclei" />
242 <param name="rgb_blue_weight" value="0.5" />
243 <param name="name_output_image" value="CombinedMask" /> 228 <param name="name_output_image" value="CombinedMask" />
244 </conditional> 229 <conditional name="con_color_scheme">
245 <expand macro="test_out_file" file="gray_to_color.txt" /> 230 <param name="color_scheme" value="RGB" />
246 </test> 231 <param name="rgb_red" value="MaskNucleoli" />
232 <param name="rgb_red_weight" value="0.8" />
233 <param name="rgb_green" value="Leave this black" />
234 <param name="rgb_blue" value="MaskNuclei" />
235 <param name="rgb_blue_weight" value="0.5" />
236 </conditional>
237 <expand macro="test_out_file" file="gray_to_color.cppipe" />
238 </test>
247 </tests> 239 </tests>
248 240
249 <expand macro="help" module="GrayToColor" /> 241 <help>
242 <![CDATA[
243 .. class:: infomark
244
245 **What it does**
246
247 This tool takes grayscale images as input and assigns them to colors in a red, green, blue (RGB) image or a cyan, magenta, yellow, black (CMYK) image. Each color’s brightness can be adjusted independently by using relative weights.
248
249 @COMMON_HELP@
250 ]]>
251 </help>
252
250 <expand macro="citations" /> 253 <expand macro="citations" />
251 254
252 </tool> 255 </tool>