Mercurial > repos > imgteam > binary2labelimage
comparison binary2label.xml @ 6:364e235bf378 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/binary2labelimage/ commit f5a4de7535e433e3b0e96e0694e481b6643a54f8
| author | imgteam |
|---|---|
| date | Sat, 03 Jan 2026 14:14:28 +0000 |
| parents | 7f8102bdbfa1 |
| children |
comparison
equal
deleted
inserted
replaced
| 5:7f8102bdbfa1 | 6:364e235bf378 |
|---|---|
| 1 <tool id="ip_binary_to_labelimage" name="Convert binary image to label map" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@"> | 1 <tool id="ip_binary_to_labelimage" name="Convert binary image to label map" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@"> |
| 2 <description></description> | 2 <description>with giatools</description> |
| 3 <macros> | 3 <macros> |
| 4 <import>creators.xml</import> | 4 <import>creators.xml</import> |
| 5 <token name="@TOOL_VERSION@">0.6</token> | 5 <import>tests.xml</import> |
| 6 <import>validators.xml</import> | |
| 7 <token name="@TOOL_VERSION@">0.7.3</token> | |
| 6 <token name="@VERSION_SUFFIX@">0</token> | 8 <token name="@VERSION_SUFFIX@">0</token> |
| 9 <xml name="input"> | |
| 10 <!-- JPEG is not allowed because it is a lossy compression that has no strictly constant labels --> | |
| 11 <param name="input" type="data" format="tiff,zarr,png" label="Binary image"> | |
| 12 <expand macro="validators/is_binary"/> | |
| 13 <yield/> | |
| 14 </param> | |
| 15 </xml> | |
| 7 </macros> | 16 </macros> |
| 8 <creator> | 17 <creator> |
| 9 <expand macro="creators/bmcv"/> | 18 <expand macro="creators/bmcv"/> |
| 19 <expand macro="creators/kostrykin"/> | |
| 10 </creator> | 20 </creator> |
| 11 <edam_operations> | 21 <edam_operations> |
| 12 <edam_operation>operation_3443</edam_operation> | 22 <edam_operation>operation_3443</edam_operation> |
| 13 </edam_operations> | 23 </edam_operations> |
| 14 <xrefs> | 24 <xrefs> |
| 15 <xref type="bio.tools">galaxy_image_analysis</xref> | 25 <xref type="bio.tools">galaxy_image_analysis</xref> |
| 26 <xref type="bio.tools">giatools</xref> | |
| 16 </xrefs> | 27 </xrefs> |
| 17 <requirements> | 28 <requirements> |
| 18 <requirement type="package" version="0.4.0">giatools</requirement> | 29 <requirement type="package" version="@TOOL_VERSION@">giatools</requirement> |
| 19 <requirement type="package" version="1.12.0">scipy</requirement> | 30 <requirement type="package" version="1.16.3">scipy</requirement> |
| 31 <requirement type="package" version="0.12.2">ome-zarr</requirement> | |
| 20 </requirements> | 32 </requirements> |
| 21 <command detect_errors="aggressive"> | 33 <required_files> |
| 22 <![CDATA[ | 34 <include type="literal" path="binary2label.py"/> |
| 23 #if str($mode.mode_selector) == 'cca': | 35 </required_files> |
| 24 python '$__tool_directory__/binary2label.py' '$input' '$output' | 36 <command detect_errors="aggressive"><![CDATA[ |
| 25 #elif str($mode.mode_selector) == 'watershed': | 37 |
| 26 python '$__tool_directory__/2d_split_binaryimage_by_watershed.py' '$input' '$output' $min_distance | 38 python '$__tool_directory__/binary2label.py' |
| 39 | |
| 40 #if $setup.input.extension == "zarr" | |
| 41 --input '$setup.input.extra_files_path/$setup.input.metadata.store_root' | |
| 42 #else | |
| 43 --input '$setup.input' | |
| 27 #end if | 44 #end if |
| 28 ]]> | 45 |
| 29 </command> | 46 --output 'output.tiff' |
| 47 --params '$params' | |
| 48 --verbose | |
| 49 | |
| 50 ]]></command> | |
| 51 <configfiles> | |
| 52 <configfile name="params"><![CDATA[ | |
| 53 { | |
| 54 | |
| 55 #if str($setup.method) == "watershed" | |
| 56 "min_distance": $setup.min_distance, | |
| 57 #end if | |
| 58 | |
| 59 "method": "$setup.method" | |
| 60 | |
| 61 } | |
| 62 ]]></configfile> | |
| 63 </configfiles> | |
| 30 <inputs> | 64 <inputs> |
| 31 <param name="input" type="data" format="tiff,png,jpg,bmp" label="Binary image"/> | 65 <conditional name="setup"> |
| 32 <conditional name="mode"> | 66 <param name="method" type="select" label="Mode" |
| 33 <param name="mode_selector" type="select" label="Mode"> | 67 help="Connected component analysis assigns unique labels to objects that are separated by 1 pixel or more. Watershed transform can also separate partially overlapping objects, but is only applicable to 2-D image data."> |
| 34 <option value="cca" selected="true">Connected component analysis</option> | 68 <option value="cca" selected="true">Connected component analysis</option> |
| 35 <option value="watershed">Watershed transform</option> | 69 <option value="watershed">Watershed transform</option> |
| 36 </param> | 70 </param> |
| 37 <when value="cca"> | 71 <when value="cca"> |
| 72 <expand macro="input"/> | |
| 38 </when> | 73 </when> |
| 39 <when value="watershed"> | 74 <when value="watershed"> |
| 40 <param name="min_distance" type="integer" min="0" value="5" label="Minimum distance between two objects" /> | 75 <expand macro="input"> |
| 76 <expand macro="validators/is_2d"/> | |
| 77 </expand> | |
| 78 <param name="min_distance" type="integer" min="0" value="5" label="Minimum distance between two objects"/> | |
| 41 </when> | 79 </when> |
| 42 </conditional> | 80 </conditional> |
| 43 </inputs> | 81 </inputs> |
| 44 <outputs> | 82 <outputs> |
| 45 <data format="tiff" name="output"/> | 83 <data format="tiff" name="output" from_work_dir="output.tiff"/> |
| 46 </outputs> | 84 </outputs> |
| 47 <tests> | 85 <tests> |
| 86 <!-- Tests for 2-D --> | |
| 48 <test> | 87 <test> |
| 49 <param name="input" value="galaxyIcon_noText.tiff" /> | 88 <conditional name="setup"> |
| 50 <conditional name="mode"> | 89 <param name="method" value="cca"/> |
| 51 <param name="mode_selector" value="cca" /> | 90 <param name="input" value="input/input11.tiff"/> |
| 52 </conditional> | 91 </conditional> |
| 53 <output name="output" value="label.tiff" ftype="tiff" compare="image_diff"/> | 92 <expand macro="tests/label_image_diff" name="output" value="output/input11-cca.tiff" ftype="tiff"/> |
| 93 <assert_stdout> | |
| 94 <has_line line="[input] Input image axes: YX"/> | |
| 95 <has_line line="[input] Input image shape: (265, 329)"/> | |
| 96 <has_line line="[input] Input image dtype: uint16"/> | |
| 97 <has_line line="[output] Output image axes: YX"/> | |
| 98 <has_line line="[output] Output image shape: (265, 329)"/> | |
| 99 <has_line line="[output] Output image dtype: uint16"/> | |
| 100 </assert_stdout> | |
| 54 </test> | 101 </test> |
| 55 <test> | 102 <test> |
| 56 <param name="input" value="in.tiff"/> | 103 <conditional name="setup"> |
| 57 <conditional name="mode"> | 104 <param name="method" value="watershed"/> |
| 58 <param name="mode_selector" value="watershed" /> | 105 <param name="input" value="input/input11.tiff"/> |
| 59 <param name="min_distance" value="10" /> | 106 <param name="min_distance" value="10"/> |
| 60 </conditional> | 107 </conditional> |
| 61 <output name="output" value="out.tiff" ftype="tiff" compare="image_diff"/> | 108 <expand macro="tests/label_image_diff" name="output" value="output/input11-watershed.tiff" ftype="tiff"/> |
| 62 </test> | 109 <assert_stdout> |
| 110 <has_line line="[input] Input image axes: YX"/> | |
| 111 <has_line line="[input] Input image shape: (265, 329)"/> | |
| 112 <has_line line="[input] Input image dtype: uint16"/> | |
| 113 <has_line line="[output] Output image axes: YX"/> | |
| 114 <has_line line="[output] Output image shape: (265, 329)"/> | |
| 115 <has_line line="[output] Output image dtype: uint16"/> | |
| 116 </assert_stdout> | |
| 117 </test> | |
| 118 <!-- Tests for 3-D --> | |
| 63 <test> | 119 <test> |
| 64 <param name="input" value="uint8_z12_x11_y10.tiff"/> | 120 <conditional name="setup"> |
| 65 <conditional name="mode"> | 121 <param name="method" value="cca"/> |
| 66 <param name="mode_selector" value="cca" /> | 122 <param name="input" value="input/input9.zarr"/> |
| 67 </conditional> | 123 </conditional> |
| 68 <output name="output" value="uint8_z12_x11_y10-output.tiff" ftype="tiff" compare="image_diff"> | 124 <!-- `label_image_diff` currently does not support 3-D images: https://github.com/galaxyproject/galaxy/pull/21455 --> |
| 69 <assert_contents> | 125 <expand macro="tests/intensity_image_diff" name="output" value="output/input9-cca.tiff" ftype="tiff"/> |
| 70 <has_image_width width="11"/> | 126 <assert_stdout> |
| 71 <has_image_height height="10"/> | 127 <has_line line="[input] Input image axes: ZYX"/> |
| 72 <has_image_depth depth="12"/> | 128 <has_line line="[input] Input image shape: (2, 100, 100)"/> |
| 73 </assert_contents> | 129 <has_line line="[input] Input image dtype: bool"/> |
| 74 </output> | 130 <has_line line="[input] Input image resolution=(1.0, 1.0), unit='um', z_spacing=1.0"/> |
| 131 <has_line line="[output] Output image axes: ZYX"/> | |
| 132 <has_line line="[output] Output image shape: (2, 100, 100)"/> | |
| 133 <has_line line="[output] Output image dtype: uint16"/> | |
| 134 <has_line line="[output] Output image resolution=(1.0, 1.0), unit='um', z_spacing=1.0"/> | |
| 135 </assert_stdout> | |
| 136 </test> | |
| 137 <test expect_failure="true"> | |
| 138 <conditional name="setup"> | |
| 139 <param name="method" value="watershed"/> | |
| 140 <param name="input" value="input/input9.zarr"/> | |
| 141 </conditional> | |
| 142 <assert_stderr> | |
| 143 <!-- Rejected by py-script --> | |
| 144 <has_text text='Method "watershed" is not applicable to 3-D images.'/> | |
| 145 </assert_stderr> | |
| 146 <assert_stdout> | |
| 147 <has_line line="[input] Input image axes: ZYX"/> | |
| 148 <has_line line="[input] Input image shape: (2, 100, 100)"/> | |
| 149 <has_line line="[input] Input image dtype: bool"/> | |
| 150 <has_line line="[input] Input image resolution=(1.0, 1.0), unit='um', z_spacing=1.0"/> | |
| 151 </assert_stdout> | |
| 152 </test> | |
| 153 <test expect_failure="true"> | |
| 154 <conditional name="setup"> | |
| 155 <param name="method" value="watershed"/> | |
| 156 <param name="input" value="input/input9.tiff"/> | |
| 157 </conditional> | |
| 158 <assert_stderr> | |
| 159 <!-- Rejected by validator --> | |
| 160 <has_n_lines n="0"/> | |
| 161 </assert_stderr> | |
| 162 <assert_stdout> | |
| 163 <!-- Rejected by validator --> | |
| 164 <has_n_lines n="0"/> | |
| 165 </assert_stdout> | |
| 166 </test> | |
| 167 <!-- Tests for multi-channel images --> | |
| 168 <test expect_failure="true"> | |
| 169 <conditional name="setup"> | |
| 170 <param name="method" value="cca"/> | |
| 171 <param name="input" value="input/input10.zarr"/> | |
| 172 </conditional> | |
| 173 <assert_stderr> | |
| 174 <!-- Rejected by py-script --> | |
| 175 <has_text text='Multi-channel images are forbidden to avoid confusion with multi-channel labels (e.g., RGB labels).'/> | |
| 176 </assert_stderr> | |
| 177 <assert_stdout> | |
| 178 <has_line line="[input] Input image axes: CYX"/> | |
| 179 <has_line line="[input] Input image shape: (2, 64, 64)"/> | |
| 180 <has_line line="[input] Input image dtype: uint8"/> | |
| 181 <has_line line="[input] Input image resolution=(1.0, 1.0)"/> | |
| 182 </assert_stdout> | |
| 183 </test> | |
| 184 <test expect_failure="true"> | |
| 185 <conditional name="setup"> | |
| 186 <param name="method" value="cca"/> | |
| 187 <param name="input" value="input/rgb.png"/> | |
| 188 </conditional> | |
| 189 <assert_stderr> | |
| 190 <!-- Rejected by validator --> | |
| 191 <has_n_lines n="0"/> | |
| 192 </assert_stderr> | |
| 193 <assert_stdout> | |
| 194 <!-- Rejected by validator --> | |
| 195 <has_n_lines n="0"/> | |
| 196 </assert_stdout> | |
| 75 </test> | 197 </test> |
| 76 </tests> | 198 </tests> |
| 77 <help> | 199 <help> |
| 78 This tool assigns each object a unique label. | 200 |
| 79 | 201 **Converts a binary image to a label map.** |
| 80 Individual objects are determined using connected component analysis, or distance transform and watershed. | 202 |
| 203 This tool assigns each object a unique label. | |
| 204 | |
| 205 Individual objects are determined using connected component analysis, or distance transform and watershed. | |
| 206 | |
| 81 </help> | 207 </help> |
| 82 <citations> | 208 <citations> |
| 83 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> | 209 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> |
| 84 </citations> | 210 </citations> |
| 85 </tool> | 211 </tool> |
