Exemplo n.º 1
0
def neuron_graph_from_annotations(annotation_list,
                                  proj_opts,
                                  anno_dict=None,
                                  append_annotations=True):
    # Build a neuron graph from a readable list of annotation strings
    if anno_dict is None:
        anno_dict = ci.get_annotation_dict(proj_opts)

    anno_id_list = list()
    for anno in annotation_list:
        try:
            anno_id_list.append(anno_dict[anno])
        except KeyError:
            print('Not a valid key: ' + anno + ' (skipping)')

    skid_list = ci.get_ids_from_annotation(anno_id_list, proj_opts)
    g = neuron_graph(skid_list, proj_opts)

    if append_annotations:
        g = append_annotation_list(g,
                                   annotation_list,
                                   proj_opts,
                                   anno_dict=anno_dict)

    return g
Exemplo n.º 2
0
def main():

    project_flag = sys.argv[1]
    input_args = {
        sys.argv[i]: sys.argv[i + 1]
        for i in range(2, len(sys.argv), 2)
    }

    proj_opts = cpp.project_map(project_flag)
    anno_dict = ci.get_annotation_dict(proj_opts)

    arg_ids_to_expand = [
        anno_dict[arg] for arg in input_args.keys() if input_args[arg] == '1'
    ]
    arg_ids_noexpand = [
        anno_dict[arg] for arg in input_args.keys() if input_args[arg] == '0'
    ]

    if len(arg_ids_to_expand) > 0:
        id_list_base = ci.get_ids_from_annotation(arg_ids_to_expand, proj_opts)
    else:
        id_list_base = []

    if len(arg_ids_noexpand) > 0:
        id_list_noexpand = ci.get_ids_from_annotation(arg_ids_noexpand,
                                                      proj_opts)
    else:
        id_list_noexpand = []

    print("     Building id list...")
    id_list = ci.increase_id_list(id_list_base, proj_opts, 1, 1)
    for id in id_list_noexpand:
        id_list.append(id)
    id_list = list(set(id_list))

    ci.write_skeletons_from_list(id_list, proj_opts)
Exemplo n.º 3
0
def main():

    project_flag = sys.argv[1]
    input_args = [sys.argv[i] for i in range(2, len(sys.argv))]

    proj_opts = cpp.project_map(project_flag)
    anno_dict = ci.get_annotation_dict(proj_opts)
    arg_ids = [anno_dict[arg] for arg in input_args]

    f_anno = open('annotation_ids.txt', 'w')

    for arg in input_args:
        f_anno.write(arg)
        id_list_base = ci.get_ids_from_annotation([anno_dict[arg]], proj_opts)
        for skid in id_list_base:
            f_anno.write(',' + str(skid))
        f_anno.write('\n')
    f_anno.close()
Exemplo n.º 4
0
def append_annotation_list(g, annotation_list, proj_opts, anno_dict=None):
    # Given a list of annotations (as a string), add a node property to each
    # skeleton containing which annotations they have
    if anno_dict is None:
        anno_dict = ci.get_annotation_dict(proj_opts)

    for anno in annotation_list:
        try:
            anno_id = [anno_dict[anno]]
            for skid in ci.get_ids_from_annotation(anno_id, proj_opts):
                if skid in g.nodes():
                    if 'annotations' in g.node[skid].keys():
                        if anno not in g.node[skid]['annotations']:
                            g.node[skid]['annotations'].append(anno)
                    else:
                        g.node[skid]['annotations'] = [anno]
        except KeyError:
            print('Not a valid key: ' + anno + ' (skipping)')
    return g
Exemplo n.º 5
0
def neurons_from_annotations(annotation_list, proj_opts, syns=None):
    anno_dict = ci.get_annotation_dict(proj_opts)
    id_list = ci.get_ids_from_annotation(
        [anno_dict[anno] for anno in annotation_list], proj_opts)
    (neurons, syns) = neurons_from_id_list(id_list, proj_opts, syns=syns)
    return (neurons, syns)