diff crop_image.xml @ 1:2852af87036d draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/crop_image/ commit 52a95105291e38f3410e347ed3b60d6acd6d5daa
author imgteam
date Fri, 09 Jan 2026 14:55:04 +0000
parents d52317f0ac21
children
line wrap: on
line diff
--- a/crop_image.xml	Fri Jun 06 12:47:06 2025 +0000
+++ b/crop_image.xml	Fri Jan 09 14:55:04 2026 +0000
@@ -3,16 +3,18 @@
     <macros>
         <import>creators.xml</import>
         <import>tests.xml</import>
-        <token name="@TOOL_VERSION@">0.4.1</token>
+        <token name="@TOOL_VERSION@">0.7.3</token>
         <token name="@VERSION_SUFFIX@">0</token>
     </macros>
     <creator>
-        <expand macro="creators/bmcv" />
+        <expand macro="creators/bmcv"/>
+        <expand macro="creators/kostrykin"/>
     </creator>
     <edam_operations>
         <edam_operation>operation_3443</edam_operation>
     </edam_operations>
     <xrefs>
+        <xref type="bio.tools">galaxy_image_analysis</xref>
         <xref type="bio.tools">giatools</xref>
     </xrefs>
     <requirements>
@@ -23,17 +25,34 @@
         mkdir ./output &&
         python '$__tool_directory__/crop_image.py'
 
-        '$image'
-        '$labelmap'
+        #if $image.extension == "zarr"
+            '$image.extra_files_path/$image.metadata.store_root'
+        #else
+            '$image'
+        #end if
+
+        #if $labelmap.extension == "zarr"
+            '$labelmap.extra_files_path/$labelmap.metadata.store_root'
+        #else
+            '$labelmap'
+        #end if
+
         '$skip_labels'
-        '${image.ext}'
+
+        #if str($image.ext).lower() == 'png'
+            'png'
+        #else
+            'tiff'
+        #end if
 
         ./output
 
     ]]></command>
     <inputs>
-        <param name="image" type="data" format="png,tiff" label="Image file" help="The image to be cropped."/>
-        <param name="labelmap" type="data" format="png,tiff" label="Label map" help="Each label identifies an individual region of interest, for which a cropped image is produced."/>
+        <param name="image" type="data" format="png,tiff,zarr" label="Image file"
+               help="The image to be cropped."/>
+        <param name="labelmap" type="data" format="png,tiff,zarr" label="Label map"
+               help="Each label identifies an individual region of interest, for which a cropped image is produced."/>
         <param name="skip_labels" type="text" label="Skip labels" value="0" optional="true" help="Comma-separated list of labels for which no cropped image shall be produced.">
             <validator type="regex">^\d+(,\d+)*$|^$</validator>
         </param>
@@ -46,7 +65,7 @@
     <tests>
         <!-- Test 2D TIFF -->
         <test>
-            <param name="image" value="yx_float32.tiff" ftype="tiff"/>
+            <param name="image" value="yx_float32.tiff"/>
             <param name="labelmap" value="yx_uint8.tiff"/>
             <output_collection name="output" type="list" count="2">
                 <expand macro="tests/intensity_image_diff/element" name="1" value="yx_float32_uint8_1.tiff" ftype="tiff"/>
@@ -55,7 +74,7 @@
         </test>
         <!-- Test with `skip_labels` -->
         <test>
-            <param name="image" value="yx_float32.tiff" ftype="tiff"/>
+            <param name="image" value="yx_float32.tiff"/>
             <param name="labelmap" value="yx_uint8.tiff"/>
             <param name="skip_labels" value="0,1"/>
             <output_collection name="output" type="list" count="1">
@@ -64,7 +83,7 @@
         </test>
         <!-- Test with empty `skip_labels` -->
         <test>
-            <param name="image" value="yx_float32.tiff" ftype="tiff"/>
+            <param name="image" value="yx_float32.tiff"/>
             <param name="labelmap" value="yx_uint8.tiff"/>
             <param name="skip_labels" value=""/>
             <output_collection name="output" type="list" count="3">
