Exemplo n.º 1
0
def test_neuron_not_corrupted():
    # Regression for #492: dendrogram was corrupting
    # neuron used to construct it.
    # This caused the section path distance calculation
    # to raise a KeyError exception.
    neuron = load_neuron(NEURON_PATH)
    dm.Dendrogram(neuron)
    assert get('section_path_distances', neuron).size > 0
Exemplo n.º 2
0
def test_create_dendrogram_neuron():
    neuron = load_neuron(NEURON_PATH)
    dendrogram = dm.Dendrogram(neuron)
    assert NeuriteType.soma == dendrogram.neurite_type
    soma_len = 1.0
    assert soma_len == dendrogram.height
    assert soma_len == dendrogram.width
    assert_array_almost_equal(
        [[-.5, 0], [-.5, soma_len], [.5, soma_len], [.5, 0]],
        dendrogram.coords)
    assert len(neuron.neurites) == len(dendrogram.children)
Exemplo n.º 3
0
def test_create_dendrogram_neuron():
    neuron = load_neuron(NEURON_PATH)
    dendrogram = dm.Dendrogram(neuron)
    nt.assert_equal(NeuriteType.soma, dendrogram.neurite_type)
    soma_len = 1.0
    nt.assert_equal(soma_len, dendrogram.height)
    nt.assert_equal(soma_len, dendrogram.width)
    assert_array_almost_equal(
        [[-.5, 0], [-.5, soma_len], [.5, soma_len], [.5, 0]],
        dendrogram.coords)
    nt.assert_equal(len(neuron.neurites), len(dendrogram.children))
Exemplo n.º 4
0
def test_create_dendrogram_neurite():
    def assert_trees(neurom_section, dendrogram):
        assert len(neurom_section.children) == len(dendrogram.children)
        for i, d in enumerate(dendrogram.children):
            section = neurom_section.children[i]
            assert section.type == d.neurite_type

    neuron = load_neuron(NEURON_PATH)
    neurite = neuron.neurites[0]
    dendrogram = dm.Dendrogram(neurite)
    assert neurite.type == dendrogram.neurite_type
    assert_trees(neurite.root_node, dendrogram)
Exemplo n.º 5
0
def test_create_dendrogram_neurite():
    def assert_trees(neurom_section, dendrogram):
        nt.assert_equal(len(neurom_section.children), len(dendrogram.children))
        for i, d in enumerate(dendrogram.children):
            section = neurom_section.children[i]
            nt.assert_equal(section.type, d.neurite_type)

    neuron = load_neuron(NEURON_PATH)
    neurite = neuron.neurites[0]
    dendrogram = dm.Dendrogram(neurite)
    nt.assert_equal(neurite.type, dendrogram.neurite_type)
    assert_trees(neurite.root_node, dendrogram)
Exemplo n.º 6
0
def test_layout_dendrogram():
    def assert_layout(dendrogram):
        for i, child in enumerate(dendrogram.children):
            # child is higher than parent in Y coordinate
            assert (positions[child][1] >=
                    positions[dendrogram][1] + dendrogram.height)
            if i < len(dendrogram.children) - 1:
                next_child = dendrogram.children[i + 1]
                # X space between child is enough for their widths
                assert (positions[next_child][0] - positions[child][0] > .5 *
                        (next_child.width + child.width))
            assert_layout(child)

    neuron = load_neuron(NEURON_PATH)
    dendrogram = dm.Dendrogram(neuron)
    positions = dm.layout_dendrogram(dendrogram, np.array([0, 0]))
    assert_layout(dendrogram)