예제 #1
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    contours = simple_interface.load_contours(args, show_progress = options.show_progress)
    if options.grid:
        contours = simple_interface.grid_contours(contours)
# 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:
        options.end -= 1
    if options.color_by == 'none':
        gradient_factory = None
    else:
        gradient_factory = plot_tools.default_gradient
    if options.color_by == 'points' or options.begin or options.end or options.label_points:
        # do point ordering plot
        colorbar = options.color_by == 'points'
        color_by_point = options.color_by == 'points'
        # use a color bar if we're doing a gradient        
        plot_tools.point_order_plot(contours, options.output_file, plot_title=options.title, 
            label_points=options.label_points, colorbar=colorbar, begin=options.begin, 
            end=options.end, gradient_factory=gradient_factory, color_by_point=color_by_point,
            scale=options.scale, show_progress=options.show_progress)
    else:
        plot_tools.contour_plot(contours, options.output_file, plot_title=options.title, 
            gradient_factory=gradient_factory, scale=options.scale, show_progress=options.show_progress)
예제 #2
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(
        filenames, show_progress=options.show_progress)
    if options.reference is not None:
        reference = contour_class.from_file(options.reference)
        contours = simple_interface.align_contours_to(
            contours,
            reference,
            align_steps=options.alignment_steps,
            allow_reflection=options.allow_reflection,
            show_progress=options.show_progress)
    else:
        contours = simple_interface.align_contours(
            contours,
            options.alignment_steps,
            options.allow_reflection,
            max_iters=options.max_iterations,
            show_progress=options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
예제 #3
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
    if options.first_point is not None:
        options.first_point -= 1
    if options.scale is not None or options.rotate is not None or options.units is not None or options.first_point is not None:
        in_radians = False
        if options.units is not None and options.units.lower() in ('um', 'micron', 'microns'):
            options.units = '\N{MICRO SIGN}m'
        contours = simple_interface.transform_contours(contours, options.scale, options.rotate, in_radians, 
            options.units, options.first_point, options.show_progress, title = 'Modifying Contours')
    if options.weights is not None:
        contours = simple_interface.reweight_landmarks(contours, options.weights, options.show_progress)
        
    
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
예제 #4
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if options.help:
        print_help()
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    contours = simple_interface.load_contours(args, show_progress = options.show_progress)
    measurements = [m(**kws) for m, kws in options.measurements]
    header, rows = simple_interface.measure_contours(contours, options.show_progress, *measurements)
    datafile.write_data_file([header]+rows, options.output_file)
예제 #5
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    contours = simple_interface.load_contours(args, show_progress = options.show_progress)
    shape_model, header, rows, norm_header, norm_rows = simple_interface.make_shape_model(contours, options.variance_explained)
    shape_model.to_file(options.output_prefix + '.contour')
    if options.write_data:
        datafile.write_data_file([header]+rows, options.output_prefix + '-positions.csv')
        datafile.write_data_file([norm_header]+norm_rows, options.output_prefix + '-normalized-positions.csv')
예제 #6
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.namebase + '.mat' for filename in filenames]
    simple_interface.save_contour_data_for_matlab(contours, names, options.show_progress)
예제 #7
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if options.help:
        print_help()
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    contours = simple_interface.load_contours(
        args, show_progress=options.show_progress)
    measurements = [m(**kws) for m, kws in options.measurements]
    header, rows = simple_interface.measure_contours(contours,
                                                     options.show_progress,
                                                     *measurements)
    datafile.write_data_file([header] + rows, options.output_file)
예제 #8
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(
        filenames, show_progress=options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [
        destination / filename.namebase + '.mat' for filename in filenames
    ]
    simple_interface.save_contour_data_for_matlab(contours, names,
                                                  options.show_progress)
예제 #9
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    contours = simple_interface.load_contours(
        args, show_progress=options.show_progress)
    if options.grid:
        contours = simple_interface.grid_contours(contours)


# 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:
        options.end -= 1
    if options.color_by == 'none':
        gradient_factory = None
    else:
        gradient_factory = plot_tools.default_gradient
    if options.color_by == 'points' or options.begin or options.end or options.label_points:
        # do point ordering plot
        colorbar = options.color_by == 'points'
        color_by_point = options.color_by == 'points'
        # use a color bar if we're doing a gradient
        plot_tools.point_order_plot(contours,
                                    options.output_file,
                                    plot_title=options.title,
                                    label_points=options.label_points,
                                    colorbar=colorbar,
                                    begin=options.begin,
                                    end=options.end,
                                    gradient_factory=gradient_factory,
                                    color_by_point=color_by_point,
                                    scale=options.scale,
                                    show_progress=options.show_progress)
    else:
        plot_tools.contour_plot(contours,
                                options.output_file,
                                plot_title=options.title,
                                gradient_factory=gradient_factory,
                                scale=options.scale,
                                show_progress=options.show_progress)
예제 #10
0
def main(name, arguments):
  parser.prog = name
  options, args = parser.parse_args(arguments)
  args = cli_tools.glob_args(args)
  if len(args) == 0:
    raise ValueError('Some contour files must be specified!')
  filenames = [path.path(arg) for arg in args]
  contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
  if options.endpoints is None:
    endpoints = options.endpoint_method
  else:
    endpoints = options.endpoints
  contours = simple_interface.find_centerlines(contours, options.axis_points, endpoints, options.show_progress)
  destination = path.path(options.destination)
  if not destination.exists():
    destination.makedirs()
  # note that with path objects, the '/' operator means 'join path components.'
  names = [destination / filename.name for filename in filenames]
  simple_interface.save_contours(contours, names, options.show_progress)
예제 #11
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(filenames, show_progress = options.show_progress)
    if options.reference is not None:
        reference = contour_class.from_file(options.reference)
        contours = simple_interface.align_contours_to(contours, reference, align_steps=options.alignment_steps,
            allow_reflection=options.allow_reflection, show_progress=options.show_progress)
    else:
        contours = simple_interface.align_contours(contours, options.alignment_steps, options.allow_reflection,
            max_iters=options.max_iterations, show_progress = options.show_progress)
    destination = path.path(options.destination)
    destination.makedirs_p()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)
예제 #12
0
def main(name, arguments):
    parser.prog = name
    options, args = parser.parse_args(arguments)
    args = cli_tools.glob_args(args)
    if len(args) == 0:
        raise ValueError('Some contour files must be specified!')
    filenames = [path.path(arg) for arg in args]
    contours = simple_interface.load_contours(
        filenames, show_progress=options.show_progress)
    if options.first_point is not None:
        options.first_point -= 1
    if options.scale is not None or options.rotate is not None or options.units is not None or options.first_point is not None:
        in_radians = False
        if options.units is not None and options.units.lower() in ('um',
                                                                   'micron',
                                                                   'microns'):
            options.units = u'\N{MICRO SIGN}m'
        contours = simple_interface.transform_contours(
            contours,
            options.scale,
            options.rotate,
            in_radians,
            options.units,
            options.first_point,
            options.show_progress,
            title='Modifying Contours')
    if options.weights is not None:
        contours = simple_interface.reweight_landmarks(contours,
                                                       options.weights,
                                                       options.show_progress)

    destination = path.path(options.destination)
    if not destination.exists():
        destination.makedirs()
    # note that with path objects, the '/' operator means 'join path components.'
    names = [destination / filename.name for filename in filenames]
    simple_interface.save_contours(contours, names, options.show_progress)