Example #1
0
def _dendrogram(neuron_, show_diameters=True):
    '''Main dendrogram function
    '''
    from copy import deepcopy
    import sys
    sys.setrecursionlimit(3000)
    # neuron is copied because otherwise the tree modifications that follow
    # will be applied to our original object
    neuron = deepcopy(neuron_)

    # total number of lines equal to the total number of segments
    # plus the number of horizontal lines (2) per bifurcation
    n_lines = sum(
        n_segments(neu) + n_bifurcations(neu) * 2 for neu in neuron.neurites)

    soma_tree = _create_root_soma_tree(neuron)

    n_lines += 2

    # add all the neurites to the soma treen
    for neurite in neuron.neurites:

        soma_tree.children[0].add_child(neurite)
        n_lines += 2

    # initialize the lines matrix that is required for the PolyCollection
    # and the colors one
    lines = np.zeros((n_lines, 4, 2))
    colors = np.zeros(n_lines)

    # n is used as a list in order to be static
    n = [0]

    _generate_dendro(soma_tree,
                     lines,
                     colors,
                     n, [0., 0.], (40., 0.), (0., 0.),
                     show_diameters=show_diameters)

    assert n[0] == n_lines - 1

    return lines, colors
Example #2
0
def _dendrogram(neuron_, show_diameters=True):
    '''Main dendrogram function
    '''
    from copy import deepcopy
    import sys
    sys.setrecursionlimit(3000)
    # neuron is copied because otherwise the tree modifications that follow
    # will be applied to our original object
    neuron = deepcopy(neuron_)

    # total number of lines equal to the total number of segments
    # plus the number of horizontal lines (2) per bifurcation
    n_lines = sum(n_segments(neu) + n_bifurcations(neu) * 2 for neu in neuron.neurites)

    soma_tree = _create_root_soma_tree(neuron)

    n_lines += 2

    # add all the neurites to the soma treen
    for neurite in neuron.neurites:

        soma_tree.children[0].add_child(neurite)
        n_lines += 2

    # initialize the lines matrix that is required for the PolyCollection
    # and the colors one
    lines = np.zeros((n_lines, 4, 2))
    colors = np.zeros(n_lines)

    # n is used as a list in order to be static
    n = [0]

    _generate_dendro(soma_tree, lines, colors, n, [0., 0.],
                     (40., 0.), (0., 0.), show_diameters=show_diameters)

    assert n[0] == n_lines - 1

    return lines, colors
Example #3
0
def test_n_bifurcations():
    nt.ok_(n_bifurcations(tree0) == 10)