예제 #1
0
     ggn.soma.push()
     ordered_tree = h.SectionList()
     ordered_tree.wholetree()
     h.pop_section()
     for sec in ordered_tree:
         sec.push()
         for ii, seg in enumerate(sec):
             if seg.diam < dialim:
                 seg.diam = seg.diam * diascale
                 # print('Changed diameter of segment', ii, seg.x, 'of section', sec.name(), 'to', seg.diam)
                 count += 1
         h.pop_section()
     print('Scaled diameters of', count, 'sections whose diameters were <',
           dialim, 'by', diascale)
 g0 = nu.nrngraph(ggn)
 g, nmap = ng.renumber_nodes(g0, ggn.soma.name())
 type_node_map = defaultdict(list)
 # Reverse lookup table for node by stype
 for n, d in g.nodes_iter(data=True):
     stype = d['s']
     if g.node[n]['orig'] is not None:  # Skip the dummy nodes at terminal
         type_node_map[stype].append(n)
 synnodes = []
 if args.synfile is None:
     for branch_id in inputs:
         nodes = type_node_map[branch_id]
         size = syncount
         if len(nodes) < syncount:
             size = len(nodes)
         for n in np.random.choice(nodes, size=size, replace=False):
             # print(n, g.node[n])
        '--origlabel',
        action='store_true',
        dest='origlabel',
        help='If the original neuron section names should be used.')
    args = parser.parse_args()
    h.xopen(args.filename)
    cellclass = getattr(h, args.cellname)
    cell = cellclass()
    if args.stick:
        graph = nu.nrngraph(cell)
        for n in graph.nodes:
            print(n)
        root = '{}.soma'.format(list(graph.nodes)[0].partition('.')[0])
    else:
        graph, root = cell_to_morph3d(cell)
    numeric, nmap = ng.renumber_nodes(graph, start=root)
    print(len(graph.nodes))
    print(max(numeric.nodes))
    print(len(numeric.nodes))
    if args.origlabel:
        reverse = {node: name.split('.')[-1] for name, node in nmap.items()}
        label_nodes = reverse.keys()
        labels = reverse.values()

    else:
        label_nodes = list(numeric.nodes)
        labels = label_nodes

    morph3d.show_neurons({args.cellname: numeric},
                         label_nodes_dict={args.cellname: label_nodes},
                         labels_dict={args.cellname: labels},