Mercurial > repos > iuc > imagej2_noise
changeset 2:c8fc3f34cbff draft
planemo upload commit 8f8692e83217a072a3ed928469621f1f606ab28a-dirty
| author | iuc |
|---|---|
| date | Tue, 04 Aug 2015 11:15:16 -0400 |
| parents | 1af4f60294c3 |
| children | d99cf938ad41 |
| files | imagej2_base_utils.py imagej2_macros.xml imagej2_noise.py imagej2_noise.xml jython_script.py jython_utils.py tool_dependencies.xml |
| diffstat | 7 files changed, 112 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/imagej2_base_utils.py Fri Jun 26 05:28:29 2015 -0400 +++ b/imagej2_base_utils.py Tue Aug 04 11:15:16 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_macros.xml Fri Jun 26 05:28:29 2015 -0400 +++ b/imagej2_macros.xml Tue Aug 04 11:15:16 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/imagej2_noise.py Fri Jun 26 05:28:29 2015 -0400 +++ b/imagej2_noise.py Tue Aug 04 11:15:16 2015 -0400 @@ -6,15 +6,6 @@ import tempfile import imagej2_base_utils -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 - if __name__=="__main__": # Parse Command Line. parser = argparse.ArgumentParser() @@ -38,7 +29,7 @@ parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' ) parser.add_argument( '--max_heap_size_type', dest='max_heap_size_type', help='Type (default or megabytes) of max_heap_size value' ) parser.add_argument( '--max_heap_size', dest='max_heap_size', help='Maximum size of the memory allocation pool used by the JVM.' ) - parser.add_argument( '--output', help='Path to the output file' ) + parser.add_argument( '--output', dest='output', help='Path to the output file' ) args = parser.parse_args() tmp_dir = imagej2_base_utils.get_temp_dir() @@ -65,19 +56,19 @@ cmd += ' %s' % tmp_input_path cmd += ' %s' % args.input_datatype cmd += ' %s ' % args.noise - cmd += handle_none_type( args.standard_deviation ) - cmd += handle_none_type( args.radius ) - cmd += handle_none_type( args.threshold ) + cmd += imagej2_base_utils.handle_none_type( args.standard_deviation ) + cmd += imagej2_base_utils.handle_none_type( args.radius ) + cmd += imagej2_base_utils.handle_none_type( args.threshold ) cmd += ' %s' % args.which_outliers cmd += ' %s' % args.randomj - cmd += handle_none_type( args.trials ) - cmd += handle_none_type( args.probability ) - cmd += handle_none_type( args.lammbda ) - cmd += handle_none_type( args.order, val_type='int' ) - cmd += handle_none_type( args.mean ) - cmd += handle_none_type( args.sigma ) - cmd += handle_none_type( args.min ) - cmd += handle_none_type( args.max ) + cmd += imagej2_base_utils.handle_none_type( args.trials ) + cmd += imagej2_base_utils.handle_none_type( args.probability ) + cmd += imagej2_base_utils.handle_none_type( args.lammbda ) + cmd += imagej2_base_utils.handle_none_type( args.order, val_type='int' ) + cmd += imagej2_base_utils.handle_none_type( args.mean ) + cmd += imagej2_base_utils.handle_none_type( args.sigma ) + cmd += imagej2_base_utils.handle_none_type( args.min ) + cmd += imagej2_base_utils.handle_none_type( args.max ) cmd += ' %s' % args.insertion cmd += ' %s' % tmp_output_path @@ -86,7 +77,7 @@ # Handle execution errors. 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 ) # Handle processing errors. if os.path.getsize( error_log ) > 0:
--- a/imagej2_noise.xml Fri Jun 26 05:28:29 2015 -0400 +++ b/imagej2_noise.xml Tue Aug 04 11:15:16 2015 -0400 @@ -10,7 +10,7 @@ </param> </xml> </macros> - <expand macro="fiji_headless_requirements" /> + <expand macro="fiji_20141125_requirements" /> <command> <