示例#1
0
文件: test_io.py 项目: masht18/TMD
def test_load_h5_neuron():
    nt.ok_(neuron_v1.soma.is_equal(neuron_v2.soma))
    nt.ok_(neuron_v1.basal[0].is_equal(neuron_v2.basal[0]))
    nt.ok_(neuron_v1.axon[0].is_equal(neuron_v2.axon[0]))
    try:
        neuron = io.load_neuron(sample_h5_v0_file)
        nt.ok_(False)
    except:
        nt.ok_(True)
示例#2
0
def test_neuron_building_consistency__swc():

    path = f'{DATA_PATH}/valid/C010398B-P2.CNG.swc'

    neuron1 = load_neuron(path)
    neuron2 = load_neuron_from_morphio(path)

    _assert_neurons_equal(neuron1, neuron2)

    neuron2 = load_neuron_from_morphio(morphio.Morphology(path))

    _assert_neurons_equal(neuron1, neuron2)
示例#3
0
文件: test_io.py 项目: masht18/TMD
def test_load_swc_neuron():
    neuron = io.load_neuron(basic_file)
    nt.ok_(neuron.soma.is_equal(soma_test))
    nt.ok_(len(neuron.apical) == 1)
    nt.ok_(len(neuron.basal) == 1)
    nt.ok_(len(neuron.axon) == 1)
    nt.ok_(neuron.apical[0].is_equal(apical_test))
    nt.ok_(neuron.basal[0].is_equal(basal_test))
    nt.ok_(neuron.axon[0].is_equal(axon_test))
    neuron1 = io.load_neuron(sample_file)
    nt.ok_(neuron1.soma.is_equal(soma_test1))
    nt.ok_(len(neuron1.apical) == 0)
    nt.ok_(len(neuron1.basal) == 1)
    nt.ok_(len(neuron1.axon) == 1)
    tree_1 = neuron1.axon[0]
    nt.ok_(np.allclose(tree_1.get_bifurcations(), np.array([10, 20])))
    nt.ok_(np.allclose(tree_1.get_terminations(), np.array([15, 25, 30])))
    try:
        neuron = io.load_neuron(nosecids_file)
        nt.ok_(False)
    except:
        nt.ok_(True)
示例#4
0
文件: test_io.py 项目: vsukhor/TMD
def test_tree_type():
    tree_types = {5: 'soma', 6: 'axon', 7: 'basal', 8: 'apical'}

    neuron = io.load_neuron(os.path.join(DATA_PATH,
                                         'basic_exotic_section_types.swc'),
                            soma_type=5,
                            tree_types=tree_types)

    def point(section):
        return np.column_stack([section.x, section.y, section.z])

    assert_array_equal(point(neuron.apical[0]), [[3, 4, 5]])
    assert_array_equal(point(neuron.basal[0]), [[4, 5, 6]])
    assert_array_equal(point(neuron.axon[0]), [[5, 6, 7], [5, 6, 7]])
示例#5
0
文件: test_io.py 项目: masht18/TMD
import glob

_path = os.path.dirname(os.path.abspath(__file__))
DATA_PATH = os.path.join(_path, '../../../test_data')
POP_PATH = os.path.join(_path, '../../../test_data/valid')

# Filenames for testing
basic_file = os.path.join(DATA_PATH, 'basic.swc')
nosecids_file = os.path.join(DATA_PATH, 'basic_no_sec_ids.swc')
sample_file = os.path.join(DATA_PATH, 'sample.swc')

sample_h5_v1_file = os.path.join(DATA_PATH, 'sample_v1.h5')
sample_h5_v2_file = os.path.join(DATA_PATH, 'sample_v2.h5')
sample_h5_v0_file = os.path.join(DATA_PATH, 'sample_v0.h5')

neuron_v1 = io.load_neuron(sample_h5_v1_file)
neuron_v2 = io.load_neuron(sample_h5_v2_file)
neuron1 = io.load_neuron(sample_file)

soma_test = Soma.Soma([0.], [0.], [0.], [12.])
soma_test1 = Soma.Soma([0.], [0.], [0.], [6.])
apical_test = Tree.Tree(x=np.array([5., 5.]), y=np.array([6., 6.]), z=np.array([7., 7.]),
                        d=np.array([16., 16.]), t=np.array([4, 4]), p=np.array([-1,  0]))
basal_test = Tree.Tree(x=np.array([4.]), y=np.array([5.]), z=np.array([6.]),
                       d=np.array([14.]), t=np.array([3]), p=np.array([-1]))
axon_test = Tree.Tree(x=np.array([3.]), y=np.array([4.]), z=np.array([5.]),
                      d=np.array([12.]), t=np.array([2]), p=np.array([-1]))


def test_type_dict():
    nt.ok_(io.TYPE_DCT == {'soma': 1,
示例#6
0
import numpy as np
from numpy import testing as npt
from tmd.Tree import Tree
from tmd.io import io
from tmd.Tree import methods
import os

_path = os.path.dirname(os.path.abspath(__file__))
DATA_PATH = os.path.join(_path, 'data')
POP_PATH = os.path.join(DATA_PATH, 'valid')

# Filenames for testing
sample_file = os.path.join(DATA_PATH, 'sample.swc')
sample_file2 = os.path.join(POP_PATH, 'C010398B-P2.h5')

neu1 = io.load_neuron(sample_file)
neu3 = io.load_neuron(sample_file2)
tree_h5 = neu3.axon[0]
tree_h5_ap = neu3.apical[0]
tree0 = neu1.neurites[0]
tree1 = neu1.neurites[1]

secs_h5_beg = np.array([
    0, 16, 17, 21, 30, 52, 78, 78, 52, 30, 196, 219, 219, 196, 21, 17, 301,
    301, 334, 334, 406, 409, 409, 406, 16, 508, 519, 522, 612, 640, 645, 645,
    640, 612, 710, 730, 738, 738, 730, 710, 522, 519, 508
])

secs_h5_end = np.array([
    16, 17, 21, 30, 52, 78, 86, 91, 190, 196, 219, 222, 230, 249, 256, 301,
    330, 334, 385, 406, 409, 454, 482, 494, 508, 519, 522, 612, 640, 645, 678,