Mercurial > repos > iuc > imagej2_noise
comparison jython_script.py @ 2:c8fc3f34cbff draft
planemo upload commit 8f8692e83217a072a3ed928469621f1f606ab28a-dirty
| author | iuc |
|---|---|
| date | Tue, 04 Aug 2015 11:15:16 -0400 |
| parents | da9a450c85b7 |
| children | d99cf938ad41 |
comparison
equal
deleted
inserted
replaced
| 1:1af4f60294c3 | 2:c8fc3f34cbff |
|---|---|
| 1 import sys | 1 import sys |
| 2 from ij import IJ | 2 from ij import IJ |
| 3 from ij import ImagePlus | 3 from ij import ImagePlus |
| 4 | 4 import jython_utils |
| 5 def handle_error( error_log, msg ): | |
| 6 elh = open( error_log, 'wb' ) | |
| 7 elh.write( msg ) | |
| 8 elh.close() | |
| 9 | 5 |
| 10 # Fiji Jython interpreter implements Python 2.5 which does not | 6 # Fiji Jython interpreter implements Python 2.5 which does not |
| 11 # provide support for argparse. | 7 # provide support for argparse. |
| 12 error_log = sys.argv[ -19 ] | 8 error_log = sys.argv[ -19 ] |
| 13 input = sys.argv[ -18 ] | 9 input = sys.argv[ -18 ] |
| 60 else: | 56 else: |
| 61 # When Galaxy metadata for images is enhanced to include information like this, | 57 # When Galaxy metadata for images is enhanced to include information like this, |
| 62 # we'll be able to write tool validators rather than having to stop the job in | 58 # we'll be able to write tool validators rather than having to stop the job in |
| 63 # an error state. | 59 # an error state. |
| 64 msg = "Remove NaNs requires a 32-bit image, the selected image is %d-bit" % bit_depth | 60 msg = "Remove NaNs requires a 32-bit image, the selected image is %d-bit" % bit_depth |
| 65 handle_error( error_log, msg ) | 61 jython_utils.handle_error( error_log, msg ) |
| 66 error = True | 62 error = True |
| 67 elif noise == 'rof_denoise': | 63 elif noise == 'rof_denoise': |
| 68 if image_type == ImagePlus.GRAY32: | 64 if image_type == ImagePlus.GRAY32: |
| 69 IJ.run( image_plus_copy, "ROF Denoise", "" ) | 65 IJ.run( image_plus_copy, "ROF Denoise", "" ) |
| 70 else: | 66 else: |
| 71 msg = "ROF Denoise requires an image of type 32-bit grayscale, the selected image is %d-bit" % ( bit_depth ) | 67 msg = "ROF Denoise requires an image of type 32-bit grayscale, the selected image is %d-bit" % ( bit_depth ) |
| 72 handle_error( error_log, msg ) | 68 jython_utils.handle_error( error_log, msg ) |
| 73 error = True | 69 error = True |
| 74 elif noise == 'randomj': | 70 elif noise == 'randomj': |
| 75 if randomj == 'randomj_binomial': | 71 if randomj == 'randomj_binomial': |
| 76 IJ.run( image_plus_copy, "RandomJ Binomial", "trials=&trials probability=&probability insertion=&insertion" ) | 72 IJ.run( image_plus_copy, "RandomJ Binomial", "trials=&trials probability=&probability insertion=&insertion" ) |
| 77 elif randomj == 'randomj_exponential': | 73 elif randomj == 'randomj_exponential': |
