view color_to_gray.xml @ 1:e8f822eeb9fd draft default tip

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 7d7a519c3a2cc612d38695b335d0f6c75a099de3"
author bgruening
date Fri, 26 Feb 2021 14:14:56 +0000
parents 4395ea2a01f4
children
line wrap: on
line source

<tool id="cp_color_to_gray" name="ColorToGray" version="@CP_VERSION@+galaxy@VERSION_SUFFIX@" python_template_version="3.5">
    <description> converts color and channel-stacked images to grayscale</description>
    <macros>
        <import>macros.xml</import>
        <token name="@VERSION_SUFFIX@">0</token>
        <xml name="combine_weight">
            <param name="weight_red_channel" value="1.0" min = "0.0" max = "1.0" type="float" label="Relative weight of the red channel" />
            <param name="weight_green_channel" value="1.0" min = "0.0" max = "1.0" type="float" label="Relative weight of the green channel" />
            <param name="weight_blue_channel" value="1.0" min = "0.0" max = "1.0" type="float" label="Relative weight of the blue channel" />
        </xml>
        <xml name="image_type_param">
            <param name="image_type" label="Image type" type="select">
                <option value="RGB">RGB</option>
                <option value="HSV">HSV</option>
                <option value="Channels">Channels</option>
            </param>
        </xml>

        <xml name="split_rgb">
            <conditional name="con_convert_red">
                <param name="yes_no" type="select" label="Convert red to gray">
                    <option value="Yes">Yes</option>
                    <option value="No">No</option>
                </param>
                <when value="Yes">
                    <param name="name_output_image" value="OrigRed" type="text" label="Name the output image" />
                </when>
                <when value="No">
                </when>
            </conditional>
            <conditional name="con_convert_green">
                <param name="yes_no" type="select" label="Convert green to gray">
                    <option value="Yes">Yes</option>
                    <option value="No">No</option>
                </param>
                <when value="Yes">
                    <param name="name_output_image" value="OrigGreen" type="text" label="Name the output image" />
                </when>
                <when value="No">
                </when>
            </conditional>
            <conditional name="con_convert_blue">
                <param name="yes_no" type="select" label="Convert blue to gray">
                    <option value="Yes">Yes</option>
                    <option value="No">No</option>
                </param>
                <when value="Yes">
                    <param name="name_output_image" value="OrigBlue" type="text" label="Name the output image" />
                </when>
                <when value="No">
                </when>
            </conditional>
        </xml>

        <xml name="split_hsv">
            <conditional name="con_convert_hue">
                <param name="yes_no" type="select" label="Convert hue to gray">
                    <option value="Yes">Yes</option>
                    <option value="No">No</option>
                </param>
                <when value="Yes">
                    <param name="name_output_image" value="OrigHue" type="text" label="Name the output image" />
                </when>
                <when value="No">
                </when>
            </conditional>
            <conditional name="con_convert_saturation">
                <param name="yes_no" type="select" label="Convert saturation to gray">
                    <option value="Yes">Yes</option>
                    <option value="No">No</option>
                </param>
                <when value="Yes">
                    <param name="name_output_image" value="OrigSaturation" type="text" label="Name the output image" />
                </when>
                <when value="No">
                </when>
            </conditional>
            <conditional name="con_convert_value">
                <param name="yes_no" type="select" label="Convert value to gray">
                    <option value="Yes">Yes</option>
                    <option value="No">No</option>
                </param>
                <when value="Yes">
                    <param name="name_output_image" value="OrigValue" type="text" label="Name the output image" />
                </when>
                <when value="No">
                </when>
            </conditional>
        </xml>

        <xml name="combine">
            <param name="name_output_image" label="Name the output image" value="OrigGray" type="text">
                <expand macro="text_validator" />
            </param>
            <conditional name="con_image_type">
                <expand macro="image_type_param" />
                <when value="RGB">
                    <expand macro="combine_weight"/>
                </when>
                <when value="HSV">
                    <expand macro="combine_weight"/>
                </when>
                <when value="Channels">
                    <repeat name="rpt_channel" title="another channel" min="1">
                        <param name="channel_no" value="1" type="integer" label="Channel number" />
                        <param name="weight_of_channel" value="1.0" type="float" min = "0.0" max = "1.0" label="Relative weight of the channel" />
                    </repeat>
                </when>
            </conditional>
        </xml>
        <xml name="split">
            <conditional name="con_image_type">
                <expand macro="image_type_param" />
                <when value="RGB">
                    <expand macro="split_rgb"/>
                </when>
                <when value="HSV">
                    <expand macro="split_hsv"/>
                </when>
                <when value="Channels">
                    <repeat name="rpt_channel" title="another channel" min="1">
                        <param name="channel_no" value="1" type="integer" label="Channel number" help="This setting chooses a channel to be processed. The channel number should be within the range of channels in the image."/>
                        <param name="image_name" type="text" label="Image name" />
                    </repeat>
                </when>
            </conditional>
        </xml>

    </macros>
    <expand macro="py_requirements"/>
    <command detect_errors="exit_code">
        <![CDATA[
            python '$__tool_directory__/color_to_gray.py' -p '$input_pipeline' -i '$input_json'
            ]]>
    </command>
    <configfiles>
        <inputs name="input_json"/>
    </configfiles>
    <inputs>
        <expand macro="input_pipeline_param"/>
        <param name="name_input_image" label="Enter the name of the input image" value="DNA" type="text">
            <expand macro="text_validator" />
        </param>
        <conditional name="con_conversion_method">
            <param name="conversion_method" type="select" label="Conversion method" >
                <help>
                    <![CDATA[
                        How do you want to convert the color image? 
                        <i>Split:</i> Splits the channels of a color image (e.g., red, green, blue) into separate grayscale images. 
                        <i>Combine:</i> Converts a color image to a grayscale image by combining channels together (e.g., red, green, blue).
                    ]]>

                </help>
                <option value="Combine">Combine</option>
                <option value="Split">Split</option>
            </param>
            <when value="Combine">
                <expand macro="combine"/>
            </when>
            <when value="Split">
                <expand macro="split"/>
            </when>
        </conditional>
        
    </inputs>
    <outputs>
        <expand macro="output_pipeline_param" />
    </outputs>
    <tests>
        <test>
            <param name="input_pipeline" value="common.cppipe"/>
            <param name="name_input_image" value="OrigColor" />
            <conditional name="con_conversion_method">
                <param name="conversion_method" value="Combine"/>
                <param name="name_output_image" value="OrigGray" />
                <conditional name="con_image_type">
                    <param name = "image_type" value="RGB"/>
                    <param name ="weight_red_channel" value = "1.0" />
                    <param name ="weight_green_channel" value = "1.0" />
                    <param name ="weight_blue_channel" value = "1.0" />
                </conditional>
            </conditional>
            <expand macro="test_out_file" file="color_to_gray.cppipe" />
        </test>
        <test>
            <param name="input_pipeline" value="common.cppipe"/>
            <param name="name_input_image" value="DNA" />
            <conditional name="con_conversion_method">
                <param name="conversion_method" value="Combine"/>
                <param name="name_output_image" value="OrigGray" />
                <conditional name="con_image_type">
                    <param name = "image_type" value="Channels"/>
                    <repeat name="rpt_channel">
                        <param name="channel_no" value="2" />
                        <param name="weight_of_channel" value="0.2" />
                    </repeat>
                    <repeat name="rpt_channel">
                        <param name="channel_no" value="3" />
                        <param name="weight_of_channel" value="0.5" />
                    </repeat>
                </conditional>
            </conditional>

            <expand macro="test_out_file" file="color_to_gray_combine_channels.cppipe" />
        </test>
        <test>
            <param name="input_pipeline" value="common.cppipe"/>
            <param name="name_input_image" value="DNA" />
            <conditional name="con_conversion_method">
                <param name="conversion_method" value="Split"/>
                <param name="name_output_image" value="OrigGray" />
                <conditional name="con_image_type">
                    <param name = "image_type" value="HSV"/>
                    <conditional name="con_convert_hue">
                        <param name="yes_no" value="Yes" />
                        <param name="name_output_image" value="OutputHue" />
                    </conditional>
                    <conditional name="con_convert_saturation">
                        <param name="yes_no" value="No" />
                    </conditional>
                    <conditional name="con_convert_value">
                        <param name="yes_no" value="Yes" />
                        <param name="name_output_image" value="OutputValue" />
                    </conditional>
                </conditional>
            </conditional>

            <expand macro="test_out_file" file="color_to_gray_split_hsv.cppipe" />
        </test>
        <test>
            <param name="input_pipeline" value="common.cppipe"/>
            <param name="name_input_image" value="DNA" />
            <conditional name="con_conversion_method">
                <param name="conversion_method" value="Split"/>
                <param name="name_output_image" value="DNA" />
                <conditional name="con_image_type">
                    <param name = "image_type" value="RGB"/>
                    <conditional name="con_convert_red">
                        <param name="yes_no" value="Yes" />
                        <param name="name_output_image" value="OutputRed" />
                    </conditional>
                    <conditional name="con_convert_green">
                        <param name="yes_no" value="Yes" />
                        <param name="name_output_image" value="OutputGreen" />
                    </conditional>
                    <conditional name="con_convert_blue">
                        <param name="yes_no" value="No" />
                        
                    </conditional>
                </conditional>
            </conditional>

            <expand macro="test_out_file" file="color_to_gray_split_rgb.cppipe" />
        </test>
        <test>
            <param name="input_pipeline" value="common.cppipe"/>
            <param name="name_input_image" value="DNA" />
            <conditional name="con_conversion_method">
                <param name="conversion_method" value="Split"/>
                <param name="name_output_image" value="DNA" />
                <conditional name="con_image_type">
                    <param name = "image_type" value="Channels"/>
                    <repeat name="rpt_channel">
                        <param name="channel_no" value="2" />
                        <param name="image_name" value="Image2" />
                    </repeat>
                    <repeat name="rpt_channel">
                        <param name="channel_no" value="3" />
                        <param name="image_name" value="Image3" />
                    </repeat>
                </conditional>
            </conditional>

            <expand macro="test_out_file" file="color_to_gray_split_channels.cppipe" />
        </test>
    </tests>
    <help>
        <![CDATA[

            .. class:: infomark

            **What it does**

            This module converts color and channel-stacked images to grayscale. All channels can be merged into one grayscale image (Combine), or each channel can be extracted into a separate grayscale image (Split). If you use Combine, the relative weights you provide allow adjusting the contribution of the colors relative to each other. Note that all Identify modules require grayscale images. 

            @COMMON_HELP@
            ]]>
    </help>
    <expand macro="citations"/>
</tool>