annotate imagej2_shadows_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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
1 import jython_utils
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
2 import sys
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
3 from ij import IJ
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
4
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
5 # Fiji Jython interpreter implements Python 2.5 which does not
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
6 # provide support for argparse.
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
7 error_log = sys.argv[ -5 ]
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
8 input = sys.argv[ -4 ]
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
9 direction = sys.argv[ -3 ]
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
10 tmp_output_path = sys.argv[ -2 ]
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
11 output_datatype = sys.argv[ -1 ]
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
12
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
13 # Open the input image file.
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
14 input_image_plus = IJ.openImage( input )
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
15
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
16 # Create a copy of the image.
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
17 input_image_plus_copy = input_image_plus.duplicate()
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
18 image_processor_copy = input_image_plus_copy.getProcessor()
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
19
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
20 try:
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
21 # Run the command.
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
22 IJ.run( input_image_plus_copy, direction, "" )
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
23 # Save the ImagePlus object as a new image.
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
24 IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path )
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
25 except Exception, e:
74b6dd718fef planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8ea6a4271431c05c82b09c0d3e629b13e6ea7936
iuc
parents:
diff changeset
26 jython_utils.handle_error( error_log, str( e ) )