annotate imagej2_sharpen_jython_script.py @ 0:191d574ddd8d draft default tip

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
author bgruening
date Sat, 18 Mar 2017 09:43:20 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
1 import jython_utils
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
2 import sys
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
3 from ij import IJ
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
4
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
5 # Fiji Jython interpreter implements Python 2.5 which does not
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
6 # provide support for argparse.
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
7 error_log = sys.argv[ -4 ]
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
8 input = sys.argv[ -3 ]
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
9 tmp_output_path = sys.argv[ -2 ]
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
10 output_datatype = sys.argv[ -1 ]
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
11
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
12 # Open the input image file.
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
13 input_image_plus = IJ.openImage( input )
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
14
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
15 # Create a copy of the image.
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
16 input_image_plus_copy = input_image_plus.duplicate()
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
17 image_processor_copy = input_image_plus_copy.getProcessor()
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
18
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
19 try:
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
20 # Run the command.
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
21 IJ.run( input_image_plus_copy, "Sharpen", "" )
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
22 # Save the ImagePlus object as a new image.
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
23 IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path )
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
24 except Exception, e:
191d574ddd8d planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit b'7e5cd452018ae9507c2d1cd13dd688a747550393\n'
bgruening
parents:
diff changeset
25 jython_utils.handle_error( error_log, str( e ) )