comparison image_math.xml @ 0:e0beec1d4bf1 draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/image_math commit cddd14dcfe71bb7a7e77aaf09bd2c5535e1dd643
author imgteam
date Fri, 06 Mar 2026 17:31:48 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e0beec1d4bf1
1 <tool id="image_math" name="Process images using arithmetic expressions" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0">
2 <description>with NumPy</description>
3 <macros>
4 <import>creators.xml</import>
5 <import>tests.xml</import>
6 <token name="@TOOL_VERSION@">2.3.5</token>
7 <token name="@VERSION_SUFFIX@">0</token>
8 </macros>
9 <creator>
10 <expand macro="creators/bmcv"/>
11 <expand macro="creators/kostrykin"/>
12 </creator>
13 <edam_operations>
14 <edam_operation>operation_3443</edam_operation>
15 </edam_operations>
16 <requirements>
17 <requirement type="package" version="@TOOL_VERSION@">numpy</requirement>
18 <requirement type="package" version="0.7.3">giatools</requirement>
19 </requirements>
20 <required_files>
21 <include type="glob" path="*.py"/>
22 </required_files>
23 <command><![CDATA[
24
25 ## Inputs
26
27 python '$__tool_directory__/image_math.py'
28 --expression='$expression'
29 #if '$dtype' != '':
30 --dtype='$dtype'
31 #end if
32 #for $item in $inputs:
33 --input='$item.name:$item.image'
34 #end for
35
36 ## Outputs
37
38 --output='./result.tiff'
39
40 ]]>
41 </command>
42 <inputs>
43 <param argument="--expression" type="text" label="Expression" optional="false">
44 <validator type="regex">^[a-zA-Z0-9-_\*\+ \(\)/\.]+$</validator>
45 </param>
46 <param name="dtype" type="select" label="Data type of the produced TIFF image">
47 <option value="" selected="true">Determine automatically</option>
48 <option value="float16">16-bit floating point</option>
49 <option value="float32">32-bit floating point</option>
50 <option value="float64">64-bit floating point</option>
51 <option value="int8">8-bit signed integer</option>
52 <option value="int16">16-bit signed integer</option>
53 <option value="int32">32-bit signed integer</option>
54 <option value="uint8">8-bit unsigned integer</option>
55 <option value="uint16">16-bit unsigned integer</option>
56 <option value="uint32">32-bit unsigned integer</option>
57 </param>
58 <repeat name="inputs" title="Input images" min="1">
59 <param name="image" type="data" format="png,tiff" label="Image" />
60 <param name="name" type="text" label="Variable for representation of the image within the expression" optional="false">
61 <validator type="regex">^[a-zA-Z_][a-zA-Z0-9_]*$</validator>
62 </param>
63 </repeat>
64 </inputs>
65 <outputs>
66 <data format="tiff" name="result" from_work_dir="result.tiff" />
67 </outputs>
68 <tests>
69 <!-- Multiplication with a scalar -->
70 <test>
71 <!--
72 GIA204: :relax_indent:
73 python '$__tool_directory__/image_math.py'
74 ––expression='input1 * 2'
75 ––dtype=''
76 ––input='input1:input1.tiff'
77 ––output='./result.tiff'
78 -->
79 <param name="expression" value="input1 * 2" />
80 <repeat name="inputs">
81 <param name="image" value="input1.tiff" />
82 <param name="name" value="input1" />
83 </repeat>
84 <expand macro="tests/intensity_image_diff" name="result" value="input1_times_2.tiff" ftype="tiff"/>
85 </test>
86 <!-- Unary negation operator -->
87 <test>
88 <!--
89 GIA204: :relax_indent:
90 python '$__tool_directory__/image_math.py'
91 ––expression='-input1'
92 ––dtype=''
93 ––input='input1:input1.tiff'
94 ––output='./result.tiff'
95 -->
96 <param name="expression" value="-input1" />
97 <repeat name="inputs">
98 <param name="image" value="input1.tiff" />
99 <param name="name" value="input1" />
100 </repeat>
101 <expand macro="tests/intensity_image_diff" name="result" value="minus_input1.tiff" ftype="tiff"/>
102 </test>
103 <!-- Binary addition, neutral element, addition with scalar -->
104 <test>
105 <!--
106 GIA204: :relax_indent:
107 python '$__tool_directory__/image_math.py'
108 ––expression='input1 + input2 + 1'
109 ––dtype=''
110 ––input='input1:input1.tiff'
111 ––input='input2:minus_input1.tiff'
112 ––output='./result.tiff'
113 -->
114 <param name="expression" value="input1 + input2 + 1" />
115 <repeat name="inputs">
116 <param name="image" value="input1.tiff" />
117 <param name="name" value="input1" />
118 </repeat>
119 <repeat name="inputs">
120 <param name="image" value="minus_input1.tiff" />
121 <param name="name" value="input2" />
122 </repeat>
123 <expand macro="tests/intensity_image_diff" name="result" value="ones.tiff" ftype="tiff"/>
124 </test>
125 <!-- Parentheses -->
126 <test>
127 <!--
128 GIA204: :relax_indent:
129 python '$__tool_directory__/image_math.py'
130 ––expression='(input1 + input2) / 2'
131 ––dtype=''
132 ––input='input1:input1.tiff'
133 ––input='input2:ones.tiff'
134 ––output='./result.tiff'
135 -->
136 <param name="expression" value="(input1 + input2) / 2" />
137 <repeat name="inputs">
138 <param name="image" value="input1.tiff" />
139 <param name="name" value="input1" />
140 </repeat>
141 <repeat name="inputs">
142 <param name="image" value="ones.tiff" />
143 <param name="name" value="input2" />
144 </repeat>
145 <expand macro="tests/intensity_image_diff" name="result" value="half_of_input1_plus_one.tiff" ftype="tiff"/>
146 </test>
147 <!-- Abs -->
148 <test>
149 <!--
150 GIA204: :relax_indent:
151 python '$__tool_directory__/image_math.py'
152 ––expression='abs(input)'
153 ––dtype=''
154 ––input='input:input1.tiff'
155 ––output='./result.tiff'
156 -->
157 <param name="expression" value="abs(input)" />
158 <repeat name="inputs">
159 <param name="image" value="input1.tiff" />
160 <param name="name" value="input" />
161 </repeat>
162 <expand macro="tests/intensity_image_diff" name="result" value="input1_abs.tiff" ftype="tiff"/>
163 </test>
164 <!-- Decimal, conversion to explicit `dtype` -->
165 <test>
166 <!--
167 GIA204: :relax_indent:
168 python '$__tool_directory__/image_math.py'
169 ––expression='input1 / 0.5'
170 ––dtype='uint8'
171 ––input='input1:input1.tiff'
172 ––output='./result.tiff'
173 -->
174 <param name="expression" value="input1 / 0.5" />
175 <param name="dtype" value="uint8" />
176 <repeat name="inputs">
177 <param name="image" value="input1.tiff" />
178 <param name="name" value="input1" />
179 </repeat>
180 <expand macro="tests/intensity_image_diff" name="result" value="input1_times_2_uint8.tiff" ftype="tiff"/>
181 </test>
182 </tests>
183 <help>
184
185 **Processes images according to pixel-wise arithmetic expressions.**
186
187 The supported pixel-wise expressions are:
188
189 - Addition, subtraction, multiplication, and division (``+``, ``-``, ``*``, ``/``)
190 - Integer division (e.g., ``input // 2``)
191 - Power (e.g., ``input ** 2``)
192 - Negation (e.g., ``-input``)
193 - Absolute values (e.g., ``abs(input)``)
194 - Square root (e.g., ``sqrt(input)``)
195 - Combinations of the above (also using parentheses)
196
197 Examples:
198
199 - **Negate an image.**
200 Expression: ``-image``
201 where ``image`` is an arbitrary input image.
202
203 - **Mean of two images.**
204 Expression: ``(image1 + image2) / 2``
205 where ``image1`` and `image2` are two arbitrary input images.
206
207 - **Perform division avoiding division-by-zero.**
208 Expression: ``image1 / (abs(image2) + 1e-8)``
209 where ``image1`` and `image2` are two arbitrary input images.
210
211 </help>
212 <citations>
213 <citation type="doi">10.1038/s41586-020-2649-2</citation>
214 </citations>
215 </tool>