comparison render.xml @ 0:7d6be2b7e1e2 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/libcarna/ commit 20db59ffe2a97f25d82ba02e451bf73f93ef84ee
author imgteam
date Mon, 05 Jan 2026 20:10:28 +0000
parents
children 22618ff03b3d
comparison
equal deleted inserted replaced
-1:000000000000 0:7d6be2b7e1e2
1 <tool id="libcarna_render" name="Render 3-D image data" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05">
2 <description>with LibCarna</description>
3 <macros>
4 <import>creators.xml</import>
5 <import>validators.xml</import>
6 <import>colormaps.xml</import>
7 <token name="@TOOL_VERSION@">0.2.0</token>
8 <token name="@VERSION_SUFFIX@">0</token>
9 <xml name="params/intensity" tokens="name,label">
10 <section name="@NAME@" title="@LABEL@" expanded="true">
11 <param name="type" type="select" label="@LABEL@"
12 help="For relative intensity values, 0 is the minimum intensity of the image, and 1 is the maximum intensity.">
13 <option value="absolute" selected="true">Absolute intensity value</option>
14 <option value="relative">Relative intensity value</option>
15 </param>
16 <param name="value" type="float" label="Intensity value"/>
17 </section>
18 </xml>
19 <xml name="params/builtin_cmap">
20 <conditional name="ramp">
21 <param name="enabled" type="select" label="Ramp function"
22 help="Use a piecewise linear ramp function for the alpha channel of the colormap.">
23 <option value="false" selected="true">Disabled</option>
24 <option value="true">Enabled</option>
25 </param>
26 <when value="true">
27 <expand macro="params/intensity" name="start" label="Ramp start"/>
28 <expand macro="params/intensity" name="end" label="Ramp end"/>
29 </when>
30 <when value="false"/>
31 </conditional>
32 </xml>
33 <xml name="when/builtin_cmap" tokens="value">
34 <when value="@VALUE@">
35 <expand macro="params/builtin_cmap"/>
36 </when>
37 </xml>
38 <xml name="test/params">
39 <!-- CI tests use software rendering which requires very low sample rates -->
40 <param name="sample_rate_override" value="5"/>
41 <param name="width" value="200"/>
42 <param name="height" value="110"/>
43 </xml>
44 <xml name="test/assert_stdout">
45 <assert_stdout>
46 <has_line_matching expression="^EGL Vendor: .+"/>
47 <yield/>
48 </assert_stdout>
49 </xml>
50 </macros>
51 <creator>
52 <expand macro="creators/bmcv"/>
53 <expand macro="creators/kostrykin"/>
54 </creator>
55 <edam_operations>
56 <edam_operation>operation_3443</edam_operation>
57 </edam_operations>
58 <xrefs>
59 <xref type="bio.tools">galaxy_image_analysis</xref>
60 <xref type="bio.tools">giatools</xref>
61 </xrefs>
62 <requirements>
63 <!--
64 We employ here a custom Docker image until https://github.com/bioconda/bioconda-containers/issues/87 gets a better solution.
65
66 The Docker image is an extension of the BioContainer for the following packages:
67
68 <requirement type="package" version="@TOOL_VERSION@">libcarna-python</requirement>
69 <requirement type="package" version="1.26.4">numpy</requirement>
70 <requirement type="package" version="4.3.2">ffmpeg</requirement>
71 <requirement type="package" version="0.7.3">giatools</requirement>
72 <requirement type="package" version="0.12.2">ome-zarr</requirement>
73 <requirement type="package" version="2.3.3">pandas</requirement>
74
75 See https://github.com/kostrykin/LibCarna-Python-Docker for details of the image.
76 -->
77 <container type="docker">docker.io/kostrykin/libcarna-python:@TOOL_VERSION@-0</container>
78 </requirements>
79 <required_files>
80 <include type="literal" path="clip_image.py"/>
81 <exclude type="literal" path="README.md"/>
82 </required_files>
83 <command detect_errors="aggressive"><![CDATA[
84
85 python '$__tool_directory__/render.py'
86
87 #if $intensities.extension == "zarr"
88 --intensities '$intensities.extra_files_path/$intensities.metadata.store_root'
89 #else
90 --intensities '$intensities'
91 #end if
92
93 #if str($colormap.name) == "custom"
94 --colormap '$colormap.custom'
95 #end if
96
97 #if str($mask.enabled) == "true":
98 #if $mask.image.extension == "zarr"
99 --mask '$mask.image.extra_files_path/$mask.image.metadata.store_root'
100 #else
101 --mask '$mask.image'
102 #end if
103 #end if
104
105 --html '$html'
106 --params '$params'
107 --verbose
108
109 ]]></command>
110 <configfiles>
111 <configfile name="params"><![CDATA[
112 {
113
114 #if str($sample_rate_override) != ""
115 #set $sample_rate = int($sample_rate_override)
116 #end if
117
118 "sample_rate": $sample_rate,
119 "axes": "$axes",
120 "width": $width,
121 "height": $height,
122 "mode": "$mode.name",
123
124 "mode_kwargs": {
125 #if str($mode.name) == "dvr"
126 "translucency": $mode.translucency,
127 "diffuse": $mode.diffuse
128 #end if
129 },
130
131 "colormap": "$colormap.name",
132
133 #if str($colormap.name) != "custom"
134 "ramp": {
135 #if str($colormap.ramp.enabled) == "true"
136 "start_type": "$colormap.ramp.start.type",
137 "start_value": $colormap.ramp.start.value,
138 "end_type": "$colormap.ramp.end.type",
139 "end_value": $colormap.ramp.end.value
140 #end if
141 },
142 #end if
143
144 "camera": {
145 "distance": $camera.distance,
146 "kwargs": {
147 "fov": $camera.fov,
148 "z_near": $camera.z_near,
149 "z_far": $camera.z_far
150 }
151 },
152 "video": {
153 "frames": $video.frames,
154 "fps": $video.fps
155 },
156
157 "mask": $mask.enabled,
158 "mask_renderer_kwargs": {
159 #if str($mask.enabled) == "true"
160 "color": "$mask.color"
161 #end if
162 }
163
164 }
165 ]]></configfile>
166 </configfiles>
167 <inputs>
168 <param name="intensities" type="data" format="tiff,zarr" label="Input image (3-D)">
169 <expand macro="validators/is_single_channel"/>
170 <expand macro="validators/is_single_frame"/>
171 <expand macro="validators/is_3d"/>
172 </param>
173 <param name="axes" type="select" label="Coordinate system">
174 <option value="XZY" selected="true">Point Z to the top</option>
175 <option value="XYZ">Point Y to the top</option>
176 </param>
177 <param name="sample_rate" type="integer" min="100" value="800" label="Sample rate"
178 help="Samples per pixel for volume rendering (ray marching)."/>
179 <param name="sample_rate_override" type="hidden" value="0"/><!-- For testing purposes -->
180 <param name="width" type="integer" min="50" max="1024" value="800" label="Width of the video (in pixels)"/>
181 <param name="height" type="integer" min="50" max="1024" value="450" label="Height of the video (in pixels)"/>
182 <conditional name="mode">
183 <param name="name" type="select" label="Rendering mode">
184 <option value="mip" selected="true">Maximum Intensity Projection (MIP)</option>
185 <option value="dvr">Direct Volume Rendering (DVR)</option>
186 </param>
187 <when value="mip"/>
188 <when value="dvr">
189 <param name="translucency" type="float" min="0" value="1" label="Translucency"/>
190 <param name="diffuse" type="float" min="0" max="1" value="0.8" label="Directional light"
191 help="Balances the amount of ambient vs directional light. The light is fully ambient for 0 and fully directional for 1."/>
192 </when>
193 </conditional>
194 <conditional name="colormap">
195 <param name="name" type="select" label="Color map">
196 <option value="custom">Custom</option>
197 <expand macro="option/builtin_cmap_list"/>
198 </param>
199 <when value="custom">
200 <param name="custom" type="data" format="tabular" label="Custom colormap">
201 <validator type="dataset_metadata_in_range" metadata_name="columns" min="3" message="Colormap needs to have at least 3 columns."/>
202 </param>
203 </when>
204 <expand macro="when/builtin_cmap_list"/>
205 </conditional>
206 <section name="camera" title="Camera parameters" expanded="true">
207 <param name="fov" type="float" min="10" max="170" value="90" label="Field of view (in degrees)"/>
208 <param name="distance" type="float" min="1" value="200" label="Distance"
209 help="Distance between the camera and the center of the 3-D image."/>
210 <param name="z_near" type="float" min="0.01" value="10" label="Near clipping plane"
211 help="Position of the near clipping plane along the z-axis."/>
212 <param name="z_far" type="float" min="100" value="1000" label="Far clipping plane"
213 help="Position of the far clipping plane along the z-axis."/>
214 </section>
215 <conditional name="mask">
216 <param name="enabled" type="select" label="Render mask overlay">
217 <option value="false" selected="true">No overlay</option>
218 <option value="true">Render mask overlay</option>
219 </param>
220 <when value="false"/>
221 <when value="true">
222 <param name="image" type="data" format="tiff,zarr" label="Mask overlay (3-D)">
223 <expand macro="validators/is_single_channel"/>
224 <expand macro="validators/is_single_frame"/>
225 <expand macro="validators/is_3d"/>
226 </param>
227 <param name="color" type="color" value="#00ff00" label="Color of the overlay"/>
228 </when>
229 </conditional>
230 <section name="video" title="Video parameters" expanded="false">
231 <param name="frames" type="integer" min="10" value="200" label="Frames"/>
232 <param name="fps" type="integer" min="1" max="60" value="25" label="Frames per second"/>
233 </section>
234 </inputs>
235 <outputs>
236 <data format="html" name="html"/>
237 </outputs>
238 <tests>
239 <!-- Test with MIP -->
240 <test>
241 <param name="intensities" value="input/float32_10z_32y_40x.tiff"/>
242 <section name="camera">
243 <param name="distance" value="50"/>
244 </section>
245 <output name="html" ftype="html" value="output/float32_10z_32y_40x-mip.html" compare="sim_size" delta="1000"/>
246 <expand macro="test/params"/>
247 <expand macro="test/assert_stdout"/>
248 </test>
249 <!-- Test with DVR, ramp colormap, and mask -->
250 <test>
251 <param name="intensities" value="input/float32_10z_32y_40x.tiff"/>
252 <conditional name="mode">
253 <param name="name" value="dvr"/>
254 <param name="translucency" value="0"/>
255 </conditional>
256 <conditional name="colormap">
257 <param name="name" value="BrBG"/>
258 <conditional name="ramp">
259 <param name="enabled" value="true"/>
260 <section name="start">
261 <param name="type" value="relative"/>
262 <param name="value" value="0.33"/>
263 </section>
264 <section name="end">
265 <param name="type" value="relative"/>
266 <param name="value" value="0.37"/>
267 </section>
268 </conditional>
269 </conditional>
270 <section name="camera">
271 <param name="distance" value="50"/>
272 </section>
273 <conditional name="mask">
274 <param name="enabled" value="true"/>
275 <param name="image" value="input/uint8_10z_32y_40x.tiff"/>
276 </conditional>
277 <output name="html" ftype="html" value="output/float32_10z_32y_40x-dvr-mask.html" compare="sim_size" delta="1000"/>
278 <expand macro="test/params"/>
279 <expand macro="test/assert_stdout"/>
280 </test>
281 <!-- Test with custom colormap -->
282 <test>
283 <param name="intensities" value="input/float32_10z_32y_40x.tiff"/>
284 <param name="axes" value="XYZ"/>
285 <conditional name="colormap">
286 <param name="name" value="custom"/>
287 <param name="custom" value="input/colormap.tsv"/>
288 </conditional>
289 <section name="camera">
290 <param name="distance" value="50"/>
291 </section>
292 <output name="html" ftype="html" value="output/float32_10z_32y_40x-colormap.html" compare="sim_size" delta="1000"/>
293 <expand macro="test/params"/>
294 <expand macro="test/assert_stdout"/>
295 </test>
296 <!-- Test with Zarr and missing `z_spacing` metadata -->
297 <test>
298 <param name="intensities" value="input/float32_5z_16y_20x-no_z_spacing.zarr"/>
299 <section name="camera">
300 <param name="distance" value="50"/>
301 </section>
302 <output name="html" ftype="html" value="output/float32_5z_16y_20x.html" compare="sim_size" delta="1000"/>
303 <expand macro="test/params"/>
304 <expand macro="test/assert_stdout"/>
305 </test>
306 </tests>
307 <help>
308
309 **Renders videos for visualization of 3-D image data.**
310
311 The image data is rotated to facilitate grasping visual information from different angles.
312
313 LibCarna employs a volume rendering technique called *ray marching* and permits different visualization modes, including *maximum intensity projections* (MIP) and *direct volume rendering* (DVR). In addition, the renderings can be augmented with binary or label masks (e.g., segmentation overlays).
314
315 .. image:: dvr.gif
316 :width: 438px
317 :scale: 100%
318
319 An overview of the available colormaps is available at `matplotlib.org`_.
320
321 .. _matplotlib.org: https://matplotlib.org/stable/users/explain/colors/colormaps.html
322
323 When using custom colormaps, a tabular file with at least 3 columns must be used (`intensity`, `type`, `color`). Each pair of consecutive rows defines a linear segment of the colormap. The `intensity` values can be given either as absolute intensity values, or as relative values where 0 and 1 correspond to the minimum and maximum intensities of the image data, respectively. The `type` column indicates whether the corresponding `intensity` value is `absolute` or `relative`. The `color` must be given in hexadecimal notation with a ``#`` prefix and must be either 6 or 8 digits long (6 for RGB and 8 for RGBA). An example is given below.
324
325 +-----------+------------+----------+
326 | color | intensity | type |
327 +-----------+------------+----------+
328 | #ff00007f | 0 | absolute |
329 +-----------+------------+----------+
330 | #ffff00ff | 0.5 | absolute |
331 +-----------+------------+----------+
332 | #00ffffff | 1.0 | relative |
333 +-----------+------------+----------+
334
335 </help>
336 <citations>
337 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation>
338 </citations>
339 </tool>