tmp_dir = imagej2_base_utils.get_temp_dir() # ImageJ expects valid image file extensions, so the Galaxy .dat extension does not # work for some features. The following creates a symlink with an appropriate file # extension that points to the Galaxy dataset. This symlink is used by ImageJ. tmp_input_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.input, args.input_datatype ) tmp_output_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.output_datatype ) # Define command response buffers. tmp_out = tempfile.NamedTemporaryFile().name tmp_stdout = open( tmp_out, 'wb' ) tmp_err = tempfile.NamedTemporaryFile().name tmp_stderr = open( tmp_err, 'wb' ) # Java writes a lot of stuff to stderr, so we'll specify a file for handling actual errors. error_log = tempfile.NamedTemporaryFile( delete=False ).name # Build the command line. cmd = imagej2_base_utils.get_base_command_imagej2( None, jython_script=args.jython_script ) if cmd is None: imagej2_base_utils.stop_err( "ImageJ not found!" ) cmd += ' %s' % error_log cmd += ' %s' % tmp_input_path cmd += ' %.3f' % args.threshold_min cmd += ' %.3f' % args.threshold_max cmd += ' %s' % args.method cmd += ' %s' % args.display cmd += ' %s' % args.black_background cmd += ' %s' % args.stack_histogram cmd += ' %s' % tmp_output_path cmd += ' %s' % args.output_datatype # Run the command. proc = subprocess.Popen( args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True ) rc = proc.wait()
# ImageJ expects valid image file extensions, so the Galaxy .dat extension does not # work for some features. The following creates a symlink with an appropriate file # extension that points to the Galaxy dataset. This symlink is used by ImageJ. tmp_input_path = imagej2_base_utils.get_input_image_path(tmp_dir, args.input, args.input_datatype) tmp_output_path = imagej2_base_utils.get_temporary_image_path(tmp_dir, args.output_datatype) # Set the size of the memory allocation pool used by the JVM. memory_size = imagej2_base_utils.get_max_heap_size_value(args.max_heap_size_type, args.max_heap_size) # Define command response buffers. tmp_out = tempfile.NamedTemporaryFile().name tmp_stdout = open(tmp_out, "wb") tmp_err = tempfile.NamedTemporaryFile().name tmp_stderr = open(tmp_err, "wb") # Java writes a lot of stuff to stderr, so we'll specify a file for handling actual errors. error_log = tempfile.NamedTemporaryFile(delete=False).name # Build the command line. cmd = imagej2_base_utils.get_base_command_imagej2(memory_size, jython_script=args.jython_script) if cmd is None: imagej2_base_utils.stop_err("ImageJ not found!") cmd += " %s" % error_log cmd += " %s" % tmp_input_path cmd += " %s" % tmp_output_path cmd += " %s" % args.output_datatype # Run the command. proc = subprocess.Popen(args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True) rc = proc.wait() # Handle execution errors. if rc != 0: error_message = imagej2_base_utils.get_stderr_exception(tmp_err, tmp_stderr, tmp_out, tmp_stdout) imagej2_base_utils.stop_err(error_message) # Handle processing errors. if os.path.getsize(error_log) > 0: