diff imagej2_noise.xml @ 1:7a44772cc89f draft

"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 756e062741dc
line wrap: on
line diff
--- a/imagej2_noise.xml	Tue Sep 17 16:58:28 2019 -0400
+++ b/imagej2_noise.xml	Mon Sep 28 16:45:49 2020 +0000
@@ -1,4 +1,3 @@
-<?xml version='1.0' encoding='UTF-8'?>
 <tool id="imagej2_noise" name="Add or remove noise" version="@WRAPPER_VERSION@.0">
     <description></description>
     <macros>
@@ -10,45 +9,92 @@
             </param>
         </xml>
     </macros>
-    <expand macro="fiji_requirements" />
-    <command>
-<![CDATA[
-    python $__tool_directory__/imagej2_noise.py
-    --input "$input"
-    --input_datatype $input.ext
-    --noise $noise_cond.noise
-    #if $noise_cond.noise == 'add_specified_noise':
-        --standard_deviation $noise_cond.standard_deviation
-    #else if $noise_cond.noise == 'remove_outliers':
-        --radius $noise_cond.radius
-        --threshold $noise_cond.threshold
-        --which_outliers $noise_cond.which_outliers
-    #else if $noise_cond.noise == 'randomj':
-        --randomj $noise_cond.randomj_cond.randomj
-        #if $noise_cond.randomj_cond.randomj == 'randomj_binomial':
-            --trials $noise_cond.randomj_cond.trials
-            --probability $noise_cond.randomj_cond.probability
-        #else if $noise_cond.randomj_cond.randomj == 'randomj_exponential':
-            --lammbda $noise_cond.randomj_cond.lammbda
-        #else if $noise_cond.randomj_cond.randomj == 'randomj_gamma':
-            --order $noise_cond.randomj_cond.order
-        #else if $noise_cond.randomj_cond.randomj == 'randomj_gaussian':
-            --mean $noise_cond.randomj_cond.mean
-            --sigma $noise_cond.randomj_cond.sigma
-         #else if $noise_cond.randomj_cond.randomj == 'randomj_poisson':
-            --mean $noise_cond.randomj_cond.mean
-         #else if $noise_cond.randomj_cond.randomj == 'randomj_uniform':
-            --min $noise_cond.randomj_cond.min
-            --max $noise_cond.randomj_cond.max
-        #end if
-        --insertion $noise_cond.randomj_cond.insertion
+    <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
-    --jython_script $__tool_directory__/imagej2_noise_jython_script.py
-    --output "$output"
-]]>
-    </command>
+#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>
-        <param format="bmp,eps,gif,jpg,pcx,pgm,png,psd,tiff" name="input" type="data" label="Select image"/>
+        <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>
@@ -60,12 +106,12 @@
                 <option value="rof_denoise">ROF Denoise</option>
                 <option value="randomj">RandomJ</option>
             </param>
-            <when value="add_noise" />
+            <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="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"/>
@@ -74,8 +120,8 @@
                     <option value="dark">Dark</option>
                 </param>
             </when>
-            <when value="remove_nans" />
-            <when value="rof_denoise" />
+            <when value="remove_nans"/>
+            <when value="rof_denoise"/>
             <when value="randomj">
                 <conditional name="randomj_cond">
                     <param name="randomj" type="select" label="RandomJ">
@@ -89,58 +135,52 @@
                     <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" />
+                        <expand macro="insertion_select"/>
                     </when>
                     <when value="randomj_exponential">
                         <param name="lammbda" type="float" value="0.5" label="Lambda"/>
-                        <expand macro="insertion_select" />
+                        <expand macro="insertion_select"/>
                     </when>
                     <when value="randomj_gamma">
                         <param name="order" type="integer" value="1" label="Order"/>
-                        <expand macro="insertion_select" />
+                        <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" />
+                        <expand macro="insertion_select"/>
                     </when>
                     <when value="randomj_poisson">
                         <param name="mean" type="float" value="1.0" label="Mean"/>
-                        <expand macro="insertion_select" />
+                        <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" />
+                        <expand macro="insertion_select"/>
                     </when>
                 </conditional>
             </when>
         </conditional>
     </inputs>
     <outputs>
-        <data name="output" format_source="input" label="${tool.name} on ${on_string}: ${noise_cond.noise.replace( '_', ' ' )}" />
+        <data name="output" format_source="input"/>
     </outputs>
     <tests>
         <test>
-            <param name="input" value="blobs.gif" />
-            <param name="input_datatype" value="gif" />
-            <param name="noise" value="add_specified_noise" />
-            <output name="output" file="add_specified_noise.gif" />
+            <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="input_datatype" value="gif" />
-            <param name="noise" value="despeckle" />
-            <output name="output" file="despeckle.gif" />
+            <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="input_datatype" value="gif" />
-            <param name="noise" value="remove_outliers" />
-            <param name="radius" value="2.0" />
-            <param name="threshold" value="50.0" />
-            <param name="which_outliers" value="bright" />
-            <output name="output" file="remove_outliers.gif" />
+            <param name="input" value="blobs.gif"/>
+            <param name="noise" value="remove_outliers"/>
+            <output name="output" file="remove_outliers.gif"/>
         </test>
     </tests>
     <help>
@@ -163,5 +203,5 @@
 - **RandonJ Uniform** - Contaminates image with random numbers generated using a uniform random variable.
 ]]>
     </help>
-    <expand macro="fiji_headless_citations" />
+    <expand macro="fiji_headless_citations"/>
 </tool>