comparison image_math.xml @ 0:33b2ca53a566 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/image_math commit b356d76025941b691c156f8ff931cd759d35b107
author imgteam
date Sat, 09 Mar 2024 22:04:19 +0000
parents
children f8b7770cbca5
comparison
equal deleted inserted replaced
-1:000000000000 0:33b2ca53a566
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 <token name="@TOOL_VERSION@">1.26.4</token>
5 <token name="@VERSION_SUFFIX@">0</token>
6 </macros>
7 <edam_operations>
8 <edam_operation>operation_3443</edam_operation>
9 </edam_operations>
10 <requirements>
11 <requirement type="package" version="1.26.4">numpy</requirement>
12 <requirement type="package" version="0.22.0">scikit-image</requirement>
13 </requirements>
14 <command><![CDATA[
15
16 ## Inputs
17
18 python '$__tool_directory__/image_math.py'
19 --expression='$expression'
20 #for $item in $inputs:
21 --input='$item.name:$item.image'
22 #end for
23
24 ## Outputs
25
26 --output='./result.tiff'
27
28 ]]>
29 </command>
30 <inputs>
31 <param argument="--expression" type="text" label="Expression" optional="false">
32 <validator type="regex">^[a-zA-Z0-9-_\*\+ \(\)/]+$</validator>
33 </param>
34 <repeat name="inputs" title="Input images" min="1">
35 <param name="image" type="data" format="png,tiff" label="Image" />
36 <param name="name" type="text" label="Variable for representation of the image within the expression" optional="false">
37 <validator type="regex">^[a-zA-Z_][a-zA-Z0-9_]*$</validator>
38 </param>
39 </repeat>
40 </inputs>
41 <outputs>
42 <data format="tiff" name="result" from_work_dir="result.tiff" />
43 </outputs>
44 <tests>
45 <!-- Multiplication with a scalar -->
46 <test>
47 <param name="expression" value="input1 * 2" />
48 <repeat name="inputs">
49 <param name="image" value="input1.tiff" />
50 <param name="name" value="input1" />
51 </repeat>
52 <output name="result" value="input1_times_2.tiff" ftype="tiff" compare="sim_size" delta="0" />
53 </test>
54 <!-- Unary negation operator -->
55 <test>
56 <param name="expression" value="-input1" />
57 <repeat name="inputs">
58 <param name="image" value="input1.tiff" />
59 <param name="name" value="input1" />
60 </repeat>
61 <output name="result" value="minus_input1.tiff" ftype="tiff" compare="sim_size" delta="0" />
62 </test>
63 <!-- Binary addition, neutral element, addition with scalar -->
64 <test>
65 <param name="expression" value="input1 + input2 + 1" />
66 <repeat name="inputs">
67 <param name="image" value="input1.tiff" />
68 <param name="name" value="input1" />
69 </repeat>
70 <repeat name="inputs">
71 <param name="image" value="minus_input1.tiff" />
72 <param name="name" value="input2" />
73 </repeat>
74 <output name="result" value="ones.tiff" ftype="tiff" compare="sim_size" delta="0" />
75 </test>
76 <!-- Parentheses -->
77 <test>
78 <param name="expression" value="(input1 + input2) / 2" />
79 <repeat name="inputs">
80 <param name="image" value="input1.tiff" />
81 <param name="name" value="input1" />
82 </repeat>
83 <repeat name="inputs">
84 <param name="image" value="ones.tiff" />
85 <param name="name" value="input2" />
86 </repeat>
87 <output name="result" value="half_of_input1_plus_one.tiff" ftype="tiff" compare="sim_size" delta="0" />
88 </test>
89 <!-- Abs -->
90 <test>
91 <param name="expression" value="abs(input)" />
92 <repeat name="inputs">
93 <param name="image" value="input1.tiff" />
94 <param name="name" value="input" />
95 </repeat>
96 <output name="result" value="input1_abs.tiff" ftype="tiff" compare="sim_size" delta="0" />
97 </test>
98 </tests>
99 <help>
100
101 This tool processes images according to pixel-wise arithmetic expressions.
102
103 The supported pixel-wise expressions are:
104
105 - Addition, subtraction, multiplication, and division (``+``, ``-``, ``*``, ``/``)
106 - Integer division (e.g., ``input // 2``)
107 - Power (e.g., ``input ** 2``)
108 - Negation (e.g., ``-input``)
109 - Absolute values (e.g., ``abs(input)``)
110 - Square root (e.g., ``sqrt(input)``)
111 - Combinations of the above (also using parentheses)
112
113 Examples:
114
115 - **Negate an image.**
116 Expression: ``-image``
117 where ``image`` is an arbitrary input image.
118
119 - **Mean of two images.**
120 Expression: ``(image1 + image2) / 2``
121 where ``image1`` and `image2` are two arbitrary input images.
122
123 - **Perform division avoiding division-by-zero.**
124 Expression: ``image1 / (abs(image2) + 1e-8)``
125 where ``image1`` and `image2` are two arbitrary input images.
126
127 </help>
128 <citations>
129 <citation type="doi">10.1038/s41586-020-2649-2</citation>
130 </citations>
131 </tool>