Пример #1
0
def end_point_sb_data(
    skf,
    labels,
    tags=[],
    active=False,
    color="#FFFFFF",
    voxel_resolution=GUIDEBOOK_EXPECTED_RESOLUTION,
    omit_indices=[],
):
    points = sb.PointMapper(point_column="ep_locs", set_position=active)
    ep_layer = sb.AnnotationLayerConfig("end_points",
                                        mapping_rules=points,
                                        active=active,
                                        color=color,
                                        tags=tags)
    sb_ep = sb.StateBuilder(layers=[ep_layer], resolution=voxel_resolution)

    eps = skf.end_points_undirected
    eps = eps[~np.isin(eps, omit_indices)]
    ep_lbls = labels[eps]

    ep_df = pd.DataFrame({
        "eps":
        eps,
        "ep_locs": (skf.vertices[eps] / np.array(voxel_resolution)).tolist(),
        "dfr":
        skf.distance_to_root[eps],
        "ep_group":
        ep_lbls,
    })

    return sb_ep, ep_df.sort_values(by=["ep_group", "dfr"])
Пример #2
0
def branch_sb_data(client,
                   oid,
                   skf,
                   labels=None,
                   tags=[],
                   set_position=False,
                   active=False,
                   color='#299bff'):
    points_bp = sb.PointMapper(point_column='bp_locs',
                               group_column='bp_group',
                               set_position=set_position)
    bp_layer = sb.AnnotationLayerConfig('branch_points',
                                        mapping_rules=points_bp,
                                        active=active,
                                        color=color,
                                        tags=tags)
    sb_bp = sb.StateBuilder(layers=[bp_layer], view_kws={'layout': '3d'})

    bps = skf.branch_points_undirected
    if labels is None:
        labels = np.ones(len(skf.vertices))
    bp_lbls = labels[bps]

    bp_df = pd.DataFrame({
        'bps':
        bps,
        'bp_locs': (skf.vertices[bps] / np.array([4, 4, 40])).tolist(),
        'dfr':
        skf.distance_to_root[bps],
        'bp_group':
        bp_lbls
    })

    return sb_bp, bp_df.sort_values(by=['bp_group', 'dfr'])
Пример #3
0
def end_point_sb_data(client,
                      oid,
                      skf,
                      labels,
                      tags=[],
                      active=False,
                      color='#299bff'):
    points = sb.PointMapper(point_column='ep_locs',
                            group_column='ep_group',
                            set_position=active)
    ep_layer = sb.AnnotationLayerConfig('branch_points',
                                        mapping_rules=points,
                                        active=active,
                                        color=color,
                                        tags=tags)
    sb_ep = sb.StateBuilder(layers=[ep_layer])

    eps = skf.end_points_undirected
    ep_lbls = labels[eps]

    ep_df = pd.DataFrame({
        'eps':
        eps,
        'ep_locs': (skf.vertices[eps] / np.array([4, 4, 40])).tolist(),
        'dfr':
        skf.distance_to_root[eps],
        'ep_group':
        ep_lbls
    })

    return sb_ep, ep_df.sort_values(by=['ep_group', 'dfr'])
Пример #4
0
def proofer_statebuilder(oid,
                         client,
                         root_pt=None,
                         bp_proofreading_tags=[],
                         ep_proofreading_tags=[],
                         bp_active=False):

    state_server = client.state.state_service_endpoint
    img = sb.ImageLayerConfig(client.info.image_source(),
                              contrast_controls=True,
                              black=0.35,
                              white=0.7)
    seg = sb.SegmentationLayerConfig(client.info.segmentation_source(),
                                     fixed_ids=[oid],
                                     view_kws={
                                         'alpha_selected': 0.2,
                                         'alpha_3d': 0.6
                                     })

    points_bp = sb.PointMapper(point_column='bp_locs',
                               group_column='bp_group',
                               set_position=bp_active)
    bp_layer = sb.AnnotationLayerConfig('branch_points',
                                        mapping_rules=points_bp,
                                        active=True,
                                        color='#299bff',
                                        tags=bp_proofreading_tags)

    points_ep = sb.PointMapper(point_column='ep_locs')
    ep_layer = sb.AnnotationLayerConfig('end_points',
                                        mapping_rules=points_ep,
                                        color='#ffffff',
                                        tags=ep_proofreading_tags)

    if root_pt is not None:
        view_kws = {'position': root_pt}
    else:
        view_kws = {}

    sb_ep = sb.StateBuilder(layers=[img, seg, ep_layer],
                            state_server=state_server,
                            view_kws=view_kws)
    sb_bp = sb.StateBuilder(layers=[bp_layer], view_kws={'layout': '3d'})

    sb_all = sb.ChainedStateBuilder([sb_ep, sb_bp])

    return sb_all
