Exemplo n.º 1
0
class TestSectionFunctions(unittest.TestCase):
    def setUp(self):
        self.morphology = Morphology(morphology_path)
        self.section = self.morphology.section(1)

    def test_equality(self):
        assert (self.section == self.section)
        assert (self.section == self.morphology.section(1))
        assert (self.section != self.morphology.section(2))

    def test_simple_data(self):
        assert (self.section.id() == 1)
        assert (self.section.type() == brain.neuron.SectionType.axon)
        assert (numpy.isclose(self.section.children()[0].distance_to_soma(),
                              self.section.length()))

    def test_samples(self):
        distances = self.section.sample_distances_to_soma()
        assert (distances.shape == (11, ))
        samples = self.section.samples()
        assert (samples.shape == (11, 4))
        samples = self.section.samples([0, 0.5, 1.0])
        assert (samples.shape == (3, 4))

    def test_tree(self):
        assert (self.section.parent() == None)
        children = self.section.children()
        assert (len(children) == 2)
        for child in children:
            assert (child.parent() == self.section)
Exemplo n.º 2
0
class TestSectionFunctions(unittest.TestCase):
    def setUp(self):
        self.morphology = Morphology(morphology_path)
        self.section = self.morphology.section(1)

    def test_equality(self):
        assert(self.section == self.section)
        assert(self.section == self.morphology.section(1))
        assert(self.section != self.morphology.section(2))

    def test_simple_data(self):
        assert(self.section.id() == 1)
        assert(self.section.type() == brain.neuron.SectionType.axon)
        assert(numpy.isclose(self.section.children()[0].distance_to_soma(),
                             self.section.length()))

    def test_samples(self):
        distances = self.section.sample_distances_to_soma()
        assert(distances.shape == (11,))
        samples = self.section.samples()
        assert(samples.shape == (11, 4))
        samples = self.section.samples([0, 0.5, 1.0])
        assert(samples.shape == (3, 4))

    def test_tree(self):
        assert(self.section.parent() == None)
        children = self.section.children()
        assert(len(children) == 2)
        for child in children:
            assert(child.parent() == self.section)
Exemplo n.º 3
0
class TestMorphologyFunctions(unittest.TestCase):
    def setUp(self):
        self.morphology = Morphology(morphology_path)

    def test_array_accessors(self):
        points = self.morphology.points()
        assert (points.shape == (96, 4))
        sections = self.morphology.sections()
        assert (sections.shape == (13, 2))
        section_types = self.morphology.section_types()
        assert (section_types.shape == (13, ))
        apicals = self.morphology.apicals()
        assert (len(apicals) == 0)

    def test_section(self):
        Type = brain.neuron.SectionType
        neurites = [Type.axon, Type.dendrite, Type.apical_dendrite]

        ids = self.morphology.section_ids([Type.soma])
        assert (ids == [0])
        self.assertRaises(RuntimeError, lambda: self.morphology.section(0))

        ids = self.morphology.section_ids(neurites)
        assert (len(ids) == 12)

        sections = self.morphology.sections([Type.soma])
        assert (len(sections) == 0)
        sections = self.morphology.sections(neurites)
        assert (len(sections) == 12)
        for id in ids:
            self.morphology.section(int(id))
        self.assertRaises(RuntimeError, lambda: self.morphology.section(1234))

    def test_soma(self):
        soma = self.morphology.soma()
        assert (len(soma.profile_points()) == 4)
        for p in soma.profile_points():
            assert (len(p) == 4)
        assert (numpy.isclose(soma.mean_radius(), 0.1))
        assert (soma.centroid() == (0, 0, 0))
Exemplo n.º 4
0
class TestMorphologyFunctions(unittest.TestCase):
    def setUp(self):
        self.morphology = Morphology(morphology_path)

    def test_array_accessors(self):
        points = self.morphology.points()
        assert(points.shape == (96, 4))
        sections = self.morphology.sections()
        assert(sections.shape == (13, 2))
        section_types = self.morphology.section_types()
        assert(section_types.shape == (13,))
        apicals = self.morphology.apicals()
        assert(len(apicals) == 0)

    def test_section(self):
        Type = brain.neuron.SectionType
        neurites = [Type.axon, Type.dendrite, Type.apical_dendrite]

        ids = self.morphology.section_ids([Type.soma])
        assert(ids == [0])
        self.assertRaises(RuntimeError, lambda: self.morphology.section(0))

        ids = self.morphology.section_ids(neurites)
        assert(len(ids) == 12)

        sections = self.morphology.sections([Type.soma])
        assert(len(sections) == 0)
        sections = self.morphology.sections(neurites)
        assert(len(sections) == 12)
        for id in ids:
            self.morphology.section(int(id))
        self.assertRaises(RuntimeError, lambda: self.morphology.section(1234))

    def test_soma(self):
        soma = self.morphology.soma()
        assert(len(soma.profile_points()) == 4)
        for p in soma.profile_points():
            assert(len(p) == 4)
        assert(numpy.isclose(soma.mean_radius(), 0.1))
        assert(soma.centroid() == (0, 0, 0))
Exemplo n.º 5
0
class TestMorphologyMemoryManagement(unittest.TestCase):
    def setUp(self):
        self.morphology = Morphology(morphology_path)

    def test_soma(self):
        soma = self.morphology.soma()
        del self.morphology
        points = soma.profile_points()
        sum = numpy.zeros(4)
        for p in points:
            sum += p

    def test_section(self):
        section = self.morphology.section(1)
        del self.morphology
        samples = section.samples()
        sum = numpy.zeros(4)
        for s in samples:
            sum += s
Exemplo n.º 6
0
class TestMorphologyMemoryManagement(unittest.TestCase):

    def setUp(self):
        self.morphology = Morphology(morphology_path)

    def test_soma(self):
        soma = self.morphology.soma()
        del self.morphology
        points = soma.profile_points()
        sum = numpy.zeros(4)
        for p in points:
            sum += p

    def test_section(self):
        section = self.morphology.section(1)
        del self.morphology
        samples = section.samples()
        sum = numpy.zeros(4)
        for s in samples:
            sum += s