Mercurial > repos > imgteam > split_image
view split_image.xml @ 3:d45a07063da1 draft default tip
planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/split_image/ commit df96ae15da34285b0a9d435a48924665fff37d6a
| author | imgteam |
|---|---|
| date | Sat, 04 Apr 2026 21:22:07 +0000 |
| parents | 227e8928af6e |
| 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.3.5</token> <token name="@VERSION_SUFFIX@">1</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> </xrefs> <requirements> <requirement type="package" version="@TOOL_VERSION@">numpy</requirement> <requirement type="package" version="0.7.3">giatools</requirement> </requirements> <required_files> <include type="glob" path="*.py"/> </required_files> <command detect_errors="aggressive"><![CDATA[ mkdir output && python '$__tool_directory__/split.py' '$input' '$axis' output $offset $step $squeeze #if str($count) != "" --count $count #end if ]]></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> <option value="">Split dataset that contains multiple images (e.g., multi-series TIFF)</option> </param> <param name="squeeze" type="boolean" checked="false" truevalue="--squeeze" falsevalue="" label="Squeeze result images" help="Only non-singleton axes (axes with more than one element) will be retained in the result images. This does not apply for the X and Y axes which always are retained."/> <param name="offset" type="integer" value="0" min="0" label="Offset" help="Number of slices to skip at the beginning."/> <param name="step" type="integer" value="1" min="1" label="Step" help="Number of slices between extracted images (each slice is extracted for a value of 1, each second slice is extracted for a value of two, and so on)."/> <param name="count" type="integer" optional="true" min="1" label="Count" help="Maximum number of slices to extract."/> </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> <assert_stdout> <has_line line="Input image axes: YXC"/> <has_line line="Input image shape: (32, 32, 3)"/> <has_line line="Writing 3 out of 3 image(s)"/> <has_line line="Output axes: YXC"/> <has_line line="Output shape: (32, 32, 1)"/> </assert_stdout> </test> <test> <param name="input" value="rgb1.png" /> <param name="axis" value="" /> <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.tiff" ftype="tiff"/> </output_collection> <assert_stdout> <has_line line="Found 1 image(s) in file"/> <has_line line="Writing 1 out of 1 image(s)"/> <has_line line="Output axes: YXC"/> <has_line line="Output shape: (32, 32, 3)"/> </assert_stdout> </test> <!-- TIFF tests --> <test> <param name="input" value="zcyx.tiff"/> <param name="axis" value="Z"/> <param name="squeeze" value="false"/> <param name="offset" value="9"/> <param name="step" value="2"/> <param name="count" value="5"/> <output_collection name="output" type="list" count="5"> <expand macro="tests/intensity_image_diff/element" name="10.tiff" value="zcyx_slice10.tiff" ftype="tiff"/> <expand macro="tests/intensity_image_diff/element" name="18.tiff" value="zcyx_slice18.tiff" ftype="tiff"/> </output_collection> <assert_stdout> <has_line line="Input image axes: ZCYX"/> <has_line line="Input image shape: (25, 2, 50, 50)"/> <has_line line="Writing 5 out of 25 image(s)"/> <has_line line="Output axes: ZCYX"/> <has_line line="Output shape: (1, 2, 50, 50)"/> </assert_stdout> </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> <assert_stdout> <has_line line="Input image axes: QYX"/> <has_line line="Input image shape: (2, 256, 256)"/> <has_line line="Writing 2 out of 2 image(s)"/> <has_line line="Output axes: QYX"/> <has_line line="Output shape: (1, 256, 256)"/> </assert_stdout> </test> <test> <param name="input" value="qyx.tiff" /> <param name="axis" value="" /> <param name="squeeze" value="false" /> <output_collection name="output" type="list" count="1"> <expand macro="tests/intensity_image_diff/element" name="1.tiff" value="qyx.tiff" ftype="tiff"/> </output_collection> <assert_stdout> <has_line line="Found 1 image(s) in file"/> </assert_stdout> </test> <!-- Test splitting multi-series TIFF --> <test> <param name="input" value="multiseries.ome.tiff" /> <param name="axis" value="" /> <param name="squeeze" value="false" /> <output_collection name="output" type="list" count="6"> <expand macro="tests/intensity_image_diff/element" name="1.tiff" value="multiseries_series1.tiff" ftype="tiff"/> <expand macro="tests/intensity_image_diff/element" name="6.tiff" value="multiseries_series6.tiff" ftype="tiff"/> </output_collection> <assert_stdout> <has_line line="Found 6 image(s) in file"/> <has_line line="Writing 6 out of 6 image(s)"/> <has_line line="Output 1 axes: CYX"/> <has_line line="Output 1 shape: (4, 5, 5)"/> <has_line line="Output 2 axes: CYX"/> <has_line line="Output 2 shape: (4, 5, 5)"/> <has_line line="Output 3 axes: CYX"/> <has_line line="Output 3 shape: (4, 5, 5)"/> <has_line line="Output 4 axes: CYX"/> <has_line line="Output 4 shape: (4, 5, 5)"/> <has_line line="Output 5 axes: CYX"/> <has_line line="Output 5 shape: (4, 5, 5)"/> <has_line line="Output 6 axes: CYX"/> <has_line line="Output 6 shape: (4, 5, 5)"/> </assert_stdout> </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> <assert_stdout> <has_line line="Input image axes: YXC"/> <has_line line="Input image shape: (32, 32, 3)"/> <has_line line="Writing 3 out of 3 image(s)"/> <has_line line="Output axes: YX"/> <has_line line="Output shape: (32, 32)"/> </assert_stdout> </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> <assert_stdout> <has_line line="Input image axes: YXC"/> <has_line line="Input image shape: (32, 32, 3)"/> <has_line line="Writing 1 out of 1 image(s)"/> <has_line line="Output axes: YXC"/> <has_line line="Output shape: (32, 32, 3)"/> </assert_stdout> </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>
