Example #1
0
def main_segments(swc_matirx):
    neuron = Neuron(swc_matirx)
    branch_order = tree_util.branch_order(neuron.parent_index)
    distance_from_parent = neuron.distance_from_parent()
    main, parent_main_point, neural, euclidean = \
        neuron.get_neural_and_euclid_lenght_main_point(branch_order, distance_from_parent)
    branch_branch, branch_die, die_die, initial_with_branch = \
        neuron.branching_type(main, parent_main_point)
    ind_main = nodes_laying_toward_soma(
        neuron.parent_index, np.array(np.append(branch_die, die_die)))

    main_seg = np.zeros(len(neuron.parent_index))
    main_seg[ind_main] = 1
    return main_seg.astype(int)
Example #2
0
def topological_depth(swc_matirx):
    neuron = Neuron(swc_matirx)
    branch_order = tree_util.branch_order(neuron.parent_index)
    distance_from_parent = neuron.distance_from_parent()
    main, parent_main_point, neural, euclidean = \
        neuron.get_neural_and_euclid_lenght_main_point(branch_order, distance_from_parent)

    reg_neuron = Neuron(subsample.regular_subsample(swc_matirx))
    topo_depth = np.zeros(swc_matirx.shape[0])
    depth_main = neuron_util.dendogram_depth(reg_neuron.parent_index)
    topo_depth[main] = depth_main
    for i in range(1, swc_matirx.shape[0]):
        b = True
        par = i
        while b:
            (index, ) = np.where(main == par)
            if len(index) != 0:
                topo_depth[i] = topo_depth[main[index]]
                b = False
            par = neuron.parent_index[par]
    return topo_depth