Mercurial > repos > iuc > imagej2_create_image
comparison imagej2_make_binary_jython_script.py @ 6:74b6dd718fef draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
| author | iuc |
|---|---|
| date | Fri, 22 Jul 2016 23:12:05 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5:e16d8e6654a6 | 6:74b6dd718fef |
|---|---|
| 1 import jython_utils | |
| 2 import sys | |
| 3 from ij import IJ | |
| 4 | |
| 5 # Fiji Jython interpreter implements Python 2.5 which does not | |
| 6 # provide support for argparse. | |
| 7 error_log = sys.argv[ -8 ] | |
| 8 input = sys.argv[ -7 ] | |
| 9 iterations = int( sys.argv[ -6 ] ) | |
| 10 count = int( sys.argv[ -5 ] ) | |
| 11 black_background = jython_utils.asbool( sys.argv[ -4 ] ) | |
| 12 pad_edges_when_eroding = jython_utils.asbool( sys.argv[ -3 ] ) | |
| 13 tmp_output_path = sys.argv[ -2 ] | |
| 14 output_datatype = sys.argv[ -1 ] | |
| 15 | |
| 16 # Open the input image file. | |
| 17 input_image_plus = IJ.openImage( input ) | |
| 18 | |
| 19 # Create a copy of the image. | |
| 20 input_image_plus_copy = input_image_plus.duplicate() | |
| 21 image_processor_copy = input_image_plus_copy.getProcessor() | |
| 22 | |
| 23 try: | |
| 24 # Set binary options. | |
| 25 options = jython_utils.get_binary_options( black_background=black_background, | |
| 26 iterations=iterations, | |
| 27 count=count, | |
| 28 pad_edges_when_eroding=pad_edges_when_eroding ) | |
| 29 IJ.run( input_image_plus_copy, "Options...", options ) | |
| 30 | |
| 31 # Run the command. | |
| 32 IJ.run( input_image_plus_copy, "Make Binary", "" ) | |
| 33 | |
| 34 # Save the ImagePlus object as a new image. | |
| 35 IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path ) | |
| 36 except Exception, e: | |
| 37 jython_utils.handle_error( error_log, str( e ) ) |
