view imagej2_noise.xml @ 1:7a44772cc89f draft default tip

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 2afb24f3c81d625312186750a714d702363012b5"
author imgteam
date Mon, 28 Sep 2020 16:45:49 +0000
parents 3f6599ec7d30
children
line wrap: on
line source

<tool id="imagej2_noise" name="Add or remove noise" version="@WRAPPER_VERSION@.0">
    <description></description>
    <macros>
        <import>imagej2_macros.xml</import>
        <xml name="insertion_select">
            <param name="insertion" type="select" label="Insertion">
                <option value="additive" selected="True">Additive</option>
                <option value="multiplicative">Multiplicative</option>
            </param>
        </xml>
    </macros>
    <expand macro="fiji_requirements"/>
    <command detect_errors="exit_code"><![CDATA[
#import os
#set error_log = 'output_log.txt'
#if str($noise_cond.noise) == 'randomj':
    #set randomj_value = $noise_cond.randomj_cond.randomj
#else:
    #set randomj_value = None
#end if
#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' &&
touch '$error_log' &&
ImageJ --ij2 --headless --debug
--jython '$__tool_directory__/imagej2_noise_jython_script.py'
'$error_log'
'$input_with_ext'
'$input.ext'
'$noise_cond.noise'
#if $noise_cond.noise == 'add_specified_noise':
    $noise_cond.standard_deviation
#else:
    'None'
#end if
#if $noise_cond.noise == 'remove_outliers':
    $noise_cond.radius
    $noise_cond.threshold
    '$noise_cond.which_outliers'
#else:
    'None'
    'None'
    'None'
#end if
'$randomj_value'
#if $randomj_value == 'randomj_binomial':
    $noise_cond.randomj_cond.trials
    $noise_cond.randomj_cond.probability
#else:
    'None'
    'None'
#end if
#if $randomj_value == 'randomj_exponential':
    $noise_cond.randomj_cond.lammbda
#else:
    'None'
#end if
#if $randomj_value == 'randomj_gamma':
    $noise_cond.randomj_cond.order
#else:
    'None'
#end if
#if $randomj_value in['randomj_gaussian', 'randomj_poisson']:
    $noise_cond.randomj_cond.mean
    #if $randomj_value == 'randomj_gaussian':
        $noise_cond.randomj_cond.sigma
    #else:
        'None'
    #end if
#else:
    'None'
    'None'
#end if
#if $randomj_value == 'randomj_uniform':
    $noise_cond.randomj_cond.min
    $noise_cond.randomj_cond.max
#else:
    'None'
    'None'
#end if
#if str($randomj_value) != 'None':
    '$noise_cond.randomj_cond.insertion'
#else:
    'None'
#end if
'$output_filename'
&>'$error_log';
if [[ $? -ne 0 ]]; then
    cat '$error_log' >&2;
else
    mv '$output_filename' '$output';
fi
]]></command>
    <inputs>
        <expand macro="param_input"/>
        <conditional name="noise_cond">
            <param name="noise" type="select" label="Noise">
                <option value="add_noise" selected="True">Add Random Noise</option>
                <option value="add_specified_noise">Add Specified Noise</option>
                <option value="salt_and_pepper">Salt and Pepper</option>
                <option value="despeckle">Despeckle</option>
                <option value="remove_outliers">Remove Outliers</option>
                <option value="remove_nans">Remove NaNs</option>
                <option value="rof_denoise">ROF Denoise</option>
                <option value="randomj">RandomJ</option>
            </param>
            <when value="add_noise"/>
            <when value="add_specified_noise">
                <param name="standard_deviation" type="float" value="25.0" label="Standard deviation" help="Floating point number"/>
            </when>
            <when value="salt_and_pepper"/>
            <when value="despeckle"/>
            <when value="remove_outliers">
                <param name="radius" type="float" value="2.0" label="Radius" help="pixels"/>
                <param name="threshold" type="float" value="50.0" label="Threshold"/>
                <param name="which_outliers" type="select" label="Which Outliers">
                    <option value="bright" selected="True">Bright</option>
                    <option value="dark">Dark</option>
                </param>
            </when>
            <when value="remove_nans"/>
            <when value="rof_denoise"/>
            <when value="randomj">
                <conditional name="randomj_cond">
                    <param name="randomj" type="select" label="RandomJ">
                        <option value="randomj_binomial" selected="True">RandomJ Binomial</option>
                        <option value="randomj_exponential">RandomJ Exponential</option>
                        <option value="randomj_gamma">RandomJ Gamma</option>
                        <option value="randomj_gaussian">RandomJ Gaussian</option>
                        <option value="randomj_poisson">RandomJ Poisson</option>
                        <option value="randomj_uniform">RandomJ Uniform</option>
                    </param>
                    <when value="randomj_binomial">
                        <param name="trials" type="float" value="1.0" label="Trials"/>
                        <param name="probability" type="float" value="0.5" label="Probability"/>
                        <expand macro="insertion_select"/>
                    </when>
                    <when value="randomj_exponential">
                        <param name="lammbda" type="float" value="0.5" label="Lambda"/>
                        <expand macro="insertion_select"/>
                    </when>
                    <when value="randomj_gamma">
                        <param name="order" type="integer" value="1" label="Order"/>
                        <expand macro="insertion_select"/>
                    </when>
                    <when value="randomj_gaussian">
                        <param name="mean" type="float" value="0.0" label="Mean"/>
                        <param name="sigma" type="float" value="1.0" label="Sigma"/>
                        <expand macro="insertion_select"/>
                    </when>
                    <when value="randomj_poisson">
                        <param name="mean" type="float" value="1.0" label="Mean"/>
                        <expand macro="insertion_select"/>
                    </when>
                    <when value="randomj_uniform">
                        <param name="min" type="float" value="0.0" label="Min"/>
                        <param name="max" type="float" value="1.0" label="Max"/>
                        <expand macro="insertion_select"/>
                    </when>
                </conditional>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data name="output" format_source="input"/>
    </outputs>
    <tests>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="noise" value="add_specified_noise"/>
            <output name="output" file="add_specified_noise.gif"/>
        </test>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="noise" value="despeckle"/>
            <output name="output" file="despeckle.gif"/>
        </test>
        <test>
            <param name="input" value="blobs.gif"/>
            <param name="noise" value="remove_outliers"/>
            <output name="output" file="remove_outliers.gif"/>
        </test>
    </tests>
    <help>
