view imagej2_math.xml @ 2:d7fbe9662213 draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5
author imgteam
date Sun, 05 Nov 2023 10:58:39 +0000
parents d48c999b3b96
children
line wrap: on
line source

<tool id="imagej2_math" name="Operate on pixels" version="@WRAPPER_VERSION@.2">
    <description>with ImageJ2</description>
    <macros>
        <import>imagej2_macros.xml</import>
    </macros>
    <edam_operations>
        <edam_operation>operation_3443</edam_operation>
    </edam_operations>
    <xrefs>
        <xref type="bio.tools">imagej</xref>
        <xref type="biii">imagej2</xref>
    </xrefs>
    <expand macro="fiji_requirements"/>
    <command detect_errors="exit_code"><![CDATA[
#import os
#set error_log = 'output_log.txt'
touch '$error_log' &&
#set input_sans_ext = $os.path.splitext($os.path.basename($input.file_name))[0]
#set input_with_ext = '.'.join([input_sans_ext, $input.ext])
ln -s '$input.file_name' '$input_with_ext' &&
#set output_filename = '.'.join(['output', $input.ext])
touch '$output_filename' &&
ImageJ --ij2 --headless --debug
--jython '$__tool_directory__/imagej2_math_jython_script.py'
'$error_log'
'$input_with_ext'
'$operation_cond.operation'
#if str($operation_cond.operation) == 'Macro':
    '$operation_cond.expression'
#else:
    'None'
#end if
#if str($operation_cond.operation) in ['AND', 'OR', 'XOR']:
    $operation_cond.bin_constant
#else:
    'None'
#end if
#if str($operation_cond.operation) not in ['Macro', 'AND', 'OR', 'XOR', 'Log', 'Exp', 'Square', 'Square_Root', 'Abs', 'Reciprocal']:
    $operation_cond.float_constant
#else:
    'None'
#end if
'$output_filename'
'$input.ext'
&>'$error_log';
if [[ $? -ne 0 ]]; then
    cat '$error_log' >&2;
else
    mv '$output_filename' '$output';
fi
]]></command>
    <inputs>
        <expand macro="param_input"/>
        <!--
        NOTE: The NaN Background option is not included here because it only works with 32-bit
        thresholded images, and incorporating the functionality from the Adjust threshold tool
        here for this option would be too messy.
        -->
        <conditional name="operation_cond">
            <param name="operation" type="select" label="Operation">
                <option value="Add">Add</option>
                <option value="Subtract">Subtract</option>
                <option value="Multiply">Multiply</option>
                <option value="Divide">Divide</option>
                <option value="AND">AND</option>
                <option value="OR">OR</option>
                <option value="XOR">XOR</option>
                <option value="Min">Min</option>
                <option value="Max">Max</option>
                <option value="Gamma">Gamma</option>
                <option value="Set">Set</option>
                <option value="Log">Log</option>
                <option value="Exp">Exp</option>
                <option value="Square">Square</option>
                <option value="Square_Root">Square Root</option>
                <option value="Abs">Abs</option>
                <option value="Reciprocal">Reciprocal</option>
                <option value="Macro">Macro</option>
            </param>
            <when value="Add">
                <param name="float_constant" type="float" value="25.0" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Subtract">
                <param name="float_constant" type="float" value="25.0" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Multiply">
                <param name="float_constant" type="float" value="1.250" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Divide">
                <param name="float_constant" type="float" value="1.250" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="AND">
                <param name="bin_constant" type="integer" value="11110000" label="Value (binary)" help="Value is a binary number"/>
            </when>
            <when value="OR">
                <param name="bin_constant" type="integer" value="11110000" label="Value (binary)" help="Value is a binary number"/>
            </when>
            <when value="XOR">
                <param name="bin_constant" type="integer" value="11110000" label="Value (binary)" help="Value is a binary number"/>
            </when>
            <when value="Min">
                <param name="float_constant" type="float" value="0" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Max">
                <param name="float_constant" type="float" value="255" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Gamma">
                <param name="float_constant" type="float" value="0.50" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Set">
                <param name="float_constant" type="float" value="25" label="Value" help="Value is a floating point number"/>
            </when>
            <when value="Log"/>
            <when value="Exp"/>
            <when value="Square"/>
            <when value="Square_Root"/>
            <when value="Abs"/>
            <when value="Reciprocal"/>
            <when value="Macro">
                <param name="expression" type="text" value="v=v+50*sin(d/17)" label="Code" help="v=pixel value, x,y and z=pixel coordinates, w=image width, h=image height, a=angle, d=distance from center"/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format_source="input"/>
    </outputs>
    <tests>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="operation" value="Multiply"/>
            <output name="output" file="blobs_multiply.gif" compare="sim_size"/>
        </test>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="operation" value="Min"/>
            <param name="float_constant" value="255"/>
            <output name="output" file="blobs_min.gif" compare="sim_size"/>
        </test>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="operation" value="Log"/>
            <output name="output" file="blobs_log.gif" compare="sim_size"/>
        </test>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="operation" value="Square"/>
            <output name="output" file="blobs_square.gif" compare="sim_size"/>
        </test>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="operation" value="Macro"/>
            <output name="output" file="blobs_macro.gif" compare="sim_size"/>
        </test>
    </tests>
    <help>

