comparison imagej2_create_image.py @ 4:48f25b8408e1 draft

planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
author iuc
date Wed, 26 Aug 2015 14:37:18 -0400
parents bb65623b90a8
children
comparison
equal deleted inserted replaced
3:bb65623b90a8 4:48f25b8408e1
11 parser.add_argument( '--width', dest='width', type=int, help='Image width in pixels' ) 11 parser.add_argument( '--width', dest='width', type=int, help='Image width in pixels' )
12 parser.add_argument( '--height', dest='height', type=int, help='Image height in pixels' ) 12 parser.add_argument( '--height', dest='height', type=int, help='Image height in pixels' )
13 parser.add_argument( '--depth', dest='depth', type=int, help='Image depth (specifies the number of stack slices)' ) 13 parser.add_argument( '--depth', dest='depth', type=int, help='Image depth (specifies the number of stack slices)' )
14 parser.add_argument( '--image_type', dest='image_type', help='Image type' ) 14 parser.add_argument( '--image_type', dest='image_type', help='Image type' )
15 parser.add_argument( '--image_title', dest='image_title', default='', help='Image title' ) 15 parser.add_argument( '--image_title', dest='image_title', default='', help='Image title' )
16 parser.add_argument( '--max_heap_size_type', dest='max_heap_size_type', help='Type (default or megabytes) of max_heap_size value' )
17 parser.add_argument( '--max_heap_size', dest='max_heap_size', help='Maximum size of the memory allocation pool used by the JVM.' )
18 parser.add_argument( '--output_datatype', dest='output_datatype', help='Output image format' ) 16 parser.add_argument( '--output_datatype', dest='output_datatype', help='Output image format' )
19 parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' ) 17 parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' )
20 parser.add_argument( '--out_fname', help='Path to the output file' ) 18 parser.add_argument( '--out_fname', help='Path to the output file' )
21 args = parser.parse_args() 19 args = parser.parse_args()
22 20
23 tmp_dir = imagej2_base_utils.get_temp_dir() 21 tmp_dir = imagej2_base_utils.get_temp_dir()
24 tmp_image_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.output_datatype ) 22 tmp_image_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.output_datatype )
25 # Set the size of the memory allocation pool used by the JVM.
26 memory_size = imagej2_base_utils.get_max_heap_size_value( args.max_heap_size_type, args.max_heap_size )
27 23
28 # Define command response buffers. 24 # Define command response buffers.
29 tmp_out = tempfile.NamedTemporaryFile().name 25 tmp_out = tempfile.NamedTemporaryFile().name
30 tmp_stdout = open( tmp_out, 'wb' ) 26 tmp_stdout = open( tmp_out, 'wb' )
31 tmp_err = tempfile.NamedTemporaryFile().name 27 tmp_err = tempfile.NamedTemporaryFile().name
32 tmp_stderr = open( tmp_err, 'wb' ) 28 tmp_stderr = open( tmp_err, 'wb' )
33 # Build the command line. 29 # Build the command line.
34 cmd = imagej2_base_utils.get_base_command_imagej2( memory_size, jython_script=args.jython_script ) 30 cmd = imagej2_base_utils.get_base_command_imagej2( None, jython_script=args.jython_script )
35 if cmd is None: 31 if cmd is None:
36 imagej2_base_utils.stop_err( "ImageJ not found!" ) 32 imagej2_base_utils.stop_err( "ImageJ not found!" )
37 cmd += ' %s %d %d %d %s %s' % ( args.image_title, args.width, args.height, args.depth, args.image_type, tmp_image_path ) 33 cmd += ' %s %d %d %d %s %s' % ( args.image_title, args.width, args.height, args.depth, args.image_type, tmp_image_path )
38 proc = subprocess.Popen( args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True ) 34 proc = subprocess.Popen( args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True )
39 rc = proc.wait() 35 rc = proc.wait()