comparison imagej2_bunwarpj_align.xml @ 1:e9243cad1d67 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 2afb24f3c81d625312186750a714d702363012b5"
author imgteam
date Mon, 28 Sep 2020 16:40:20 +0000
parents ab54024c0a88
children 0a0d2dfd17e0
comparison
equal deleted inserted replaced
0:ab54024c0a88 1:e9243cad1d67
1 <?xml version='1.0' encoding='UTF-8'?>
2 <tool id="imagej2_bunwarpj_align" name="Align two images" version="@WRAPPER_VERSION@.0"> 1 <tool id="imagej2_bunwarpj_align" name="Align two images" version="@WRAPPER_VERSION@.0">
3 <description>with bUnwarpJ</description> 2 <description>with bUnwarpJ</description>
4 <macros> 3 <macros>
5 <import>imagej2_macros.xml</import> 4 <import>imagej2_macros.xml</import>
6 </macros> 5 </macros>
7 <expand macro="fiji_requirements" /> 6 <expand macro="fiji_requirements"/>
8 <command> 7 <command detect_errors="exit_code"><![CDATA[
9 <![CDATA[ 8 #import os
10 python $__tool_directory__/imagej2_bunwarpj_align.py 9 #set error_log = 'output_log.txt'
11 --target_image "$target_image" 10 touch '$error_log';
12 --target_image_format $target_image.ext 11
13 --source_image "$source_image" 12 ## ImageJ2 requires file extensions to be valid image data types.
14 --source_image_format $source_image.ext 13 #set source_out_suffix = '.' + str($source_out_datatype)
15 #if $align_with_mask_cond.align_with_mask == 'yes': 14 #set target_out_suffix = '.' + str($target_out_datatype)
16 --target_mask "$target_mask" 15 #set source_image_sans_ext = $os.path.splitext($os.path.basename($source_image.file_name))[0]
17 --target_mask_format $target_mask.ext 16 #set source_image_with_ext = '.'.join([$source_image_sans_ext, $source_image.ext])
18 --source_mask "$source_mask" 17 ln -s '$source_image.file_name' '$source_image_with_ext';
19 --source_mask_format $source_mask.ext 18 #set target_image_sans_ext = $os.path.splitext($os.path.basename($target_image.file_name))[0]
20 #end if 19 #set target_image_with_ext = '.'.join([$target_image_sans_ext, $target_image.ext])
21 --min_scale_def $min_scale_def 20 ln -s '$target_image.file_name' '$target_image_with_ext';
22 --max_scale_def $max_scale_def 21
23 --max_subsamp_fact $max_subsamp_fact 22 #set save_transformation = str($advanced_options_cond.advanced_options) == 'save_transformation'
24 --divergence_weight $divergence_weight 23 #set mono = str($advanced_options_cond.advanced_options) == 'mono'
25 --curl_weight $curl_weight 24 #set landmarks = str($advanced_options_cond.advanced_options) == 'landmarks'
26 --image_weight $image_weight 25 #set affine = str($advanced_options_cond.advanced_options) == 'affine'
27 --consistency_weight $consistency_weight 26
28 #if $advanced_options_cond.advanced_options == 'landmarks': 27 #if str($align_with_mask_cond.align_with_mask) == 'yes':
29 --landmarks_weight $advanced_options_cond.landmarks_weight 28 #set source_mask_sans_ext = $os.path.splitext($os.path.basename($align_with_mask_cond.source_mask.file_name))[0]
30 --landmarks_file "$advanced_options_cond.landmarks_file" 29 #set source_mask_with_ext = '.'.join([$source_mask_sans_ext, $source_mask.ext])
31 #else if $advanced_options_cond.advanced_options == 'affine': 30 #set source_mask = $source_mask_with_ext
32 --target_affine_file "$advanced_options_cond.target_affine_file" 31 ln -s '$align_with_mask_cond.source_mask.file_name' '$source_mask_with_ext';
33 --source_affine_file "$advanced_options_cond.source_affine_file" 32 #set target_mask_sans_ext = $os.path.splitext($os.path.basename($align_with_mask_cond.target_mask.file_name))[0]
34 #else if $advanced_options_cond.advanced_options == 'mono': 33 #set target_mask_with_ext = '.'.join([$target_mask_sans_ext, $target_mask.ext])
35 --mono "true" 34 #set target_mask = $target_mask_with_ext
36 #else if $advanced_options_cond.advanced_options == 'save_transformation': 35 ln -s '$align_with_mask_cond.target_mask.file_name' '$target_mask_with_ext';
37 --target_trans_out "$target_trans_out" 36 #else:
38 --source_trans_out "$source_trans_out" 37 #set source_mask = 'NULL'
39 #end if 38 #set target_mask = 'NULL'
40 --source_out "$source_out" 39 #end if
41 --source_out_datatype $source_out_datatype 40
42 #if $advanced_options_cond.advanced_options != 'mono': 41 #if not $mono:
43 --target_out "$target_out" 42 #set tmp_target_out = 'tmp_target_out' + $target_out_suffix
44 --target_out_datatype $target_out_datatype 43 touch '$tmp_target_out';
45 #end if 44
46 --jython_script $__tool_directory__/imagej2_bunwarpj_align_jython_script.py 45 ## bUnwarpJ automatically names the transformation files based
47 ]]> 46 ## on the names of the source and target image file names.
48 </command> 47 #set tmp_target_out_transf_name_sans_ext = $os.path.splitext($target_out.file_name)[0]
48 #set tmp_target_out_transf_name = $tmp_target_out_transf_name_sans_ext + '_transf.txt'
49 touch '$tmp_target_out_transf_name';
50 #end if
51 #set tmp_source_out = 'tmp_source_out' + $source_out_suffix
52 touch '$tmp_source_out';
53
54 ## bUnwarpJ automatically names the transformation files based
55 ## on the names of the source and target image file names.
56 #set tmp_source_out_transf_name_sans_ext = $os.path.splitext($source_out.file_name)[0]
57 #set tmp_source_out_transf_name = $tmp_source_out_transf_name_sans_ext + '_transf.txt'
58 touch '$tmp_source_out_transf_name';
59
60 ## Align the two images using bUnwarpJ.
61 bunwarpj -align
62 '$target_image_with_ext'
63 '$target_mask'
64 '$source_image_with_ext'
65 '$source_mask'
66 $min_scale_def
67 $max_scale_def
68 $max_subsamp_fact
69 $divergence_weight
70 $curl_weight
71 $image_weight
72 $consistency_weight
73 '$source_out'
74 #if not $mono:
75 '$target_out'
76 #end if
77 #if $landmarks:
78 '-landmarks'
79 $advanced_options_cond.landmarks_weight
80 '$landmarks_file'
81 #end if
82 #if $affine:
83 '-affine'
84 '$advanced_options_cond.target_affine_file'
85 '$advanced_options_cond.source_affine_file'
86 #end if
87 #if $mono:
88 '-mono'
89 #end if
90 #if $save_transformation:
91 '-save_transformation'
92 #end if
93 &>'$error_log';
94 #if $save_transformation:
95 mv '$tmp_source_out_transf_name' '$source_trans_out';
96 mv '$tmp_target_out_transf_name' '$target_trans_out';
97 #end if
98 if [[ $? -ne 0 ]]; then
99 cat '$error_log' >&2;
100 fi
101 ]]></command>
49 <inputs> 102 <inputs>
50 <param format="bmp,eps,gif,jpg,pcx,pgm,png,psd,tiff" name="target_image" type="data" label="Target image"/> 103 <expand macro="param_target_image"/>
51 <param format="bmp,eps,gif,jpg,pcx,pgm,png,psd,tiff" name="source_image" type="data" label="Source image"/> 104 <expand macro="param_source_image"/>
52 <conditional name="align_with_mask_cond"> 105 <conditional name="align_with_mask_cond">
53 <param name="align_with_mask" type="select" label="Align with masks?" help="Source and target mask can be any image format."> 106 <param name="align_with_mask" type="select" label="Align with masks?" help="Source and target mask can be any image format.">
54 <option value="no" selected="True">No</option> 107 <option value="no" selected="true">No</option>
55 <option value="yes">Yes</option> 108 <option value="yes">Yes</option>
56 </param> 109 </param>
57 <when value="no" /> 110 <when value="no"/>
58 <when value="yes"> 111 <when value="yes">
59 <param format="bmp,eps,gif,jpg,pcx,pgm,png,psd,tiff" name="target_mask" type="data" label="Target mask"/> 112 <expand macro="param_target_mask"/>
60 <param format="bmp,eps,gif,jpg,pcx,pgm,png,psd,tiff" name="source_mask" type="data" label="Source mask"/> 113 <expand macro="param_source_mask"/>
61 </when> 114 </when>
62 </conditional> 115 </conditional>
63 <param name="min_scale_def" type="select" label="Initial deformation"> 116 <param name="min_scale_def" type="select" label="Initial deformation">
64 <option value="0" selected="True">Very Coarse</option> 117 <option value="0" selected="true">Very Coarse</option>
65 <option value="1">Coarse</option> 118 <option value="1">Coarse</option>
66 <option value="2">Fine</option> 119 <option value="2">Fine</option>
67 <option value="3">Very Fine</option> 120 <option value="3">Very Fine</option>
68 </param> 121 </param>
69 <param name="max_scale_def" type="select" label="Final deformation"> 122 <param name="max_scale_def" type="select" label="Final deformation">
70 <option value="0">Very Coarse</option> 123 <option value="0">Very Coarse</option>
71 <option value="1">Coarse</option> 124 <option value="1">Coarse</option>
72 <option value="2" selected="True">Fine</option> 125 <option value="2" selected="true">Fine</option>
73 <option value="3">Very Fine</option> 126 <option value="3">Very Fine</option>
74 </param> 127 </param>
75 <param name="max_subsamp_fact" type="integer" value="0" min="0" label="Image sub-sample factor" help="Power of 2: [0, 1, 2 .. 7]"/> 128 <param name="max_subsamp_fact" type="integer" value="0" min="0" label="Image sub-sample factor" help="Power of 2: [0, 1, 2 .. 7]"/>
76 <param name="divergence_weight" type="float" value="0.0" label="Weight of the divergence term" help="Value is a floating point number"/> 129 <param name="divergence_weight" type="float" value="0.0" label="Weight of the divergence term" help="Value is a floating point number"/>
77 <param name="curl_weight" type="float" label="Weight of the curl term" value="0.0" help="Value is a floating point number"/> 130 <param name="curl_weight" type="float" label="Weight of the curl term" value="0.0" help="Value is a floating point number"/>
78 <param name="image_weight" type="float" label="Weight of the image term" value="1.0" help="Value is a floating point number"/> 131 <param name="image_weight" type="float" label="Weight of the image term" value="1.0" help="Value is a floating point number"/>
79 <param name="consistency_weight" type="float" label="Weight of the deformation consistency" value="10.0" help="Value is a floating point number"/> 132 <param name="consistency_weight" type="float" label="Weight of the deformation consistency" value="10.0" help="Value is a floating point number"/>
80 <param name="target_out_datatype" type="select" label="Save registered target image as format"> 133 <param name="target_out_datatype" type="select" label="Save registered target image as format">
81 <expand macro="image_datatypes" /> 134 <expand macro="image_datatypes"/>
82 </param> 135 </param>
83 <param name="source_out_datatype" type="select" label="Save registered source image as format"> 136 <param name="source_out_datatype" type="select" label="Save registered source image as format">
84 <expand macro="image_datatypes" /> 137 <expand macro="image_datatypes"/>
85 </param> 138 </param>
86 <!-- 139 <!--
87 The following additional options can be added to the advanced_options select 140 The following additional options can be added to the advanced_options select
88 list as soon as appropriate. Their use is supported in the imagej2_bunwarp_align.py 141 list as soon as appropriate. Their use is supported in the imagej2_bunwarp_align.py
89 wrapper. 142 wrapper.
103 results from the ImageJ GUI and in headless mode from the command line. 156 results from the ImageJ GUI and in headless mode from the command line.
104 <option value="mono">Unidirectional registration (source to target)</option> 157 <option value="mono">Unidirectional registration (source to target)</option>
105 --> 158 -->
106 <conditional name="advanced_options_cond"> 159 <conditional name="advanced_options_cond">
107 <param name="advanced_options" type="select" label="Advanced options" help="These are mutually exclusive for each execution"> 160 <param name="advanced_options" type="select" label="Advanced options" help="These are mutually exclusive for each execution">
108 <option value="none" selected="True">None</option> 161 <option value="none" selected="true">None</option>
109 <option value="save_transformation">Save calculated transformations</option> 162 <option value="save_transformation">Save calculated transformations</option>
110 </param> 163 </param>
111 <when value="none" /> 164 <when value="none"/>
112 <!-- 165 <!--
113 <when value="landmarks"> 166 <when value="landmarks">
114 <param name="landmarks_weight" type="float" label="Landmark weight" value="0.0" help="Value is a floating point number"/> 167 <param name="landmarks_weight" type="float" label="Landmark weight" value="0.0" help="Value is a floating point number"/>
115 <param format="txt" name="landmarks_file" type="data" label="Landmark file"/> 168 <param format="txt" name="landmarks_file" type="data" label="Landmark file"/>
116 </when> 169 </when>
122 --> 175 -->
123 <when value="save_transformation"/> 176 <when value="save_transformation"/>
124 </conditional> 177 </conditional>
125 </inputs> 178 </inputs>
126 <outputs> 179 <outputs>
127 <data name="source_out" format="png" label="${tool.name} on ${on_string}: Registered source image"> 180 <data name="source_out" format="png" label="${tool.name} (registered source) ${on_string}">
128 <actions> 181 <actions>
129 <action type="format"> 182 <action type="format">
130 <option type="from_param" name="source_out_datatype" /> 183 <option type="from_param" name="source_out_datatype"/>
131 </action> 184 </action>
132 </actions> 185 </actions>
133 </data> 186 </data>
134 <data name="target_out" format="png" label="${tool.name} on ${on_string}: Registered target image"> 187 <data name="target_out" format="png" label="${tool.name} (registered target) ${on_string}">
135 <filter>advanced_options_cond['advanced_options'] != "mono"</filter> 188 <filter>advanced_options_cond['advanced_options'] != "mono"</filter>
136 <actions> 189 <actions>
137 <action type="format"> 190 <action type="format">
138 <option type="from_param" name="target_out_datatype" /> 191 <option type="from_param" name="target_out_datatype"/>
139 </action> 192 </action>
140 </actions> 193 </actions>
141 </data> 194 </data>
142 <data format="txt" name="source_trans_out" label="${tool.name} on ${on_string}: Direct source transformation matrix"> 195 <data format="txt" name="source_trans_out" label="${tool.name} (source transf matrix) ${on_string}">
143 <filter>advanced_options_cond['advanced_options'] == "save_transformation"</filter> 196 <filter>advanced_options_cond['advanced_options'] == "save_transformation"</filter>
144 </data> 197 </data>
145 <data format="txt" name="target_trans_out" label="${tool.name} on ${on_string}: Inverse target transformation matrix"> 198 <data format="txt" name="target_trans_out" label="${tool.name} (target transf matrix) ${on_string}">
146 <filter>advanced_options_cond['advanced_options'] == "save_transformation"</filter> 199 <filter>advanced_options_cond['advanced_options'] == "save_transformation"</filter>
147 </data> 200 </data>
148 </outputs> 201 </outputs>
149 <tests> 202 <tests>
150 <test> 203 <test>
151 <!-- Align two images without landmarks or mask and not saving transformation matrices --> 204 <!-- Align two images without landmarks or mask and not saving transformation matrices -->
152 <param name="target_image" value="dotblot.jpg" /> 205 <expand macro="test_target_source_images"/>
153 <param name="source_image" value="blobs.gif" /> 206 <param name="max_subsamp_fact" value="1"/>
154 <param name="min_scale_def" value="0" /> 207 <output name="source_out" file="registered_source1.png" compare="sim_size"/>
155 <param name="max_scale_def" value="2" /> 208 <output name="target_out" file="registered_target1.png" compare="sim_size"/>
156 <param name="max_subsamp_fact" value="1" />
157 <param name="divergence_weight" value="0.0" />
158 <param name="curl_weight" value="0.0" />
159 <param name="image_weight" value="1.0" />
160 <param name="consistency_weight" value="10.0" />
161 <param name="target_out_datatype" value="png" />
162 <param name="source_out_datatype" value="png" />
163 <output name="source_out" file="registered_source1.png" compare="sim_size" />
164 <output name="target_out" file="registered_target1.png" compare="sim_size" />
165 </test> 209 </test>
166 <test> 210 <test>
167 <!-- Align two images without landmarks or mask, but saving transformation matrices --> 211 <!-- Align two images without landmarks or mask, but saving transformation matrices -->
168 <param name="target_image" value="dotblot.jpg" /> 212 <expand macro="test_target_source_images"/>
169 <param name="source_image" value="blobs.gif" /> 213 <param name="max_subsamp_fact" value="1"/>
170 <param name="min_scale_def" value="0" /> 214 <param name="advanced_options" value="save_transformation"/>
171 <param name="max_scale_def" value="2" /> 215 <output name="source_out" file="registered_source1.png" compare="sim_size"/>
172 <param name="max_subsamp_fact" value="1" /> 216 <output name="target_out" file="registered_target1.png" compare="sim_size"/>
173 <param name="divergence_weight" value="0.0" /> 217 <output name="source_trans_out" file="source_elastic_transformation_out.txt" compare="contains"/>
174 <param name="curl_weight" value="0.0" /> 218 <output name="target_trans_out" file="target_elastic_transformation_out.txt" compare="contains"/>
175 <param name="image_weight" value="1.0" />
176 <param name="consistency_weight" value="10.0" />
177 <param name="target_out_datatype" value="png" />
178 <param name="source_out_datatype" value="png" />
179 <param name="advanced_options" value="save_transformation" />
180 <output name="source_out" file="registered_source1.png" compare="sim_size" />
181 <output name="target_out" file="registered_target1.png" compare="sim_size" />
182 <output name="source_trans_out" file="source_elastic_transformation.txt" />
183 <output name="target_trans_out" file="target_elastic_transformation.txt" />
184 </test> 219 </test>
185 <test> 220 <test>
186 <!-- Align two images without landmarks but with mask, not saving transformation matrices --> 221 <!-- Align two images without landmarks but with mask, not saving transformation matrices -->
187 <param name="target_image" value="dotblot.jpg" /> 222 <expand macro="test_target_source_images"/>
188 <param name="source_image" value="blobs.gif" /> 223 <param name="align_with_mask" value="yes"/>
189 <param name="target_mask" value="mask_white.png" /> 224 <param name="target_mask" value="mask_white.png"/>
190 <param name="source_mask" value="mask_ramp.gif" /> 225 <param name="source_mask" value="mask_ramp.gif"/>
191 <param name="min_scale_def" value="0" /> 226 <param name="max_subsamp_fact" value="1"/>
192 <param name="max_scale_def" value="2" /> 227 <output name="source_out" file="registered_source2.png" compare="sim_size"/>
193 <param name="max_subsamp_fact" value="1" /> 228 <output name="target_out" file="registered_target2.png" compare="sim_size"/>
194 <param name="divergence_weight" value="0.0" />
195 <param name="curl_weight" value="0.0" />
196 <param name="image_weight" value="1.0" />
197 <param name="consistency_weight" value="10.0" />
198 <param name="target_out_datatype" value="png" />
199 <param name="source_out_datatype" value="png" />
200 <output name="source_out" file="registered_source2.png" compare="sim_size" />
201 <output name="target_out" file="registered_target2.png" compare="sim_size" />
202 </test> 229 </test>
203 </tests> 230 </tests>
204 <help> 231 <help>
205 **What it does** 232 **What it does**
206 233
241 the registerd source and target images: the direct transformation matrix of A and the inverse transformation 268 the registerd source and target images: the direct transformation matrix of A and the inverse transformation
242 matrix of B. 269 matrix of B.
243 ]]> 270 ]]>
244 271
245 </help> 272 </help>
246 <expand macro="bunwarpj_citations" /> 273 <expand macro="bunwarpj_citations"/>
247 </tool> 274 </tool>