view split_image.xml @ 1:4b7940d0c051 draft default tip

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/split_image/ commit 6152e9fafda27f76c1e96e533143f86fe605e2da
author imgteam
date Sat, 12 Apr 2025 15:05:17 +0000
parents 5deaa390ca62
children
line wrap: on
line source

<tool id="ip_split_image" name="Split image along axes" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05">
    <description>with NumPy</description>
    <macros>
        <import>creators.xml</import>
        <import>tests.xml</import>
        <token name="@TOOL_VERSION@">2.2.3</token>
        <token name="@VERSION_SUFFIX@">1</token>
    </macros>
    <creator>
        <expand macro="creators/bmcv"/>
    </creator>
    <edam_operations>
        <edam_operation>operation_3443</edam_operation>
    </edam_operations>
    <requirements>
        <requirement type="package" version="@TOOL_VERSION@">numpy</requirement>
        <requirement type="package" version="0.4.0">giatools</requirement>
        <requirement type="package" version="2024.7.24">tifffile</requirement>
    </requirements>
    <command detect_errors="aggressive"><![CDATA[

        mkdir output &&
        python '$__tool_directory__/split.py'

        '$input'
        '$axis'
        output

        $squeeze

    ]]></command>
    <inputs>
        <param name="input" type="data" format="tiff,png" label="Image to split" />
        <param name="axis" type="select" label="Axis to split along">
            <option value="T">T-axis (split the frames of a temporal image sequence)</option>
            <option value="Z">Z-axis (split the slices of a 3-D image or image sequence)</option>
            <option value="C" selected="true">C-axis (split the channels of an image or image sequence)</option>
            <option value="S">S-axis (split the samples of an image or image sequence)</option>
            <option value="Q">Q-axis (other or unknown axis)</option>
        </param>
        <param name="squeeze" type="boolean" checked="false" truevalue="--squeeze" falsevalue="" label="Squeeze result imags" help="Only axes with more than one element will be retained in the result images. Does not apply for X and Y axes." />
    </inputs>
    <outputs>
        <collection type="list" name="output" label="Split ${on_string} along ${axis} axis">
            <discover_datasets directory="output" pattern="__name__" format="tiff" />
        </collection>
    </outputs>
    <tests>

        <!-- PNG tests -->
        <test>
            <param name="input" value="rgb1.png" />
            <param name="axis" value="C" />
            <param name="squeeze" value="false" />
            <output_collection name="output" type="list" count="3">
                <expand macro="tests/intensity_image_diff/element" name="1.tiff" value="rgb1_r.tiff" ftype="tiff"/>
                <expand macro="tests/intensity_image_diff/element" name="2.tiff" value="rgb1_g.tiff" ftype="tiff"/>
                <expand macro="tests/intensity_image_diff/element" name="3.tiff" value="rgb1_b.tiff" ftype="tiff"/>
            </output_collection>
        </test>

        <!-- TIFF tests -->
        <test>
            <param name="input" value="zcyx.tiff" />
            <param name="axis" value="Z" />
            <param name="squeeze" value="false" />
            <output_collection name="output" type="list" count="25">
                <expand macro="tests/intensity_image_diff/element" name="01.tiff" value="zcyx_slice01.tiff" ftype="tiff"/>
                <expand macro="tests/intensity_image_diff/element" name="25.tiff" value="zcyx_slice25.tiff" ftype="tiff"/>
            </output_collection>
        </test>
        <test>
            <param name="input" value="qyx.tiff" />
            <param name="axis" value="Q" />
            <param name="squeeze" value="false" />
            <output_collection name="output" type="list" count="2">
                <expand macro="tests/intensity_image_diff/element" name="1.tiff" value="qyx_q1.tiff" ftype="tiff"/>
                <expand macro="tests/intensity_image_diff/element" name="2.tiff" value="qyx_q2.tiff" ftype="tiff"/>
            </output_collection>
        </test>

        <!-- Test squeezing -->
        <test>
            <param name="input" value="rgb1.png" />
            <param name="axis" value="C" />
            <param name="squeeze" value="true" />
            <output_collection name="output" type="list" count="3">
                <expand macro="tests/intensity_image_diff/element" name="1.tiff" value="rgb1_squeezed_r.tiff" ftype="tiff"/>
                <expand macro="tests/intensity_image_diff/element" name="2.tiff" value="rgb1_squeezed_g.tiff" ftype="tiff"/>
                <expand macro="tests/intensity_image_diff/element" name="3.tiff" value="rgb1_squeezed_b.tiff" ftype="tiff"/>
            </output_collection>
        </test>

        <!-- Test with missing axes -->
        <test>
            <param name="input" value="rgb1.png" />
            <param name="axis" value="Z" />
            <param name="squeeze" value="false" />
            <output_collection name="output" type="list" count="1">
                <expand macro="tests/intensity_image_diff/element" name="1.tiff" value="rgb1_split_z.tiff" ftype="tiff"/>
            </output_collection>
        </test>

    </tests>
    <help>

        **Splits an image along a specific axis (e.g., channels).**

        This tool splits an image along a specifc axis and yields a collection of images.
        This can be used, for example, to convert a multi-channel image into a collection of single-channel images.

        The pixel data type of the split image is preserved (will be the same as the input image).

    </help>
    <citations>
        <citation type="doi">10.1038/s41586-020-2649-2</citation>
    </citations>
</tool>