Mercurial > repos > imgteam > 2d_feature_extraction
comparison 2d_feature_extraction.xml @ 5:5530132d500e draft
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/2d_feature_extraction/ commit bb2d58ed37d8eb09583b86e3cdd9f5d1b56c42a0
| author | imgteam |
|---|---|
| date | Sun, 04 Jan 2026 20:56:17 +0000 |
| parents | a4bc9dfde846 |
| children | 8e3a52b74876 |
comparison
equal
deleted
inserted
replaced
| 4:a4bc9dfde846 | 5:5530132d500e |
|---|---|
| 1 <tool id="ip_2d_feature_extraction" name="Extract image features" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> | 1 <tool id="ip_2d_feature_extraction" name="Extract image features" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> |
| 2 <description>with scikit-image</description> | 2 <description>with scikit-image</description> |
| 3 <macros> | 3 <macros> |
| 4 <import>creators.xml</import> | 4 <import>creators.xml</import> |
| 5 <token name="@TOOL_VERSION@">0.18.1</token> | 5 <import>validators.xml</import> |
| 6 <token name="@TOOL_VERSION@">0.25.2</token> | |
| 6 <token name="@VERSION_SUFFIX@">0</token> | 7 <token name="@VERSION_SUFFIX@">0</token> |
| 8 <xml name="features"> | |
| 9 <param name="features" type="select" label="Available features" multiple="true" display="checkboxes" | |
| 10 help="*) Features marked with an asterisk are only available for 2-D images (not for 3-D images)."> | |
| 11 <option value="label" selected="true">Label from the label map</option> | |
| 12 <yield/> | |
| 13 <option value="area">Area</option> | |
| 14 <option value="area_convex">Convex area</option> | |
| 15 <option value="area_filled">Filled area</option> | |
| 16 <option value="axis_major_length">Major axis length</option> | |
| 17 <option value="axis_minor_length">Minor axis length</option> | |
| 18 <option value="bbox">Bounding box</option> | |
| 19 <option value="centroid">Centroid</option> | |
| 20 <option value="eccentricity">Eccentricity*</option> | |
| 21 <option value="equivalent_diameter_area">Equivalent diameter</option> | |
| 22 <option value="euler_number">Euler number</option> | |
| 23 <option value="extent">Extent</option> | |
| 24 <option value="inertia_tensor_eigvals">Inertia tensor eigenvalues</option> | |
| 25 <option value="moments">Moments</option> | |
| 26 <option value="moments_hu">Moments Hu*</option> | |
| 27 <option value="orientation">Orientation*</option> | |
| 28 <option value="perimeter">Perimeter</option> | |
| 29 <option value="solidity">Solidity</option> | |
| 30 </param> | |
| 31 </xml> | |
| 32 <xml name="zarr-isolated-feature-test" tokens="feature"> | |
| 33 <test> | |
| 34 <param name="labels" value="input/input13.zarr"/> | |
| 35 <conditional name="setup"> | |
| 36 <param name="mode" value="with-intensities"/> | |
| 37 <param name="intensities" value="input/input1_uint8.tiff"/> | |
| 38 <param name="features" value="@FEATURE@"/> | |
| 39 </conditional> | |
| 40 <output name="output" ftype="tabular" value="output/input13-@FEATURE@.tsv"/> | |
| 41 </test> | |
| 42 </xml> | |
| 7 </macros> | 43 </macros> |
| 8 <creator> | 44 <creator> |
| 9 <expand macro="creators/bmcv"/> | 45 <expand macro="creators/bmcv"/> |
| 46 <expand macro="creators/kostrykin"/> | |
| 10 </creator> | 47 </creator> |
| 11 <edam_operations> | 48 <edam_operations> |
| 12 <edam_operation>operation_3443</edam_operation> | 49 <edam_operation>operation_3443</edam_operation> |
| 13 </edam_operations> | 50 </edam_operations> |
| 14 <xrefs> | 51 <xrefs> |
| 15 <xref type="bio.tools">scikit-image</xref> | 52 <xref type="bio.tools">scikit-image</xref> |
| 53 <xref type="bio.tools">giatools</xref> | |
| 54 <xref type="bio.tools">galaxy_image_analysis</xref> | |
| 16 <xref type="biii">scikit-image</xref> | 55 <xref type="biii">scikit-image</xref> |
| 17 </xrefs> | 56 </xrefs> |
| 18 <requirements> | 57 <requirements> |
| 19 <requirement type="package" version="@TOOL_VERSION@">scikit-image</requirement> | 58 <requirement type="package" version="@TOOL_VERSION@">scikit-image</requirement> |
| 20 <requirement type="package" version="2.2.2">pandas</requirement> | 59 <requirement type="package" version="2.2.2">pandas</requirement> |
| 21 <requirement type="package" version="1.23.3">numpy</requirement> | 60 <requirement type="package" version="0.7.3">giatools</requirement> |
| 22 <requirement type="package" version="2020.10.1">tifffile</requirement> | 61 <requirement type="package" version="0.12.2">ome-zarr</requirement> |
| 23 <requirement type="package" version="0.1">giatools</requirement> | |
| 24 </requirements> | 62 </requirements> |
| 25 <command detect_errors="aggressive"> | 63 <required_files> |
| 26 <![CDATA[ | 64 <include type="literal" path="2d_feature_extraction.py"/> |
| 27 python '$__tool_directory__/2d_feature_extraction.py' | 65 </required_files> |
| 28 #if $feature_options['features'] == 'all' | 66 <command detect_errors="aggressive"><![CDATA[ |
| 29 --all | 67 |
| 30 #else if $feature_options['features'] == 'select' | 68 python '$__tool_directory__/2d_feature_extraction.py' |
| 31 ${' '.join(str( $feature_options['selected_features'] ).split(','))} | 69 |
| 32 #end if | 70 #if $labels.extension == "zarr" |
| 33 #if $use_raw_option['use_raw'] == 'raw_image' | 71 --labels '$labels.extra_files_path/$labels.metadata.store_root' |
| 34 --raw '$input_raw' | 72 #else |
| 35 #end if | 73 --labels '$labels' |
| 36 '$input_label' '$output' | 74 #end if |
| 37 ]]> | 75 |
| 38 </command> | 76 #if $setup.mode == "with-intensities" |
| 77 #if $setup.intensities.extension == "zarr" | |
| 78 --intensities '$setup.intensities.extra_files_path/$setup.intensities.metadata.store_root' | |
| 79 #else | |
| 80 --intensities '$setup.intensities' | |
| 81 #end if | |
| 82 #end if | |
| 83 | |
| 84 --output '$output' | |
| 85 --params '$params' | |
| 86 --verbose | |
| 87 | |
| 88 ]]></command> | |
| 89 <configfiles> | |
| 90 <configfile name="params"><![CDATA[ | |
| 91 { | |
| 92 "features": [ | |
| 93 ${ ', '.join('"%s"' % t.strip() for t in str( $setup['features'] ).split(',')) } | |
| 94 ] | |
| 95 } | |
| 96 ]]></configfile> | |
| 97 </configfiles> | |
| 39 <inputs> | 98 <inputs> |
| 40 <param name="input_label" type="data" format="tiff,png" label="Label map"/> | 99 <param name="labels" type="data" format="tiff,zarr,png" label="Label map"> |
| 41 <conditional name="use_raw_option"> | 100 <expand macro="validators/is_single_channel"/> |
| 42 <param label="Use the intensity image to compute additional features" name="use_raw" type="select"> | 101 <expand macro="validators/is_single_frame"/> |
| 43 <option selected="True" value="no_original">No intensity image</option> | 102 </param> |
| 44 <option value="raw_image">Use intensity image</option> | 103 <conditional name="setup"> |
| 104 <param label="Features to compute" name="mode" type="select"> | |
| 105 <option value="without-intensities" selected="true">Only use the label map for feature extraction (no intensity-based features)</option> | |
| 106 <option value="with-intensities">Use the intensity image to compute additional features</option> | |
| 45 </param> | 107 </param> |
| 46 <when value="no_original"/> | 108 <when value="without-intensities"> |
| 47 <when value="raw_image"> | 109 <expand macro="features"/> |
| 48 <param name="input_raw" type="data" format="tiff,png" label="Intensity image"/> | |
| 49 </when> | 110 </when> |
| 50 </conditional> | 111 <when value="with-intensities"> |
| 51 <conditional name="feature_options"> | 112 <param name="intensities" type="data" format="tiff,zarr,png,jpg" label="Intensity image"> |
| 52 <param label="Select features to compute" name="features" type="select"> | 113 <expand macro="validators/is_single_channel"/> |
| 53 <option selected="True" value="all">All features</option> | 114 <expand macro="validators/is_single_frame"/> |
| 54 <option value="select">Select features</option> | |
| 55 </param> | |
| 56 <when value="all"> </when> | |
| 57 <when value="select"> | |
| 58 <param name="selected_features" type="select" label="Available features" multiple="true" display="checkboxes"> | |
| 59 <option value="--label">Label from the label map</option> | |
| 60 <option value="--patches">Patches (requires original image)</option> | |
| 61 <option value="--max_intensity">Max Intensity (requires original image)</option> | |
| 62 <option value="--mean_intensity">Mean Intensity (requires original image)</option> | |
| 63 <option value="--min_intensity">Minimum Intensity (requires original image)</option> | |
| 64 <option value="--moments_hu">Moments Hu</option> | |
| 65 <option value="--centroid">Centroid</option> | |
| 66 <option value="--bbox">Bounding box</option> | |
| 67 <option value="--area">Area</option> | |
| 68 <option value="--filled_area">Filled area</option> | |
| 69 <option value="--convex_area">Convex area</option> | |
| 70 <option value="--perimeter">Perimeter</option> | |
| 71 <option value="--extent">Extent</option> | |
| 72 <option value="--eccentricity">Eccentricity</option> | |
| 73 <option value="--equivalent_diameter">Equivalent diameter</option> | |
| 74 <option value="--euler_number">Euler number</option> | |
| 75 <option value="--inertia_tensor_eigvals">Inertia tensor eigenvalues</option> | |
| 76 <option value="--major_axis_length">Major axis length</option> | |
| 77 <option value="--minor_axis_length">Minor axis length</option> | |
| 78 <option value="--orientation">Orientation</option> | |
| 79 <option value="--solidity">Solidity</option> | |
| 80 <option value="--moments">Moments</option> | |
| 81 <option value="--convexity">Convexity</option> | |
| 82 </param> | 115 </param> |
| 116 <expand macro="features"> | |
| 117 <option value="max_intensity">Maximum intensity</option> | |
| 118 <option value="mean_intensity">Mean intensity</option> | |
| 119 <option value="min_intensity">Minimum intensity</option> | |
| 120 </expand> | |
| 83 </when> | 121 </when> |
| 84 </conditional> | 122 </conditional> |
| 85 </inputs> | 123 </inputs> |
| 86 <outputs> | 124 <outputs> |
| 87 <data format="tabular" name="output"/> | 125 <data format="tabular" name="output"/> |
| 88 </outputs> | 126 </outputs> |
| 89 <tests> | 127 <tests> |
| 128 <!-- Single-channel 2-D --> | |
| 90 <test> | 129 <test> |
| 91 <param name="input_label" value="input.tiff" ftype="tiff"/> | 130 <param name="labels" value="input/input12.png"/> |
| 92 <conditional name="feature_options"> | 131 <conditional name="setup"> |
| 93 <param name="features" value="select"/> | 132 <param name="mode" value="without-intensities"/> |
| 94 <param name="selected_features" value="--label,--area"/> | 133 <param name="features" value="label,area,area_convex,solidity"/> |
| 95 </conditional> | 134 </conditional> |
| 96 <output name="output" ftype="tabular" value="out.tsv"/> | 135 <output name="output" ftype="tabular" value="output/input12.tsv"/> |
| 136 </test> | |
| 137 <test> | |
| 138 <param name="labels" value="input/input11.tiff"/> | |
| 139 <conditional name="setup"> | |
| 140 <param name="mode" value="with-intensities"/> | |
| 141 <param name="intensities" value="input/input1_uint8.tiff"/> | |
| 142 <param name="features" value="area,mean_intensity,perimeter"/> | |
| 143 </conditional> | |
| 144 <output name="output" ftype="tabular" value="output/input11.tsv"/> | |
| 145 </test> | |
| 146 <!-- Single-channel 2-D Zarr (isolated features, verify that Dask arrays are converted to NumPy arrays whenever necessary) --> | |
| 147 <expand macro="zarr-isolated-feature-test" feature="area"/> | |
| 148 <expand macro="zarr-isolated-feature-test" feature="area_convex"/> | |
| 149 <expand macro="zarr-isolated-feature-test" feature="area_filled"/> | |
| 150 <expand macro="zarr-isolated-feature-test" feature="axis_major_length"/> | |
| 151 <expand macro="zarr-isolated-feature-test" feature="axis_minor_length"/> | |
| 152 <expand macro="zarr-isolated-feature-test" feature="bbox"/> | |
| 153 <expand macro="zarr-isolated-feature-test" feature="centroid"/> | |
| 154 <expand macro="zarr-isolated-feature-test" feature="eccentricity"/> | |
| 155 <expand macro="zarr-isolated-feature-test" feature="equivalent_diameter_area"/> | |
| 156 <expand macro="zarr-isolated-feature-test" feature="euler_number"/> | |
| 157 <expand macro="zarr-isolated-feature-test" feature="extent"/> | |
| 158 <expand macro="zarr-isolated-feature-test" feature="inertia_tensor_eigvals"/> | |
| 159 <expand macro="zarr-isolated-feature-test" feature="moments"/> | |
| 160 <expand macro="zarr-isolated-feature-test" feature="moments_hu"/> | |
| 161 <expand macro="zarr-isolated-feature-test" feature="orientation"/> | |
| 162 <expand macro="zarr-isolated-feature-test" feature="perimeter"/> | |
| 163 <expand macro="zarr-isolated-feature-test" feature="solidity"/> | |
| 164 <expand macro="zarr-isolated-feature-test" feature="max_intensity"/> | |
| 165 <expand macro="zarr-isolated-feature-test" feature="mean_intensity"/> | |
| 166 <expand macro="zarr-isolated-feature-test" feature="min_intensity"/> | |
| 167 <!-- Single-channel 3-D, test all features are supported in 3-D --> | |
| 168 <test> | |
| 169 <param name="labels" value="input/input9.zarr"/> | |
| 170 <conditional name="setup"> | |
| 171 <param name="mode" value="with-intensities"/> | |
| 172 <param name="intensities" value="input/input8_zyx.zarr"/> | |
| 173 <param name="features" value="area,area_convex,area_filled,axis_major_length,axis_minor_length,bbox,centroid,eccentricity,equivalent_diameter_area,euler_number,extent,inertia_tensor_eigvals,moments,moments_hu,orientation,perimeter,solidity,max_intensity,mean_intensity,min_intensity"/> | |
| 174 </conditional> | |
| 175 <output name="output" ftype="tabular" value="output/input9.tsv"/> | |
| 176 <assert_stdout> | |
| 177 <has_line line='Skip feature that is not available for 3-D images: "eccentricity"'/> | |
| 178 <has_line line='Skip feature that is not available for 3-D images: "moments_hu"'/> | |
| 179 <has_line line='Skip feature that is not available for 3-D images: "orientation"'/> | |
| 180 </assert_stdout> | |
| 181 </test> | |
| 182 <!-- Multi-channel (forbidden) --> | |
| 183 <test expect_failure="true"> | |
| 184 <param name="labels" value="input/input12.png"/> | |
| 185 <conditional name="setup"> | |
| 186 <param name="mode" value="with-intensities"/> | |
| 187 <param name="intensities" value="input/input3_uint16.tiff"/> | |
| 188 <param name="features" value="label"/> | |
| 189 </conditional> | |
| 190 <assert_stderr> | |
| 191 <!-- Rejected by validator --> | |
| 192 <has_n_lines n="0"/> | |
| 193 </assert_stderr> | |
| 194 <assert_stdout> | |
| 195 <!-- Rejected by validator --> | |
| 196 <has_n_lines n="0"/> | |
| 197 </assert_stdout> | |
| 198 </test> | |
| 199 <test expect_failure="true"> | |
| 200 <param name="labels" value="input/input10.zarr"/> | |
| 201 <conditional name="setup"> | |
| 202 <param name="mode" value="without-intensities"/> | |
| 203 <param name="features" value="label"/> | |
| 204 </conditional> | |
| 205 <assert_stderr> | |
| 206 <!-- Rejected by py-script --> | |
| 207 <has_text text="This tool is not applicable to images with CYX axes."/> | |
| 208 </assert_stderr> | |
| 97 </test> | 209 </test> |
| 98 </tests> | 210 </tests> |
| 99 <help> | 211 <help> |
| 100 | 212 |
| 101 **Computes features of a label map.** | 213 **Computes features of a label map.** |
| 102 | 214 |
| 103 The computed features are computed based solely on the properties of the labels in the label map, | 215 The computed features are computed based solely on the properties of the objects in the label map, or, optionally, by also taking the intensities from a corresponding intensity image into account. Labels with value 0 are ignored. |
| 104 or, optionally, by also taking the intensities from a corresponding intensity image into account. | 216 |
| 105 | 217 Both images must be 2-D or 3-D single-channel images. |
| 106 The label map must be a 2-D or 3-D single-channel image. | 218 |
| 219 Supported Features | |
| 220 ================== | |
| 221 | |
| 222 **Area:** Area of the region i.e. number of pixels of the region scaled by pixel-area. | |
| 223 | |
| 224 **Convex area:** Area of the convex hull image, which is the smallest convex polygon that encloses the region. | |
| 225 | |
| 226 **Filled area:** Area of the region with all the holes filled in. | |
| 227 | |
| 228 **Major axis length:** The length of the major axis of the ellipse that has the same normalized second central moments as the region. | |
| 229 | |
| 230 **Minor axis length:** The length of the minor axis of the ellipse that has the same normalized second central moments as the region. | |
| 231 | |
| 232 **Bounding box:** Bounding box `(min_row, min_col, max_row, max_col)`. Pixels belonging to the bounding box are in the half-open interval `[min_row; max_row)` and `[min_col; max_col)`. | |
| 233 | |
| 234 **Centroid:** Centroid coordinate tuple `(row, col)`. | |
| 235 | |
| 236 **Eccentricity:** Eccentricity of the ellipse that has the same second-moments as the region. The eccentricity is the ratio of the focal distance (distance between focal points) over the major axis length. The value is in the interval [0, 1). When it is 0, the ellipse becomes a circle. | |
| 237 | |
| 238 **Equivalent diameter:** The diameter of a circle with the same area as the region. | |
| 239 | |
| 240 **Euler number:** Euler characteristic of the set of non-zero pixels. Computed as number of connected components subtracted by number of holes (input.ndim connectivity). In 3-D, number of connected components plus number of holes subtracted by number of tunnels. | |
| 241 | |
| 242 **Extent:** Ratio of pixels in the region to pixels in the total bounding box. Computed as `area / (rows * cols)`. | |
| 243 | |
| 244 **Inertia tensor eigenvalues:** The eigenvalues of the inertia tensor in decreasing order. | |
| 245 | |
| 246 **Moments:** Spatial moments up to 3rd order: `m_ij = sum{ array(row, col) * row^i * col^j }` where the sum is over the row, col coordinates of the region. | |
| 247 | |
| 248 **Moments Hu:** Hu moments (translation, scale and rotation invariant). | |
| 249 | |
| 250 **Orientation:** Angle between the vertical axis (rows) and the major axis of the ellipse that has the same second moments as the region, ranging from `-pi/2` to `pi/2` counter-clockwise. | |
| 251 | |
| 252 **Perimeter:** Perimeter of object which approximates the contour as a line through the centers of border pixels using a 4-connectivity. Generalizes to the surface of an object in 3-D, which uses a different approximation. | |
| 253 | |
| 254 **Solidity:** Ratio of pixels in the region to pixels of the convex hull image. | |
| 107 | 255 |
| 108 </help> | 256 </help> |
| 109 <citations> | 257 <citations> |
| 110 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> | 258 <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> |
| 111 </citations> | 259 </citations> |
