-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathimage_math.xml
More file actions
303 lines (292 loc) · 17.3 KB
/
image_math.xml
File metadata and controls
303 lines (292 loc) · 17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<tool id="cp_image_math" name="ImageMath" version="@CP_VERSION@+galaxy@VERSION_SUFFIX@" python_template_version="3.5">
<description>with CellProfiler</description>
<macros>
<import>macros.xml</import>
<token name="@VERSION_SUFFIX@">2</token>
<xml name="image_without_multiplier" token_order="first">
<conditional name="image_or_measurement_@ORDER@">
<param name="image_or_measurement_@ORDER@" type="select" label="Image or measurement?" help="You can perform math operations or you can use a measurement for one of the operands.">
<option value="Image">Image</option>
<option value="Measurement">Measurement</option>
</param>
<when value="Image">
<param name="select_the_@ORDER@_image" type="text" label="Enter the name of the @ORDER@ image">
<expand macro="text_validator"/>
</param>
</when>
<when value="Measurement">
<conditional name="category_@ORDER@">
<param name="category_@ORDER@" type="select" label="Category" help="Select a measurement made on the @ORDER@ image. The value of the measurement is used for the operand for all of the pixels of the other operand's image.">
<option value="FileName">FileName</option>
<option value="Frame">Frame</option>
<option value="Height">Height</option>
<option value="MD5digest">MD5Digest</option>
<option value="PathName">PathName</option>
<option value="Scaling">Scaling</option>
<option value="Series">Series</option>
<option value="URL">URL</option>
<option value="Width">Width</option>
</param>
<when value="FileName">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="Frame">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="Height">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="MD5digest">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="PathName">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="Scaling">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="Series">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="URL">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
<when value="Width">
<param name="measurement_@ORDER@" type="text" label="Measurement">
<expand macro="text_validator"/>
</param>
</when>
</conditional>
</when>
</conditional>
</xml>
<xml name="section_image_with_multiplier" token_title="First Image" token_order="first">
<section name="@ORDER@_image" title="@TITLE@" expanded="true">
<expand macro="image_without_multiplier" order="@ORDER@"/>
<param name="multiply_the_@ORDER@_image_by" type="float" value="1.0" label="Enter the number that you would like to multiply the @ORDER@ image by"/>
</section>
</xml>
<xml name="section_image_without_multiplier" token_title="First Image" token_order="first">
<section name="@ORDER@_image" title="@TITLE@" expanded="true">
<expand macro="image_without_multiplier" order="@ORDER@"/>
</section>
</xml>
<xml name="section_ops_result">
<section name="op_results" title="OPERATIONS ON THE RESULTS" expanded="false">
<param name="raise_the_power_of_the_result_by" type="float" value="1.0" label="Enter an exponent to raise the result to after the chosen operation"/>
<param name="multiply_the_result_by" type="float" value="1.0" label="Enter the number that you would like to multiply the above image by"/>
<param name="add_to_result" type="float" value="0.0" label="Enter a number to add to the result after the chosen operation"/>
<param name="set_values_less_than_0_equal_to_0" type="select" display="radio" label="Set the values less than 0 equal to 0?" help="Values outside the range 0 to 1 might not be handled well by other CellProfiler tools.">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<param name="set_values_greater_than_1_equal_to_1" type="select" display="radio" label="Set the values greater than 1 equal to 1?" help="Values outside the range 0 to 1 might not be handled well by other CellProfiler tools.">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
</section>
</xml>
</macros>
<edam_operations>
<edam_operation>operation_3443</edam_operation>
</edam_operations>
<xrefs>
<xref type="bio.tools">CellProfiler</xref>
<xref type="biii">cellprofiler</xref>
</xrefs>
<expand macro="py_requirements"/>
<command detect_errors="exit_code">
<![CDATA[
python '$__tool_directory__/image_math.py' -p '$input_pipeline' -i '$input_json'
]]>
</command>
<configfiles>
<inputs name="input_json"/>
</configfiles>
<inputs>
<expand macro="input_pipeline_param"/>
<param name="name_output_image" type="text" label="Enter a name for the resulting image">
<expand macro="text_validator"/>
</param>
<conditional name="operation">
<param name="operation" type="select" label="Operation" help="You can select operations for single images (Invert, Log transform base 2, Log transform legacy) or between pairs of images (Add, Subtract, Absolute Difference, Multiply, Divide, Average, Minimum, Maximum). Some operations produce binary images (And, Or, Not, Equals).">
<option value="add">Add</option>
<option value="subtract">Subtract</option>
<option value="multiply">Multiply</option>
<option value="divide">Divide</option>
<option value="average">Average</option>
<option value="minimum">Minimum</option>
<option value="maximum">Maximum</option>
<option value="invert">Invert</option>
<option value="log_2">Log transform (base 2)</option>
<option value="log_legacy">Log transform (legacy)</option>
<option value="and">And</option>
<option value="or">Or</option>
<option value="not">Not</option>
<option value="equals">Equals</option>
</param>
<when value="add">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="subtract">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="multiply">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="divide">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="average">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="minimum">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="maximum">
<expand macro="section_image_with_multiplier" title="First Image" order="first"/>
<expand macro="section_image_with_multiplier" title="Second Image" order="second"/>
<expand macro="section_ops_result"/>
</when>
<when value="invert">
<param name="select_the_image" type="text" label="Select the image">
<expand macro="text_validator"/>
</param>
<param name="multiply_the_image_by" type="float" value="1.0" label="Enter the number that you would like to multiply the above image by"/>
<expand macro="section_ops_result"/>
</when>
<when value="log_2">
<param name="select_the_image" type="text" label="Select the image">
<expand macro="text_validator"/>
</param>
<param name="multiply_the_image_by" type="float" value="1.0" label="Enter the number that you would like to multiply the above image by"/>
<expand macro="section_ops_result"/>
</when>
<when value="log_legacy">
<param name="select_the_image" type="text" label="Select the image">
<expand macro="text_validator"/>
</param>
<param name="multiply_the_image_by" type="float" value="1.0" label="Enter the number that you would like to multiply the above image by"/>
<expand macro="section_ops_result"/>
</when>
<when value="and">
<expand macro="section_image_without_multiplier" title="First Image" order="first"/>
<expand macro="section_image_without_multiplier" title="Second Image" order="second"/>
</when>
<when value="or">
<expand macro="section_image_without_multiplier" title="First Image" order="first"/>
<expand macro="section_image_without_multiplier" title="Second Image" order="second"/>
</when>
<when value="not">
<section name="first_image" title="Image" expanded="true">
<conditional name="image_or_measurement_first">
<param name="image_or_measurement_first" type="select" label="Image or measurement?">
<option value="Image">Image</option>
</param>
<when value="Image">
<param name="select_the_first_image" type="text" label="Enter the name of the image">
<expand macro="text_validator"/>
</param>
</when>
</conditional>
</section>
</when>
<when value="equals">
<expand macro="section_image_without_multiplier" title="First Image" order="first"/>
<expand macro="section_image_without_multiplier" title="Second Image" order="second"/>
</when>
</conditional>
<param name="ignore_the_image_masks" type="select" display="radio" label="Ignore the image masks?" help="Select Yes to set equal to zero all previously masked pixels and operate on the masked images as if no mask had been applied. Otherwise, the smallest image mask is applied after image math has been completed.">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
</inputs>
<outputs>
<expand macro="output_pipeline_param" />
</outputs>
<tests>
<test>
<param name="input_pipeline" value="common_image_math.cppipe"/>
<param name="operation" value="add"/>
<param name="raise_the_power_of_the_result_by" value="1.0"/>
<param name="multiply_the_result_by" value="1.0"/>
<param name="add_to_result" value="0.0"/>
<param name="set_values_less_than_0_equal_to_0" value="Yes"/>
<param name="set_values_greater_than_1_equal_to_1" value="Yes"/>
<param name="ignore_the_image_masks" value="No"/>
<param name="name_output_image" value="ImageAfterMath"/>
<param name="image_or_measurement_first" value="Image"/>
<param name="select_the_first_image" value="DNA"/>
<param name="multiply_the_first_image_by" value="1.0"/>
<param name="image_or_measurement_second" value="Image"/>
<param name="select_the_second_image" value="CellImage"/>
<param name="multiply_the_second_image_by" value="2.0"/>
<output name="output_pipeline" ftype="txt" file="image_math_1.cppipe" lines_diff="0"/>
</test>
<test>
<param name="input_pipeline" value="common_image_math.cppipe"/>
<param name="operation" value="subtract"/>
<param name="raise_the_power_of_the_result_by" value="1.0"/>
<param name="multiply_the_result_by" value="1.0"/>
<param name="add_to_result" value="0.0"/>
<param name="set_values_less_than_0_equal_to_0" value="Yes"/>
<param name="set_values_greater_than_1_equal_to_1" value="No"/>
<param name="ignore_the_image_masks" value="No"/>
<param name="name_output_image" value="ImageAfterMath"/>
<param name="image_or_measurement_first" value="Image"/>
<param name="select_the_first_image" value="DNA"/>
<param name="multiply_the_first_image_by" value="1.0"/>
<param name="image_or_measurement_second" value="Measurement"/>
<param name="multiply_the_second_image_by" value="5.0"/>
<param name="category_second" value="FileName"/>
<param name="measurement_second" value="DNA"/>
<output name="output_pipeline" ftype="txt" file="image_math_2.cppipe" lines_diff="0"/>
</test>
<test>
<param name="input_pipeline" value="common_image_math.cppipe"/>
<param name="operation" value="not"/>
<param name="name_output_image" value="ImageAfterMath"/>
<param name="select_the_first_image" value="DNA"/>
<param name="ignore_the_image_masks" value="No"/>
<output name="output_pipeline" ftype="txt" file="image_math_3.cppipe" lines_diff="0"/>
</test>
</tests>
<help>
<![CDATA[
.. class:: infomark
**What it does**
This module can perform addition, subtraction, multiplication, division, or averaging of two or more image intensities, as well as inversion, log transform, or scaling by a constant for individual image intensities.
Keep in mind that after the requested operations are carried out, the final image may have a substantially different range of pixel intensities than the original. CellProfiler assumes that the image is scaled from 0 – 1 for object identification and display purposes, so additional rescaling may be needed. Please see the RescaleIntensity module for more scaling options.
@COMMON_HELP@
]]>
</help>
<expand macro="citations"/>
</tool>