コード例 #1
0
def test_graft():
    m = Morphology(os.path.join(_path, 'simple2.swc'))
    new_axon = graft.find_axon(m)

    neuron = Morphology(os.path.join(_path, 'simple.swc'))
    graft.graft_axon(neuron, new_axon)

    grafted_axon = graft.find_axon(neuron)
    points = np.vstack([section.points for section in grafted_axon.iter()])

    assert_array_equal(
        points,
        np.array([[0., 0., 0.], [1., 2., 0.], [1., 2., 0.], [3., 4.5, 0.],
                  [1., 2., 0.], [-5., -4., 0.], [-5., -4., 1.]],
                 dtype=np.float32))
コード例 #2
0
def test_graft():
    for rng in [np.random, np.random.default_rng(0)]:
        m = Morphology(DATA / 'simple2.swc')
        new_axon = graft.find_axon(m)

        neuron = Morphology(DATA / 'simple.swc')
        graft.graft_axon(neuron, new_axon)

        grafted_axon = graft.find_axon(neuron)
        points = np.vstack([section.points for section in grafted_axon.iter()])

        assert_array_equal(
            points,
            np.array([[0., 0., 0.], [1., 2., 0.], [1., 2., 0.], [3., 4.5, 0.],
                      [1., 2., 0.], [-5., -4., 0.], [-5., -4., 1.]],
                     dtype=np.float32))
コード例 #3
0
def test_self_graft():
    '''Grafting a neuron with its own neuron'''
    filename = os.path.join(_path, 'neuron.asc')
    new_axon = graft.find_axon(ImmutMorphology(filename))

    neuron = Morphology(filename)
    graft.graft_axon(neuron, new_axon)

    expected = Morphology(filename)
    ok_(not diff(expected, neuron))
コード例 #4
0
def test_self_graft():
    '''Grafting a neuron with its own neuron'''
    filename = DATA / 'neuron.asc'
    new_axon = graft.find_axon(ImmutMorphology(filename))

    neuron = Morphology(filename)
    graft.graft_axon(neuron, new_axon)

    expected = Morphology(filename)
    assert not diff(expected, neuron)
コード例 #5
0
def test_graft_axon_on_synthesized_cell():
    np.random.seed(0)
    # donor neuron is empty
    assert_raises(NoAxonException, graft.graft_axon, SIMPLE, Morphology())

    donor_neuron = Morphology(os.path.join(_path, 'simple3.asc'))
    synthesized_cell = Morphology(os.path.join(_path, 'synthesized_cell.asc'))
    graft.graft_axon(synthesized_cell, donor_neuron)
    axon = graft.find_axon(synthesized_cell)
    assert_array_almost_equal(
        axon.points,
        [[5.110419, 5.486378, 4.9647303], [5.110419, 1.486378, 4.9647303]])
コード例 #6
0
def test_graft_axon_on_synthesized_cell():
    np.random.seed(0)
    # donor neuron is empty
    with pytest.raises(NoAxonException):
        graft.graft_axon(SIMPLE, Morphology())

    donor_neuron = Morphology(DATA / 'simple3.asc')
    synthesized_cell = Morphology(DATA / 'synthesized_cell.asc')
    graft.graft_axon(synthesized_cell, donor_neuron)
    axon = graft.find_axon(synthesized_cell)
    assert_array_almost_equal(
        axon.points,
        [[5.1272364, 5.4825425, 4.9689593], [5.1272364, 1.4825425, 4.9689593]])
コード例 #7
0
ファイル: test_graft.py プロジェクト: e7dal/morph-tool
def test_find_axon():
    axon = find_axon(SIMPLE)
    assert_array_equal(axon.points,
                       [[0, 0, 0], [0, -4, 0]])

    with assert_raises(MorphToolException) as obj:
        dendrite = SIMPLE.root_sections[0]
        find_axon(dendrite)


    with assert_raises(MorphToolException) as obj:
        find_axon(Morphology(os.path.join(_path, 'no_axon.swc')))
    assert_equal(str(obj.exception), 'No axon found!')

    with assert_raises(MorphToolException) as obj:
        find_axon(Morphology(os.path.join(_path, 'two_axons.asc')))
    assert_equal(str(obj.exception), 'Too many axons found!')
コード例 #8
0
def test_find_axon():
    axon = graft.find_axon(SIMPLE)
    assert_array_equal(axon.points, [[0, 0, 0], [0, -4, 0]])

    # section is not an axon
    with pytest.raises(MorphToolException):
        dendrite = SIMPLE.root_sections[0]
        graft.find_axon(dendrite)

    # no axon found
    with pytest.raises(MorphToolException, match='No axon found!'):
        graft.find_axon(Morphology(DATA / 'no_axon.swc'))

    # first axon is chosen
    axon = graft.find_axon(Morphology(DATA / 'two_axons.asc'))
    assert_array_equal(axon.points, [[0, 0, 0], [0, -4, 0]])
コード例 #9
0
def test_find_axon():
    axon = graft.find_axon(SIMPLE)
    assert_array_equal(axon.points, [[0, 0, 0], [0, -4, 0]])

    # section is not an axon
    with assert_raises(MorphToolException):
        dendrite = SIMPLE.root_sections[0]
        graft.find_axon(dendrite)

    # no axon found
    with assert_raises(MorphToolException) as obj:
        graft.find_axon(Morphology(os.path.join(_path, 'no_axon.swc')))
    assert_equal(str(obj.exception), 'No axon found!')

    # first axon is chosen
    axon = graft.find_axon(Morphology(os.path.join(_path, 'two_axons.asc')))
    assert_array_equal(axon.points, [[0, 0, 0], [0, -4, 0]])