Пример #1
0
parser.add_argument( '--threshold_min', dest='threshold_min', type=float, help='Minimum threshold value' )
parser.add_argument( '--threshold_max', dest='threshold_max', type=float, help='Maximum threshold value' )
parser.add_argument( '--method', dest='method', help='Threshold method' )
parser.add_argument( '--display', dest='display', help='Display mode' )
parser.add_argument( '--black_background', dest='black_background', help='Black background' )
parser.add_argument( '--stack_histogram', dest='stack_histogram', help='Stack histogram' )
parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' )
parser.add_argument( '--output', dest='output', help='Path to the output file' )
parser.add_argument( '--output_datatype', dest='output_datatype', help='Datatype of the output image' )
args = parser.parse_args()

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
import imagej2_base_utils

# Parse Command Line.
parser = argparse.ArgumentParser()
parser.add_argument( '--source_image', dest='source_image', help='Source image' )
parser.add_argument( '--source_image_format', dest='source_image_format', help='Source image format' )
parser.add_argument( '--target_image', dest='target_image', help='Target image' )
parser.add_argument( '--target_image_format', dest='target_image_format', help='Target image format' )
parser.add_argument( '--source_elastic_transformation', dest='source_elastic_transformation', help='Direct source transformation matrix' )
parser.add_argument( '--target_raw_transformation', dest='target_raw_transformation', help='Inverse target transformation matrix' )
parser.add_argument( '--output', dest='output', help='Warping index' )

args = parser.parse_args()

tmp_dir = imagej2_base_utils.get_temp_dir()
source_image_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.source_image, args.source_image_format )
target_image_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.target_image, args.target_image_format )
source_elastic_transformation_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.source_elastic_transformation, 'txt' )
target_raw_transformation_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.target_raw_transformation, 'txt' )

# 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' )

# Build the command line to compose the raw and elastic transformations.
cmd = imagej2_base_utils.get_base_cmd_bunwarpj( None )
if cmd is None:
    imagej2_base_utils.stop_err( "bUnwarpJ not found!" )
cmd += ' -compose_raw_elastic'
Пример #3
0
parser.add_argument( '--source_out_datatype', help='Output registered source image format' )
parser.add_argument( '--target_out', default=None, help='Output target image' )
parser.add_argument( '--target_out_datatype', default=None, help='Output registered target image format' )
parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' )
parser.add_argument( '--max_heap_size_type', dest='max_heap_size_type', help='Type (default or megabytes) of max_heap_size value' )
parser.add_argument( '--max_heap_size', dest='max_heap_size', help='Maximum size of the memory allocation pool used by the JVM.' )

args = parser.parse_args()

if args.source_trans_out is not None and args.target_trans_out is not None:
    save_transformation = True
else:
    save_transformation = False

tmp_dir = imagej2_base_utils.get_temp_dir()
source_image_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.source_image, args.source_image_format )
tmp_source_out_tiff_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'tiff' )
tmp_source_out_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.source_out_datatype )
target_image_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.target_image, args.target_image_format )
if not args.mono:
    tmp_target_out_tiff_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, 'tiff' )
    tmp_target_out_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.target_out_datatype )
if args.source_mask is not None and args.target_mask is not None:
    tmp_source_mask_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.source_mask, args.source_mask_format )
    tmp_target_mask_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.target_mask, args.target_mask_format )
if save_transformation:
    # bUnwarpJ automatically names the transformation files based on the names
    # of the source and target image file names.  We've defined symlinks to 
    # temporary files with valid image extensions since ImageJ does not handle
    # the Galaxy "dataset.dat" file extensions.
    source_file_name = imagej2_base_utils.get_file_name_without_extension( tmp_source_out_tiff_path )
)
parser.add_argument(
    "--source_raw_transformation", dest="source_raw_transformation", help="Source raw transformation matrix"
)
parser.add_argument(
    "--max_heap_size_type", dest="max_heap_size_type", help="Type (default or megabytes) of max_heap_size value"
)
parser.add_argument(
    "--max_heap_size", dest="max_heap_size", help="Maximum size of the memory allocation pool used by the JVM."
)
parser.add_argument("--output", dest="output", help="Warping index")

