comparison jython_utils.py @ 2:6f129c1ec6d1 draft

planemo upload commit 98c34e070343a117019ffd25a3af117808159bf5-dirty
author iuc
date Tue, 04 Aug 2015 13:21:24 -0400
parents 64aacdf3171f
children 2a8118c2ec03
comparison
equal deleted inserted replaced
1:0ff301860507 2:6f129c1ec6d1
1 import imagej2_base_utils 1 import imagej2_base_utils
2 from ij import IJ 2 from ij import IJ
3
4 IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES = { '0':'GRAY8', '1':'GRAY16', '2':'GRAY32',
5 '3':'COLOR_256', '4':'COLOR_RGB' }
3 6
4 def convert_before_saving_as_tiff( image_plus ): 7 def convert_before_saving_as_tiff( image_plus ):
5 # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3 8 # The bUnwarpJ plug-in produces TIFF image stacks consisting of 3
6 # slices which can be viewed in ImageJ. The 3 slices are: 1) the 9 # slices which can be viewed in ImageJ. The 3 slices are: 1) the
7 # registered image, 2) the target image and 3) the black/white warp 10 # registered image, 2) the target image and 3) the black/white warp
20 # and I have yet to discover it. 23 # and I have yet to discover it.
21 tmp_dir = imagej2_base_utils.get_temp_dir() 24 tmp_dir = imagej2_base_utils.get_temp_dir()
22 tmp_out_png_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'png' ) 25 tmp_out_png_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'png' )
23 IJ.saveAs( image_plus, 'png', tmp_out_png_path ) 26 IJ.saveAs( image_plus, 'png', tmp_out_png_path )
24 return IJ.openImage( tmp_out_png_path ) 27 return IJ.openImage( tmp_out_png_path )
28
29 def get_display_image_type( image_type ):
30 return IMAGE_PLUS_IMAGE_TYPE_FIELD_VALUES.get( str( image_type ), None )
31
32 def handle_error( error_log, msg ):
33 # Java writes a lot of stuff to stderr, so the received error_log
34 # will log actual errors.
35 elh = open( error_log, 'wb' )
36 elh.write( msg )
37 elh.close()