changeset 3:bb65623b90a8 draft

planemo upload commit 8f8692e83217a072a3ed928469621f1f606ab28a-dirty
author iuc
date Tue, 04 Aug 2015 11:15:10 -0400
parents ea7a01d0f218
children 48f25b8408e1
files imagej2_base_utils.py imagej2_create_image.py imagej2_create_image.xml imagej2_macros.xml tool_dependencies.xml
diffstat 5 files changed, 60 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/imagej2_base_utils.py	Fri Jun 26 05:28:23 2015 -0400
+++ b/imagej2_base_utils.py	Tue Aug 04 11:15:10 2015 -0400
@@ -30,17 +30,17 @@
 
 def get_base_command_imagej2( memory_size=None, macro=None, jython_script=None ):
     imagej2_executable = get_imagej2_executable()
-    if imagej2_executable:
-        cmd = '%s --headless -DXincgc' % imagej2_executable
-        if memory_size is not None:
-            memory_size_cmd = ' -DXms=%s -DXmx=%s' % ( memory_size, memory_size )
-            cmd += memory_size_cmd
-        if macro is not None:
-            cmd += ' --macro %s' % os.path.abspath( macro )
-        if jython_script is not None:
-            cmd += ' --jython -u %s' % os.path.abspath( jython_script )
-        return cmd
-    return None
+    if imagej2_executable is None:
+        return None
+    cmd = '%s --ij2 --headless --debug' % imagej2_executable
+    if memory_size is not None:
+        memory_size_cmd = ' -DXms=%s -DXmx=%s' % ( memory_size, memory_size )
+        cmd += memory_size_cmd
+    if macro is not None:
+        cmd += ' --macro %s' % os.path.abspath( macro )
+    if jython_script is not None:
+        cmd += ' --jython %s' % os.path.abspath( jython_script )
+    return cmd
 
 def get_file_extension( image_format ):
     """
@@ -109,7 +109,7 @@
     platform_dict[ 'architecture' ] = machine.lower()
     return platform_dict
 
-def get_stderr_exception( tmp_err, tmp_stderr, tmp_stdout ):
+def get_stderr_exception( tmp_err, tmp_stderr, tmp_out, tmp_stdout, include_stdout=False ):
     tmp_stderr.close()
     """
     Return a stderr string of reasonable size.
@@ -126,8 +126,21 @@
     except OverflowError:
         pass
     tmp_stderr.close()
+    if include_stdout:
+        tmp_stdout = open( tmp_out, 'rb' )
+        stdout_str = ''
+        buffsize = BUFF_SIZE
+        try:
+            while True:
+                stdout_str += tmp_stdout.read( buffsize )
+                if not stdout_str or len( stdout_str ) % buffsize != 0:
+                    break
+        except OverflowError:
+            pass
     tmp_stdout.close()