**What it does**

<![CDATA[

Applies a mathematical expression (add, subtract, multiply, etc.) to each pixel in the image.  When the
resulting pixel value overflows/underflows the legal range of the image's data type, the value is reset
to the maximum/minimum value.

- **Add** - Adds a value to each pixel in the image.  With 8-bit images, results greater than 255 are set to 255. nWith 16-bit signed images, results greater than 65,535 are set to 65,535.
- **Subtract** - Subtracts a value from each pixel in the image.  With 8-bit and 16-bit images, results less than 0 are set to 0.
- **Multiply** - Multiplies each pixel in the image by a value.  With 8-bit images, results greater than 255 are set to 255.  With 16-bit signed images, results greater than 65,535 are set to 65,535.
- **Divide** - Divides each pixel in the image by a value.  Except for 32-bit (float) images, attempts to divide by zero are ignored.  With 32-bit images, dividing by zero results in either NaN (0/0) or Infinity.
- **AND** - Performs a bitwise AND of each pixel in the image with the value.
- **OR** - Performs a bitwise OR of each pixel in the image with the value.
- **XOR** - Performs a bitwise XOR of each pixel in the image with the value.
- **Min** - Pixels in the image less than the value are replaced by the value.
- **Max** - Pixels in the image greater than the value are replaced by the value.
- **Gamma** - Applies the function f(p) = (p/255)^gamma*255 to each pixel (p) in the image, where 0.1 <= gamma <= 5.0.  For RGB images, this function is applied to all three color channels.  For 16-bit images, the image min and max are used for scaling instead of 255.
- **Set** - Fills the image with the value.
- **Log** - For 8-bit images, applies the function f(p) = log(p) * 255/log(255) to each pixel (p) in the image.  For RGB images, this function is applied to all three color channels.  For 16-bit images, the image min and max are used for scaling instead of 255.  For float images, no scaling is done.  To calculate log10 of the image, multiply the result of this operation by 0.4343 (1/log(10).
- **Exp** - Performs an exponential transform on the image.
- **Square** - Performs a square transform on the image.
- **Square Root** - Performs a square root transform on the image.
- **Abs** - Performs an absolute value transformation on the image.  This option works only with 32-bit or signed 16-bit images.  Other image types are automatically converted to 32-bit when this option is selected.
- **Reciprocal** - Generates the reciprocal of the image.  This option works only with 32-bit images.  Other image types are automatically converted to 32-bit when this option is selected.
- **Macro** - Performs image arithmetic using a user-specified expression.  It can be used to create fully-synthetic images or to perform precise pixel manipulations on existing images.

]]>

    </help>
    <expand macro="fiji_headless_citations"/>
</tool>