args = parser.parse_args()

tmp_dir = imagej2_base_utils.get_temp_dir()
source_image_path = imagej2_base_utils.get_input_image_path(tmp_dir, args.source_image, args.source_image_format)
target_image_path = imagej2_base_utils.get_input_image_path(tmp_dir, args.target_image, args.target_image_format)
target_elastic_transformation_path = imagej2_base_utils.get_input_image_path(
    tmp_dir, args.target_elastic_transformation, "txt"
)
source_raw_transformation_path = imagej2_base_utils.get_input_image_path(tmp_dir, args.source_raw_transformation, "txt")
# bUnwarpJ produces several lines of output that we need to discard, so
# we'll use a temporary output file from which we'll read only the last line.
tmp_output_path = imagej2_base_utils.get_input_image_path(tmp_dir, args.output, "txt")

# 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")
# Parse Command Line.
parser = argparse.ArgumentParser()
parser.add_argument( '--source_image', dest='source_image', help='Source image' )
parser.add_argument( '--source_image_format', dest='source_image_format', help='Source image format' )
parser.add_argument( '--target_image', dest='target_image', help='Target image' )
parser.add_argument( '--target_image_format', dest='target_image_format', help='Target image format' )
parser.add_argument( '--source_transformation', dest='source_transformation', help='Direct source transformation matrix' )
parser.add_argument( '--target_transformation', dest='target_transformation', help='Inverse target transformation matrix' )
parser.add_argument( '--max_heap_size_type', dest='max_heap_size_type', help='Type (default or megabytes) of max_heap_size value' )
parser.add_argument( '--max_heap_size', dest='max_heap_size', help='Maximum size of the memory allocation pool used by the JVM.' )
parser.add_argument( '--output', dest='output', help='Warping index' )

args = parser.parse_args()

tmp_dir = imagej2_base_utils.get_temp_dir()
source_image_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.source_image, args.source_image_format )
target_image_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.target_image, args.target_image_format )
source_transformation_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.source_transformation, 'txt' )
target_transformation_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.target_transformation, 'txt' )
# bUnwarpJ produces several lines of output that we need to discard, so
# we'll use a temporary output file from which we'll read only the last line.
tmp_output_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.output, 'txt' )

# 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' )
parser.add_argument('--target_image', dest='target_image', help='Target image')
parser.add_argument('--target_image_format',
                    dest='target_image_format',
                    help='Target image format')
parser.add_argument('--source_transformation',
                    dest='source_transformation',
                    help='Direct source transformation matrix')
parser.add_argument('--target_transformation',
                    dest='target_transformation',
                    help='Inverse target transformation matrix')
parser.add_argument('--output', dest='output', help='Warping index')

args = parser.parse_args()

tmp_dir = imagej2_base_utils.get_temp_dir()
source_image_path = imagej2_base_utils.get_input_image_path(
    tmp_dir, args.source_image, args.source_image_format)
target_image_path = imagej2_base_utils.get_input_image_path(
    tmp_dir, args.target_image, args.target_image_format)
source_transformation_path = imagej2_base_utils.get_input_image_path(
    tmp_dir, args.source_transformation, 'txt')
target_transformation_path = imagej2_base_utils.get_input_image_path(
    tmp_dir, args.target_transformation, 'txt')
# bUnwarpJ produces several lines of output that we need to discard, so
# we'll use a temporary output file from which we'll read only the last line.
tmp_output_path = imagej2_base_utils.get_input_image_path(
    tmp_dir, args.output, 'txt')

# Define command response buffers.
tmp_out = tempfile.NamedTemporaryFile().name
tmp_stdout = open(tmp_out, 'wb')
tmp_err = tempfile.NamedTemporaryFile().name