Пример #1
0
def filter_ransac(corr_file, compared_url, out_fname, jar_file, conf=None):
    # When matching layers, no need to take bounding box into account
    conf_args = utils.conf_args_from_file(conf, 'FilterRansac')

    java_cmd = 'java -Xmx3g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.FilterRansac --inputfile {1} --comparedUrl {2} \
            --targetPath {3} {4}'.format(jar_file, utils.path2url(corr_file),
                                         compared_url, out_fname, conf_args)
    utils.execute_shell_command(java_cmd)
def filter_local_smoothness(corr_file, out_fname, jar_file, conf=None):
    # When matching layers, no need to take bounding box into account
    conf_args = utils.conf_args_from_file(conf, 'FilterLocalSmoothness')

    java_cmd = 'java -Xmx3g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.FilterLocalSmoothness --inputfile {1} \
            --targetPath {2} {3}'.format(
        jar_file,
        utils.path2url(corr_file),
        out_fname,
        conf_args)
    utils.execute_shell_command(java_cmd)
def optimize_elastic_transform(correspondence_file, tilespec_file, fixed_tiles, output_file, jar_file, conf_fname=None):

    corr_url = utils.path2url(correspondence_file)
    tiles_url = utils.path2url(tilespec_file)
    conf_args = utils.conf_args_from_file(conf_fname, 'OptimizeMontageElastic')

    fixed_str = ""
    if fixed_tiles != None:
        fixed_str = "--fixedTiles {0}".format(" ".join(map(str, fixed_tiles)))

    java_cmd = 'java -Xmx10g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.OptimizeMontageElastic {1} --corrfile {2} --tilespecfile {3} {4} --targetPath {5}'.format(\
        jar_file, conf_args, corr_url, tiles_url, fixed_str, output_file)
    utils.execute_shell_command(java_cmd)
def match_single_sift_features_and_filter(tiles_file,
                                          features_file1,
                                          features_file2,
                                          jar,
                                          out_fname,
                                          index_pair,
                                          conf_fname=None):
    tiles_url = utils.path2url(os.path.abspath(tiles_file))

    conf_args = utils.conf_args_from_file(conf_fname,
                                          'MatchSiftFeaturesAndFilter')

    java_cmd = 'java -Xmx3g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.MatchSiftFeaturesAndFilter \
            --tilespecfile {1} --featurefile1 {2} --featurefile2 {3} --indices {4} --targetPath {5} {6}'.format(
        jar, tiles_url, features_file1, features_file2,
        "{}:{}".format(index_pair[0], index_pair[1]), out_fname, conf_args)
    utils.execute_shell_command(java_cmd)
def create_layer_sift_features(tiles_fname,
                               out_fname,
                               jar_file,
                               meshes_dir=None,
                               conf=None,
                               threads_num=4):

    meshes_str = ''
    if meshes_dir is not None:
        meshes_str = '--meshesDir "{0}"'.format(meshes_dir)

    tiles_url = utils.path2url(os.path.abspath(tiles_fname))
    conf_args = utils.conf_args_from_file(conf, 'ComputeSiftFeatures')
    # Compute the Sift features `for each tile in the tile spec file
    java_cmd = 'java -Xmx11g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.ComputeLayerSiftFeatures --url {1} --targetPath {2} --threads {3} {4} {5}'.format(\
        jar_file, tiles_url, out_fname, threads_num, meshes_str, conf_args)
    utils.execute_shell_command(java_cmd)
def match_layers_sift_features(tiles_file1,
                               features_file1,
                               tiles_file2,
                               features_file2,
                               out_fname,
                               jar_file,
                               conf=None,
                               threads_num=4):
    # When matching layers, no need to take bounding box into account
    conf_args = utils.conf_args_from_file(conf, 'MatchSiftFeatures')

    java_cmd = 'java -Xmx3g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.MatchLayersSiftFeatures --threads {1} --tilespec1 {2} \
            --featurefile1 {3} --tilespec2 {4} --featurefile2 {5} --targetPath {6} {7}'.format(
        jar_file, threads_num, utils.path2url(tiles_file1),
        utils.path2url(features_file1), utils.path2url(tiles_file2),
        utils.path2url(features_file2), out_fname, conf_args)
    utils.execute_shell_command(java_cmd)
Пример #7
0
def create_sift_features(tiles_fname,
                         out_fname,
                         index,
                         jar_file,
                         conf_fname=None,
                         threads_num=None):

    threads_str = ""
    if threads_num != None:
        threads_str = "--threads {0}".format(threads_num)

    tiles_url = utils.path2url(os.path.abspath(tiles_fname))
    conf_args = utils.conf_args_from_file(conf_fname, 'ComputeSiftFeatures')
    # Compute the Sift features `for each tile in the tile spec file
    java_cmd = 'java -Xmx5g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.ComputeSiftFeatures --index {1} \
                --url {2} --targetPath {3} {4} {5}'                                                   .format(\
        jar_file, index, tiles_url, out_fname, threads_str, conf_args)
    utils.execute_shell_command(java_cmd)
def match_layers_by_max_pmcc(jar_file,
                             tiles_file1,
                             tiles_file2,
                             models_file,
                             image_width,
                             image_height,
                             fixed_layers,
                             out_fname,
                             meshes_dir1=None,
                             meshes_dir2=None,
                             conf=None,
                             threads_num=None,
                             auto_add_model=False):
    conf_args = utils.conf_args_from_file(conf, 'MatchLayersByMaxPMCC')

    meshes_str = ''
    if meshes_dir1 is not None:
        meshes_str += ' --meshesDir1 "{0}"'.format(meshes_dir1)

    if meshes_dir2 is not None:
        meshes_str += ' --meshesDir2 "{0}"'.format(meshes_dir2)

    fixed_str = ""
    if fixed_layers != None:
        fixed_str = "--fixedLayers {0}".format(" ".join(map(str,
                                                            fixed_layers)))

    threads_str = ""
    if threads_num != None:
        threads_str = "--threads {0}".format(threads_num)

    auto_add_model_str = ""
    if auto_add_model:
        auto_add_model_str = "--autoAddModel"

    java_cmd = 'java -Xmx16g -XX:ParallelGCThreads={0} -Djava.awt.headless=true -cp "{1}" org.janelia.alignment.MatchLayersByMaxPMCC --inputfile1 {2} --inputfile2 {3} \
            --modelsfile1 {4} --imageWidth {5} --imageHeight {6} {7} {8} {9} --targetPath {10} {11} {12}'.format(
        utils.get_gc_threads_num(threads_num), jar_file,
        utils.path2url(tiles_file1), utils.path2url(tiles_file2),
        utils.path2url(models_file), int(image_width), int(image_height),
        threads_str, auto_add_model_str, meshes_str, out_fname, fixed_str,
        conf_args)
    utils.execute_shell_command(java_cmd)
Пример #9
0
def main():
    # Command line parser
    parser = argparse.ArgumentParser(
        description=
        'Iterates over the tilespecs in a file, computing matches for each overlapping tile.'
    )
    parser.add_argument('tiles_file',
                        metavar='tiles_file',
                        type=str,
                        help='the json file of tilespecs')
    parser.add_argument('features_file',
                        metavar='features_file',
                        type=str,
                        help='the json file of features')
    parser.add_argument(
        '-o',
        '--output_file',
        type=str,
        help=
        'an output correspondent_spec file, that will include the sift features for each tile (default: ./matches.json)',
        default='./matches.json')
    parser.add_argument(
        '-j',
        '--jar_file',
        type=str,
        help=
        'the jar file that includes the render (default: ../target/render-0.0.1-SNAPSHOT.jar)',
        default='../target/render-0.0.1-SNAPSHOT.jar')
    parser.add_argument(
        '-c',
        '--conf_file_name',
        type=str,
        help=
        'the configuration file with the parameters for each step of the alignment process in json format (uses default parameters, if not supplied)',
        default=None)

    args = parser.parse_args()

    match_sift_features(args.tiles_file, args.features_file, args.output_file, args.jar_file, \
        conf=utils.conf_args_from_file(args.conf_file_name, "MatchSiftFeatures"))
