Mercurial > repos > iuc > imagej2_bunwarpj_align
changeset 10:5147fcf71ee5 draft
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
| author | iuc |
|---|---|
| date | Wed, 26 Aug 2015 14:38:12 -0400 |
| parents | 8a14f00234e0 |
| children | 7631a5b3a636 |
| files | imagej2_base_utils.py imagej2_bunwarpj_align.py imagej2_bunwarpj_align.xml imagej2_macros.xml jython_utils.py |
| diffstat | 5 files changed, 34 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/imagej2_base_utils.py Tue Aug 04 13:21:10 2015 -0400 +++ b/imagej2_base_utils.py Wed Aug 26 14:38:12 2015 -0400 @@ -86,21 +86,6 @@ os.symlink( input_file, image_path ) return image_path -def get_max_heap_size_value( max_heap_size_type, max_heap_size ): - """ - Return a string that can be used by the javabridge to set the size - of the memory allocation pool used by the JVM. The value must be - determined to be a multiple of 1024 or it will be ignored. - """ - if max_heap_size_type == 'default': - return None - if max_heap_size_type == 'megabytes': - if int( max_heap_size ) % 1024 not in [ 0, 256, 512 ]: - return None - return '%sm' % str( max_heap_size ) - if max_heap_size_type == 'gigabytes': - return '%sg' % str( max_heap_size ) - def get_platform_info_dict(): '''Return a dict with information about the current platform.''' platform_dict = {} @@ -172,6 +157,7 @@ return ' %.1f' % val elif val_type == 'int': return ' %d' % val + return ' %s' % val def stop_err( msg ): sys.stderr.write( msg )
--- a/imagej2_bunwarpj_align.py Tue Aug 04 13:21:10 2015 -0400 +++ b/imagej2_bunwarpj_align.py Wed Aug 26 14:38:12 2015 -0400 @@ -35,8 +35,6 @@ parser.add_argument( '--target_out', default=None, help='Output target image' ) parser.add_argument( '--target_out_datatype', default=None, help='Output registered target image format' ) 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.' ) args = parser.parse_args() @@ -66,9 +64,6 @@ target_file_name = imagej2_base_utils.get_file_name_without_extension( tmp_target_out_tiff_path ) tmp_target_out_transf_path = os.path.join( tmp_dir, '%s_transf.txt' % target_file_name ) -# Set the size of the memory allocation pool used by the JVM. -memory_size = imagej2_base_utils.get_max_heap_size_value( args.max_heap_size_type, args.max_heap_size ) - # Define command response buffers. tmp_out = tempfile.NamedTemporaryFile().name tmp_stdout = open( tmp_out, 'wb' ) @@ -76,7 +71,7 @@ tmp_stderr = open( tmp_err, 'wb' ) # Build the command line to align the two images. -cmd = imagej2_base_utils.get_base_cmd_bunwarpj( memory_size ) +cmd = imagej2_base_utils.get_base_cmd_bunwarpj( None ) if cmd is None: imagej2_base_utils.stop_err( "bUnwarpJ not found!" ) cmd += ' -align' @@ -142,7 +137,7 @@ tmp_stderr = open( tmp_err, 'wb' ) # Build the command line to handle the multi-slice tiff images. -cmd = imagej2_base_utils.get_base_command_imagej2( memory_size, jython_script=args.jython_script ) +cmd = imagej2_base_utils.get_base_command_imagej2( None, jython_script=args.jython_script ) if cmd is None: imagej2_base_utils.stop_err( "ImageJ not found!" ) if args.mono:
--- a/imagej2_bunwarpj_align.xml Tue Aug 04 13:21:10 2015 -0400 +++ b/imagej2_bunwarpj_align.xml Wed Aug 26 14:38:12 2015 -0400 @@ -1,10 +1,10 @@ <?xml version='1.0' encoding='UTF-8'?> -<tool id="imagej2_bunwarpj_align" name="Align two images" version="1.0.0"> +<tool id="imagej2_bunwarpj_align" name="Align two images" version="@WRAPPER_VERSION@.0"> <description>with bUnwarpJ</description> <macros> <import>imagej2_macros.xml</import> </macros> - <expand macro="fiji_20141125_requirements" /> + <expand macro="fiji_requirements" /> <command> <![CDATA[ python $__tool_directory__/imagej2_bunwarpj_align.py @@ -44,7 +44,6 @@ --target_out_datatype $target_out_datatype #end if --jython_script $__tool_directory__/jython_script.py - @max_heap_size_args@ ]]> </command> <inputs> @@ -119,7 +118,6 @@ <when value="mono"/> <when value="save_transformation"/> </conditional> - <expand macro="max_heap_size_type_conditional" /> </inputs> <outputs> <data name="source_out" format="png" label="${tool.name} on ${on_string}: Registered source image">
--- a/imagej2_macros.xml Tue Aug 04 13:21:10 2015 -0400 +++ b/imagej2_macros.xml Wed Aug 26 14:38:12 2015 -0400 @@ -1,11 +1,12 @@ <?xml version='1.0' encoding='UTF-8'?> <macros> - <xml name="fiji_20141125_requirements"> + <token name="@WRAPPER_VERSION@">1.0</token> + <xml name="fiji_requirements"> <requirements> <requirement type="package" version="20141125">fiji</requirement> </requirements> </xml> - <xml name="python_bioformats_104_requirements"> + <xml name="python_bioformats_requirements"> <requirements> <requirement type="package" version="20141125">fiji</requirement> <requirement type="package" version="1.0.11">javabridge</requirement> @@ -53,33 +54,27 @@ <option value="yes">Yes</option> </param> </xml> + <xml name="black_background_param"> + <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> + </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."> - <option value="default" selected="True">Do not set</option> - <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" 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."/> - </when> - <when value="gigabytes"> - <param name="max_heap_size" type="integer" value="1" min="1" label="Maximum size, in gigabytes, of the memory allocation pool" help="Examples: 1, 2, etc."/> - </when> - </conditional> - </xml> - <token name="@max_heap_size_args@"> - --max_heap_size_type $set_max_heap_size.max_heap_size_type - --max_heap_size $set_max_heap_size.max_heap_size + <token name="@requires_binary_input@"> +.. class:: warningmark + +This tool works on binary images, so other image types will automatically be converted to binary +before they are analyzed. This step is performed using the ImageJ2 **Make Binary** command with +the following settings: **Iterations:** 1, **Count:** 1, **Pad edges when eroding:** No. The tool +allows you to choose the **Black background** setting. If these settings are not appropriate, +first manually convert the image to binary using the **Convert to binary (black and white) with ImageJ2** +tool, which allows you to change them. </token> <xml name="image_datatypes"> <option value="bmp">bmp</option>
--- a/jython_utils.py Tue Aug 04 13:21:10 2015 -0400 +++ b/jython_utils.py Wed Aug 26 14:38:12 2015 -0400 @@ -4,6 +4,9 @@ IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES = { '0':'GRAY8', '1':'GRAY16', '2':'GRAY32', '3':'COLOR_256', '4':'COLOR_RGB' } +def asbool( val ): + return str( val ).lower() in [ 'yes', 'true' ] + def convert_before_saving_as_tiff( image_plus ): # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3 # slices which can be viewed in ImageJ. The 3 slices are: 1) the @@ -26,6 +29,14 @@ IJ.saveAs( image_plus, 'png', tmp_out_png_path ) return IJ.openImage( tmp_out_png_path ) +def get_binary_options( black_background, iterations=1, count=1, pad_edges_when_eroding='no' ): + options = [ 'edm=Overwrite', 'iterations=%d' % iterations, 'count=%d' % count ] + if asbool( pad_edges_when_eroding ): + options.append( 'pad' ) + if asbool( black_background ): + options.append( "black" ) + return " ".join( options ) + def get_display_image_type( image_type ): return IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES.get( str( image_type ), None )
