示例#1
0
This tool can be used to alter contours by rotating or rescaling them, or by
changing the ordering of their points.
If the contours have landmark points, these points can be re-weighted by this
tool. (See the documentation for add_landmarks for more details.)
"""

import celltool.utility.optparse as optparse
import celltool.simple_interface as simple_interface
import celltool.utility.path as path
import cli_tools

usage = "usage: %prog [options] contour_1 ... contour_n"

parser = optparse.OptionParser(usage=usage,
                               description=__doc__.strip(),
                               formatter=cli_tools.CelltoolFormatter())
parser.set_defaults(show_progress=True, destination='.')
parser.add_option('-q',
                  '--quiet',
                  action='store_false',
                  dest='show_progress',
                  help='suppress progress bars and other status updates')
parser.add_option(
    '-r',
    '--rotate',
    type='float',
    metavar='ANGLE',
    help='rotate each contour counter-clockwise by ANGLE (in degrees)')
parser.add_option('-s',
                  '--scale',
示例#2
0
    '--begin',
    type='int',
    metavar='POINT',
    help=
    'contour position at which to start measurements [if not specified, contour start]'
)
end_option = optparse.make_option(
    '-e',
    '--end',
    type='int',
    metavar='POINT',
    help=
    'contour position at which to end measurements [if not specified, contour end]'
)

begin_end_parser = optparse.OptionParser(
    option_list=[begin_option, end_option])


def begin_end_handler(option, opt_str, value, parser, measurement):
    begin_end_parser.prog = opt_str
    arguments = _find_arguments(parser)
    options, args = begin_end_parser.parse_args(arguments)
    if len(args) != 0:
        raise optparse.OptionValueError(
            'Measurement "%s" does not take any positional arguments.' %
            opt_str)
    # Transform (begin, end) from a one-indexed, inclusive range (normal for humans)
    # to a zero-indexed inclusive range.
    if options.begin is not None:
        options.begin -= 1
    if options.end is not None: