Example #1
0
def test_egl_and_osmesa_sawp_and_equivalence():
    from syconn import global_params
    global_params.config['pyopengl_platform'] = 'egl'
    from syconn.proc.ssd_assembly import init_sso_from_kzip
    from syconn.proc.rendering import render_sso_coords, \
        render_sso_coords_index_views
    import os
    import numpy as np
    fname = os.path.dirname(__file__) + '/renderexample.k.zip'
    assert os.path.isfile(fname)
    ssv = init_sso_from_kzip(fname, sso_id=1)
    rendering_locations = np.concatenate(ssv.sample_locations())
    index_views = render_sso_coords_index_views(ssv,
                                                rendering_locations,
                                                verbose=True)
    raw_views = render_sso_coords(ssv, rendering_locations, verbose=True)

    global_params.config['pyopengl_platform'] = 'osmesa'
    index_views_osmesa = render_sso_coords_index_views(ssv,
                                                       rendering_locations,
                                                       verbose=True)
    raw_views_osmesa = render_sso_coords(ssv,
                                         rendering_locations,
                                         verbose=True)
    nb_of_pixels = np.prod(raw_views.shape)
    # fraction of different vertex indices must be below 1 out of 100k
    assert np.sum(index_views != index_views_osmesa) / nb_of_pixels < 1e-5
    # maximum deviation of depth value must be smaller
    assert np.max(((raw_views - raw_views_osmesa)**2)**0.5) == 1
    # affected pixels must be below 0.05
    assert np.sum(raw_views != raw_views_osmesa) / nb_of_pixels < 0.05
Example #2
0
def test_raw_and_index_rendering_egl():
    from syconn import global_params
    global_params.config['pyopengl_platform'] = 'egl'
    from syconn.proc.ssd_assembly import init_sso_from_kzip
    from syconn.proc.rendering import render_sso_coords, \
        render_sso_coords_index_views
    import os
    import numpy as np
    fname = os.path.dirname(__file__) + '/renderexample.k.zip'
    assert os.path.isfile(fname)
    ssv = init_sso_from_kzip(fname, sso_id=1)
    rendering_locations = np.concatenate(ssv.sample_locations())
    index_views = render_sso_coords_index_views(ssv,
                                                rendering_locations,
                                                verbose=True)
    raw_views = render_sso_coords(ssv, rendering_locations, verbose=True)
    assert len(index_views) == len(raw_views)
Example #3
0
    # path to working directory of example cube - required to load pretrained models
    path_to_workingdir = os.path.expanduser(args.working_dir)

    # path to cell reconstruction k.zip
    cell_kzip_fn = os.path.abspath(os.path.expanduser(args.kzip))
    if not os.path.isfile(cell_kzip_fn):
        raise FileNotFoundError
    # set working directory to obtain models
    global_params.wd = path_to_workingdir

    # get model for spine detection
    m = get_semseg_spiness_model()

    # load SSO instance from k.zip file
    sso = init_sso_from_kzip(cell_kzip_fn, sso_id=1)

    # run prediction and store result in new kzip
    cell_kzip_fn_spines = cell_kzip_fn[:-6] + '_spines.k.zip'
    semseg_of_sso_nocache(sso,
                          dest_path=cell_kzip_fn_spines,
                          verbose=True,
                          semseg_key="spinesstest",
                          k=0,
                          ws=(256, 128),
                          model=m,
                          nb_views=2,
                          comp_window=8e3)
    node_preds = sso.semseg_for_coords(sso.skeleton['nodes'], "spinesstest",
                                       **global_params.semseg2coords_spines)
    sso.skeleton["spinesstest"] = node_preds
Example #4
0
        help='path to kzip file which contains a cell reconstruction (see '
        'SuperSegmentationObject().export2kzip())')
    args = parser.parse_args()

    # path to working directory of example cube - required to load pretrained models
    path_to_workingdir = os.path.expanduser(args.working_dir)

    # path to cell reconstruction k.zip
    cell_kzip_fn = os.path.expanduser(args.kzip)

    # set working directory to obtain models
    global_params.wd = path_to_workingdir

    # get model for spine detection
    m = get_semseg_spiness_model()

    # load SSO instance from k.zip file
    sso = init_sso_from_kzip(cell_kzip_fn)

    # run prediction and store result in new kzip
    cell_kzip_fn_spines = cell_kzip_fn[:-6] + '_spines.k.zip'
    semseg_of_sso_nocache(sso,
                          dest_path=cell_kzip_fn_spines,
                          semseg_key="spinesstest",
                          n_avg=5,
                          ws=(256, 128),
                          model=m,
                          nb_views=2,
                          comp_window=8e3,
                          verbose=True)