Mercurial > repos > imgteam > crop_image
view crop_image.xml @ 1:457514bb6750 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:54:49 +0000 |
| parents | f8bfa85cac4c |
| children |
line wrap: on
line source
<tool id="ip_crop_image" name="Crop image" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05"> <description>with giatools</description> <macros> <import>creators.xml</import> <import>tests.xml</import> <token name="@TOOL_VERSION@">0.7.3</token> <token name="@VERSION_SUFFIX@">0</token> </macros> <creator> <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> <requirement type="package" version="@TOOL_VERSION@">giatools</requirement> </requirements> <command detect_errors="aggressive"><![CDATA[ mkdir ./output && python '$__tool_directory__/crop_image.py' #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' #if str($image.ext).lower() == 'png' 'png' #else 'tiff' #end if ./output ]]></command> <inputs> <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> </inputs> <outputs> <collection type="list" name="output" label="Crop ${on_string}" format_source="image"> <discover_datasets directory="output" pattern="__name_and_ext__"/> </collection> </outputs> <tests> <!-- Test 2D TIFF --> <test> <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"/> <expand macro="tests/intensity_image_diff/element" name="2" value="yx_float32_uint8_2.tiff" ftype="tiff"/> </output_collection> </test> <!-- Test with `skip_labels` --> <test> <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"> <expand macro="tests/intensity_image_diff/element" name="2" value="yx_float32_uint8_2.tiff" ftype="tiff"/> </output_collection> </test> <!-- Test with empty `skip_labels` --> <test> <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"> <expand macro="tests/intensity_image_diff/element" name="0" value="yx_float32_uint8_0.tiff" ftype="tiff"/> <expand macro="tests/intensity_image_diff/element" name="1" value="yx_float32_uint8_1.tiff" ftype="tiff"/> <expand macro="tests/intensity_image_diff/element" name="2" value="yx_float32_uint8_2.tiff" ftype="tiff"/> </output_collection> </test> <!-- Test 3D TIFF (multi-frame) --> <test> <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"> <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+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="cyx_uint8.zarr"/> <param name="labelmap" value="yx_uint8_mask.tiff"/> <output_collection name="output" type="list" count="1"> <!-- 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> <help> **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 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 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> <citation type="doi">10.1016/j.jbiotec.2017.07.019</citation> </citations> </tool>