def optimize_layers_affine(tile_files,
                           corr_files,
                           model_files,
                           fixed_layers,
                           out_dir,
                           max_layer_distance,
                           jar_file,
                           conf=None,
                           skip_layers=None,
                           threads_num=4,
                           manual_matches=None):
    conf_args = utils.conf_args_from_file(conf, 'OptimizeLayersAffine')

    fixed_str = ""
    if fixed_layers != None:
        fixed_str = " ".join("--fixedLayers {0}".format(str(fixed_layer))
                             for fixed_layer in fixed_layers)

    skip_str = ""
    if skip_layers != None:
        skip_str = "--skipLayers {0}".format(skip_layers)

    manual_matches_str = ""
    if manual_matches is not None:
        manual_matches_str = " ".join("--manualMatches {}".format(a)
                                      for a in manual_matches)

    # Assuming that at least 4 threads will be allocated for this job, and increasing the number of gc threads to 4 will make it faster
    java_cmd = 'java -Xmx46g -XX:ParallelGCThreads={0} -Djava.awt.headless=true -cp "{1}" org.janelia.alignment.OptimizeLayersAffine --tilespecFiles {2} --corrFiles {3} \
            --modelFiles {4} {5} {6} --threads {7} --maxLayersDistance {8} {9} --targetDir {10} {11}'.format(
        utils.get_gc_threads_num(threads_num), jar_file,
        " ".join(utils.path2url(f) for f in tile_files),
        " ".join(utils.path2url(f) for f in corr_files),
        " ".join(utils.path2url(f)
                 for f in model_files), fixed_str, manual_matches_str,
        threads_num, max_layer_distance, skip_str, out_dir, conf_args)
    utils.execute_shell_command(java_cmd)
def main():
    # Command line parser
    parser = argparse.ArgumentParser(
        description=
        'Executes the block matching parameters testing application.')
    parser.add_argument('--tile_files',
                        metavar='tile_files',
                        type=str,
                        nargs='+',
                        required=True,
                        help='the list of tile spec files to test')
    parser.add_argument(
        '-j',
        '--jar_file',
        type=str,
        help=
        'the jar file that includes the render (default: ../target/render-0.0.1-SNAPSHOT.jar)',
        default='../target/render-0.0.1-SNAPSHOT.jar')
    parser.add_argument(
        '-c',
        '--conf_file_name',
        type=str,
        help=
        'the configuration file with the parameters for each step of the alignment process in json format (uses default parameters, if not supplied)',
        default=None)
    parser.add_argument('-t',
                        '--threads_num',
                        type=int,
                        help='the number of threads to use (default: 1)',
                        default=1)

    args = parser.parse_args()

    print "tile_files: {0}".format(args.tile_files)

    block_matching_test_params(args.tile_files, args.jar_file, \
        conf=utils.conf_args_from_file(args.conf_file_name, "MatchLayersByMaxPMCC"), threads_num=args.threads_num)
Пример #12
0
def match_multiple_pmcc(tiles_file,
                        index_pairs,
                        fixed_tiles,
                        jar,
                        out_fname,
                        conf_fname=None,
                        threads_num=None):
    tiles_url = utils.path2url(os.path.abspath(tiles_file))

    fixed_str = ""
    if fixed_tiles != None:
        fixed_str = "--fixedTiles {0}".format(" ".join(map(str, fixed_tiles)))

    threads_str = ""
    if threads_num != None:
        threads_str = "--threads {0}".format(threads_num)

    conf_args = utils.conf_args_from_file(conf_fname, 'MatchByMaxPMCC')

    java_cmd = 'java -Xmx27g -XX:ParallelGCThreads=1 -Djava.awt.headless=true -cp "{0}" org.janelia.alignment.MatchByMaxPMCC --inputfile {1} {2} {3} {4} --targetPath {5} {6}'.format(
        jar, tiles_url, fixed_str,
        " ".join("--indices {}:{}".format(a, b) for a, b in index_pairs),
        threads_str, out_fname, conf_args)
    utils.execute_shell_command(java_cmd)