Пример #5
0
def make_statebuilder():
    image_layer = statebuilder.ImageLayerConfig(
        name='EM',
        source=
        'precomputed://gs://neuroglancer/pinky100_v0/son_of_alignment_v15_rechunked'
    )
    seg_layer = statebuilder.SegmentationLayerConfig(
        name='layer23',
        source='precomputed://gs://microns_public_datasets/pinky100_v185/seg',
        selected_ids_column='pt_root_id')
    points = statebuilder.PointMapper('pt_position')
    anno_layer = statebuilder.AnnotationLayerConfig(name='annos',
                                                    mapping_rules=points)
    return statebuilder.StateBuilder([image_layer, seg_layer, anno_layer])
Пример #6
0
def root_sb_data(sk,
                 set_position=False,
                 active=False,
                 layer_name='root',
                 voxel_resolution=[4, 4, 40]):
    pt = sb.PointMapper(point_column='pt', set_position=set_position)
    root_layer = sb.AnnotationLayerConfig(layer_name,
                                          color='#bfae00',
                                          mapping_rules=[pt],
                                          active=active)
    root_sb = sb.StateBuilder([root_layer])
    root_df = pd.DataFrame({
        'pt': (np.atleast_2d(sk.vertices[sk.root]) /
               np.array(voxel_resolution)).tolist(),
    })
    return root_sb, root_df
Пример #7
0
def lvl2_statebuilder(datastack, root_id):
    client = FrameworkClient(datastack)
    img = sb.ImageLayerConfig(client.info.image_source(),
                              contrast_controls=True,
                              black=0.35,
                              white=0.66)
    seg = sb.SegmentationLayerConfig(client.info.segmentation_source(),
                                     fixed_ids=[root_id])

    anno = sb.AnnotationLayerConfig('branch_points',
                                    mapping_rules=sb.PointMapper(),
                                    array_data=True,
                                    active=True)
    bp_statebuilder = sb.StateBuilder([img, seg, anno],
                                      url_prefix=client.info.viewer_site())
    return bp_statebuilder
Пример #8
0
def selection_point_sb_data(
    selection_point,
    direction,
    active=False,
    color="#FF2200",
    voxel_resolution=GUIDEBOOK_EXPECTED_RESOLUTION,
):
    points = sb.PointMapper(point_column="pt_locs", set_position=active)
    sp_layer = sb.AnnotationLayerConfig(
        f"{direction}_point",
        mapping_rules=points,
        active=active,
        color=color,
    )
    sb_sp = sb.StateBuilder(layers=[sp_layer], resolution=voxel_resolution)
    pts = np.atleast_2d(selection_point)
    sp_df = pd.DataFrame({
        "pt_locs": pts.tolist(),
    })
    return sb_sp, sp_df
Пример #9
0
def root_sb_data(
    sk,
    set_position=False,
    active=False,
    layer_name="root",
    voxel_resolution=GUIDEBOOK_EXPECTED_RESOLUTION,
):
    pt = sb.PointMapper(point_column="pt", set_position=set_position)
    root_layer = sb.AnnotationLayerConfig(layer_name,
                                          color="#bfae00",
                                          mapping_rules=[pt],
                                          active=active)
    root_point = sk._rooted.vertices[
        sk._rooted.root]  # Works even if root is not in the skeleton mask
    root_sb = sb.StateBuilder([root_layer],
                              resolution=GUIDEBOOK_EXPECTED_RESOLUTION)
    root_df = pd.DataFrame({
        "pt":
        (np.atleast_2d(root_point) / np.array(voxel_resolution)).tolist(),
    })
    return root_sb, root_df
Пример #10
0
def branch_sb_data(
    skf,
    labels=None,
    tags=[],
    set_position=False,
    active=False,
    color="#299bff",
    voxel_resolution=GUIDEBOOK_EXPECTED_RESOLUTION,
):
    points_bp = sb.PointMapper(point_column="bp_locs",
                               group_column="bp_group",
                               set_position=set_position)
    bp_layer = sb.AnnotationLayerConfig("branch_points",
                                        mapping_rules=points_bp,
                                        active=active,
                                        color=color,
                                        tags=tags)
    sb_bp = sb.StateBuilder(
        layers=[bp_layer],
        view_kws={"layout": "3d"},
        resolution=voxel_resolution,
    )

    bps = skf.branch_points_undirected
    if labels is None:
        labels = np.ones(len(skf.vertices))
    bp_lbls = labels[bps]

    bp_df = pd.DataFrame({
        "bps":
        bps,
        "bp_locs": (skf.vertices[bps] / np.array(voxel_resolution)).tolist(),
        "dfr":
        skf.distance_to_root[bps],
        "bp_group":
        bp_lbls,
    })

    return sb_bp, bp_df.sort_values(by=["bp_group", "dfr"])