Mercurial > repos > iuc > imagej2_shadows
annotate jython_script.py @ 0:42e645a20a6e draft
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
| author | iuc |
|---|---|
| date | Wed, 26 Aug 2015 14:36:27 -0400 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
1 import jython_utils |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
2 import sys |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
3 from ij import IJ |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
4 |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
5 # Fiji Jython interpreter implements Python 2.5 which does not |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
6 # provide support for argparse. |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
7 error_log = sys.argv[ -5 ] |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
8 input = sys.argv[ -4 ] |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
9 direction = sys.argv[ -3 ] |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
10 tmp_output_path = sys.argv[ -2 ] |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
11 output_datatype = sys.argv[ -1 ] |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
12 |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
13 # Open the input image file. |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
14 input_image_plus = IJ.openImage( input ) |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
15 |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
16 # Create a copy of the image. |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
17 input_image_plus_copy = input_image_plus.duplicate() |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
18 image_processor_copy = input_image_plus_copy.getProcessor() |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
19 |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
20 try: |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
21 # Run the command. |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
22 IJ.run( input_image_plus_copy, direction, "" ) |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
23 # Save the ImagePlus object as a new image. |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
24 IJ.saveAs( input_image_plus_copy, output_datatype, tmp_output_path ) |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
25 except Exception, e: |
|
42e645a20a6e
planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
iuc
parents:
diff
changeset
|
26 jython_utils.handle_error( error_log, str( e ) ) |