-    return str( stderr_str )
+    if include_stdout:
+        return 'STDOUT\n%s\n\nSTDERR\n%s\n' % ( stdout_str, stderr_str )
+    return stderr_str
 
 def get_temp_dir( prefix='tmp-imagej-', dir=None ):
     """
@@ -151,6 +164,15 @@
     file_extension = get_file_extension( image_format )
     return get_tempfilename( tmp_dir, file_extension )
 
+def handle_none_type( val, val_type='float' ):
+    if val is None:
+        return ' None'
+    else:
+        if val_type == 'float':
+            return ' %.1f' % val
+        elif val_type == 'int':
+            return ' %d' % val
+
 def stop_err( msg ):
     sys.stderr.write( msg )
     sys.exit( 1 )
--- a/imagej2_create_image.py	Fri Jun 26 05:28:23 2015 -0400
+++ b/imagej2_create_image.py	Tue Aug 04 11:15:10 2015 -0400
@@ -38,7 +38,7 @@
     proc = subprocess.Popen( args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True )
     rc = proc.wait()
     if rc != 0:
-        error_message = imagej2_base_utils.get_stderr_exception( tmp_err, tmp_stderr, tmp_stdout )
+        error_message = imagej2_base_utils.get_stderr_exception( tmp_err, tmp_stderr, tmp_out, tmp_stdout )
         imagej2_base_utils.stop_err( error_message )
     shutil.move( tmp_image_path, args.out_fname )
     imagej2_base_utils.cleanup_before_exit( tmp_dir )
--- a/imagej2_create_image.xml	Fri Jun 26 05:28:23 2015 -0400
+++ b/imagej2_create_image.xml	Tue Aug 04 11:15:10 2015 -0400
@@ -4,7 +4,7 @@
     <macros>
         <import>imagej2_macros.xml</import>
     </macros>
-    <expand macro="fiji_headless_requirements" />
+    <expand macro="fiji_20141125_requirements" />
     <command>
 <![CDATA[
     python $__tool_directory__/imagej2_create_image.py
--- a/imagej2_macros.xml	Fri Jun 26 05:28:23 2015 -0400
+++ b/imagej2_macros.xml	Tue Aug 04 11:15:10 2015 -0400
@@ -1,11 +1,11 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <macros>
-    <xml name="fiji_headless_requirements">
+    <xml name="fiji_20141125_requirements">
         <requirements>
             <requirement type="package" version="20141125">fiji</requirement>
         </requirements>
     </xml>
-    <xml name="python_bioformats_requirements">
+    <xml name="python_bioformats_104_requirements">
         <requirements>
             <requirement type="package" version="20141125">fiji</requirement>
             <requirement type="package" version="1.0.11">javabridge</requirement>
@@ -41,6 +41,24 @@
             <option value="RGB_ramp">RGB ramp</option>
         </param>
     </xml>
+    <xml name="make_binary_params">
+        <param name="iterations" type="integer" value="1" min="1" max="100" label="Iterations" help="The number of times (1-100) erosion, dilation, opening, and closing are performed."/>
+        <param name="count" type="integer" value="1" min="1" max="8" label="Count" help="The number of adjacent background pixels necessary (1-8) for erosion or dilation."/>
+        <param name="black_background" type="select" label="Black background" help="If Yes, the background is black and the foreground is white (no implies the opposite).">
+            <option value="no" selected="True">No</option>
+            <option value="yes">Yes</option>
+        </param>
+        <param name="pad_edges_when_eroding" type="select" label="Pad edges when eroding" help="If Yes, eroding does not erode from the edges of the image.">
+            <option value="no" selected="True">No</option>
+            <option value="yes">Yes</option>
+        </param>
+    </xml>
+    <token name="@make_binary_args@">
+        --iterations $iterations
+        --count $count
+        --black_background $black_background
+        --pad_edges_when_eroding $pad_edges_when_eroding
+    </token>
     <xml name="max_heap_size_type_conditional">
         <conditional name="set_max_heap_size">
             <param name="max_heap_size_type" type="select" label="Maximum size of the memory allocation pool used by the JVM" help="This value must be a multiple of 1024 or it will be ignored and the system default will be used.">
@@ -48,8 +66,8 @@
                 <option value="megabytes">Set in megabytes</option>
                 <option value="gigabytes">Set in gigabytes</option>
             </param>
-            <when value="default">
-                <param name="max_heap_size" type="integer" value="0" label="Do not set" help="Use system default"/>
+            <when value="default" >
+                <param name="max_heap_size" type="integer" value="0" hidden="true" label="Do not set" help="Use system default"/>
             </when>
             <when value="megabytes">
                 <param name="max_heap_size" type="integer" value="512" min="256" label="Maximum size, in megabytes, of the memory allocation pool" help="Examples: 256, 512, etc."/>
--- a/tool_dependencies.xml	Fri Jun 26 05:28:23 2015 -0400
+++ b/tool_dependencies.xml	Tue Aug 04 11:15:10 2015 -0400
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <tool_dependency>
     <package name="fiji" version="20141125">
-        <repository changeset_revision="7121a1ea4839" name="package_fiji_20141125" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="9dbe89105a25" name="package_fiji_20141125" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>