@@ -75,18 +94,55 @@
         </test>
         <!-- Test 3D TIFF (multi-frame) -->
         <test>
-            <param name="image" value="zyx_uint16.tiff" ftype="tiff"/>
+            <param name="image" value="zyx_uint16.tiff"/>
             <param name="labelmap" value="yxz_uint8.tiff"/>
             <output_collection name="output" type="list" count="1">
-                <expand macro="tests/intensity_image_diff/element" name="1" value="zyx_uint16_uint8_1.tiff" ftype="tiff"/>
+                <expand macro="tests/intensity_image_diff/element" name="1" value="zyx_uint16_uint8_1.tiff" ftype="tiff">
+                    <has_image_width width="5"/>
+                    <has_image_height height="3"/>
+                    <has_image_depth depth="6"/>
+                </expand>
+            </output_collection>
+        </test>
+        <!-- Test PNG (multi-channel) -->
+        <test>
+            <param name="image" value="yxc_uint8.png"/>
+            <param name="labelmap" value="yxc_uint8_mask.png"/>
+            <output_collection name="output" type="list" count="1">
+                <expand macro="tests/intensity_image_diff/element" name="2" value="yxc_uint8_uint8_2.png" ftype="png">
+                    <has_image_width width="10"/>
+                    <has_image_height height="12"/>
+                    <has_image_channels channels="3"/>
+                </expand>
             </output_collection>
         </test>
-        <!-- Test PNG -->
+        <!-- Test PNG+Zarr (multi-channel `image` PNG with single-channel `labelmap` Zarr) -->
+        <test>
+            <param name="image" value="yxc_uint8.png"/>
+            <param name="labelmap" value="yx_uint8_mask.zarr"/>
+            <output_collection name="output" type="list" count="1">
+                <expand macro="tests/intensity_image_diff/element" name="2" value="yxc_uint8_uint8_2.png" ftype="png">
+                    <has_image_width width="10"/>
+                    <has_image_height height="12"/>
+                    <has_image_channels channels="3"/>
+                </expand>
+            </output_collection>
+        </test>
+        <!-- Test Zarr+TIFF (multi-channel `image` Zarr with single-channel `labelmap` TIFF) -->
         <test>
-            <param name="image" value="yxc_uint8.png" ftype="png"/>
-            <param name="labelmap" value="yxc_uint8_mask.png"/>
+            <param name="image" value="cyx_uint8.zarr"/>
+            <param name="labelmap" value="yx_uint8_mask.tiff"/>
             <output_collection name="output" type="list" count="1">
-                <expand macro="tests/intensity_image_diff/element" name="2" value="yxc_uint8_uint8_2.png" ftype="png"/>
+                <!--
+                OME-Zarr requires a specific axes order. For this reason, it is not possible to generally write "any" image as an OME-Zarr.
+                This would require adapting the axes order, which is do-able, but changes the image. This might be unintended or unexpected
+                in many cases, which is why it is not happening automatically. We might change this behaviour somehow in the future.
+                -->
+                <expand macro="tests/intensity_image_diff/element" name="2" value="cyx_uint8_uint8.tiff" ftype="tiff">
+                    <has_image_width width="10"/>
+                    <has_image_height height="12"/>
+                    <has_image_channels channels="3"/>
+                </expand>
             </output_collection>
         </test>
     </tests>
@@ -94,9 +150,12 @@
 
         **Crops an image using one or more regions of interest.**
 
-        The image is cropped using a label map that identifies individual regions of interest. The image and the label map must be of equal size.
+        The image is cropped using a label map that identifies individual regions of interest. The image and the label map must be of
+        compatible size. The sizes are compatible if they are equal, or, if the label map can be broadcasted to the size of the image
+        (e.g., if the image is a multi-channel image and the label map is single-channel but has identical width and height).
 
-        This operation preserves the file type of the image, the brightness, and the range of values.
+        This operation preserves the brightness and the range of values of the input image. The file format is also preserved, unless
+        the input image is a Zarr, for which the output image file format is TIFF.
 
     </help>
     <citations>