**What it does**

<![CDATA[
Adds noise to or removes noise from images.

- **Add Random Noise** - Adds random noise to the image. The noise is Gaussian (normally) distributed with a mean of zero and standard deviation of 25.
- **Add Specified Noise** - Adds Gaussian noise with a mean of zero and a chosen standard deviation.
- **Salt and Pepper** - Adds salt and pepper noise to the image by randomly replacing 2.5% of the pixels with black pixels and 2.5% with white pixels. This command only works with 8-bit images.
- **Despeckle** - Replaces each pixel with the median value in its 3 × 3 neighborhood. This is a time consuming operation because for each pixel, the nine pixels in the 3 × 3 neighborhood must be sorted and the center pixel replaced with the median value (the fifth).
- **Remove Outliers** - Replaces a pixel by the median of the pixels in the surrounding if it deviates from the median by more than a certain value (the threshold).
- **Remove NaNs** - Replaces NaN (Not-a-Number) pixels in 32-bit images by the median of the neighbors inside the circular kernel area defined by Radius. It does not remove patches of NaNs larger than the kernel size, however.
- **RandonJ Binomial** - Contaminates image with random numbers generated using a binomial random variable
- **RandonJ Exponential** - Contaminates image with random numbers generated using an exponential random variable.
- **RandonJ Gamma** - Contaminates image with random numbers generated using a gamma random variable.
- **RandonJ Gaussian** - Contaminates image with random numbers generated using a Gaussian random variable.
- **RandonJ Poisson** - Contaminates image with random numbers generated using a Poisson random variable.
- **RandonJ Uniform** - Contaminates image with random numbers generated using a uniform random variable.
]]>
    </help>
    <expand macro="fiji_headless_citations"/>
</tool>