How to use MorphIO - 10 common examples

To help you get started, we’ve selected a few MorphIO examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BlueBrain / MorphIO / tests / brain / python / synapses.py View on Github external
def test_synapse(self):
        circuit = morphio.Circuit(morphio.test.circuit_config)
        synapses = circuit.afferent_synapses([320])
        del circuit
        synapses = [s for s in synapses]
        for synapse in synapses:
            assert(synapse.delay() < 10)
github BlueBrain / MorphIO / tests / brain / python / circuit.py View on Github external
        self.assertRaises(RuntimeError, lambda: morphio.Circuit("foo"))
github BlueBrain / MorphIO / tests / brain / python / synapses.py View on Github external
def setUp(self):
        self.circuit = morphio.Circuit(morphio.test.circuit_config)
        self.synapses = self.circuit.afferent_synapses([320])
github BlueBrain / MorphIO / tests / brain / python / synapses.py View on Github external
def test_synapses(self):
        circuit = morphio.Circuit(morphio.test.circuit_config)
        synapses = circuit.afferent_synapses([320])
        del circuit
        delays = synapses.delays()
        for delay in delays:
            assert(delay < 10)
github BlueBrain / MorphIO / tests / brain / python / morphology.py View on Github external
def setUp(self):
        self.circuit = morphio.Circuit(morphio.test.circuit_config)
github BlueBrain / MorphIO / tests / brain / python / circuit.py View on Github external
def test_open(self):
        circuit = morphio.Circuit(morphio.test.circuit_config)
github BlueBrain / MorphIO / tests / test_8_all_morphologies.py View on Github external
pass

    not_same_same = list()

    def walk(folder):
        import os
        for root, _, files in os.walk(folder):
            for file in files:
                yield os.path.join(root, file)

    # for i, f in enumerate(filter(_is_good_file, walk('MorphologyRepository'))):
    for i, f in enumerate(not_same_same_list):
        print(i)
        print(f)
        m = MutMorphology(f)
        immut = Morphology(f)
        try:
            m.write_h5('morph.h5')
        except MorphioError:
            continue

        m.write_swc('morph.swc')
        m.write_asc('morph.asc')
        same_same = ((immut == Morphology("morph.h5")) and
                     (immut == Morphology("morph.swc")) and
                     (immut == Morphology("morph.asc")))

        if not same_same:
            not_same_same.append(f)
    print(not_same_same)
github BlueBrain / MorphIO / tests / test_1_swc.py View on Github external
# soma point
                         1 1 1 0 1 4.0 -1
                         # root section
                         2 3 0 0 2 0.5 1
                         3 3 0 0 3 0.5 2
                         # first child: real duplicate
                         4 3 0 0 3 0.5 3
                         5 3 0 0 7 0.5 4
                         # second child: duplicate with different diameter
                         6 3 0 0 3 2.3 3
                         7 3 0 0 8 3.5 6
                         # third child: no duplicate
                         8 3 1 0 0 2.3 3
                         9 3 1 1 0 3.5 8''') as tmp_file:

        n = Morphology(tmp_file.name)

    nt.eq_(len(n.root_sections), 1)
    nt.eq_(len(n.root_sections[0].children), 3)
    child1, child2, child3 = n.root_sections[0].children
    assert_array_equal(n.root_sections[0].points, np.array([[0, 0, 2], [0, 0, 3]]))
    assert_array_equal(child1.points, np.array([[0, 0, 3], [0, 0, 7]]))
    assert_array_equal(child2.points, np.array([[0, 0, 3], [0, 0, 8]]))
    assert_array_equal(child3.points, np.array([[0, 0, 3],
                                                [1, 0, 0],
                                                [1, 1, 0]]))
    assert_array_equal(child1.diameters, np.array([1, 1]))
    assert_array_equal(child2.diameters, np.array([4.6, 7], dtype=np.float32))
    assert_array_equal(child3.diameters, np.array([1, 4.6, 7], dtype=np.float32))
github BlueBrain / MorphIO / tests / test_2_neurolucida.py View on Github external
(
                        (3 -10 0 2)  ; merged with parent section
                        (0 -10 0 2)  ; merged with parent section
                        (-3 -10 0 2) ; merged with parent section
                        (
                          (-5 -5 5 5)
                          |
                          (-6 -6 6 6)
                        )
                       )
                      )
                 ''') as tmp_file:

        with captured_output() as (_, err):
            with ostream_redirect(stdout=True, stderr=True):
                n = Morphology(tmp_file.name)
                assert_substring('is the only child of section: 0 starting at:',
                                 err.getvalue().strip())
                assert_substring('It will be merged with the parent section',
                                 err.getvalue().strip())

        nt.assert_equal(len(n.soma.points), 0)
        nt.assert_equal(len(n.soma.points), 0)
        assert_equal(len(n.root_sections), 1)
        assert_array_equal(n.root_sections[0].points,
                           np.array([[3, -4, 0],
                                     [3, -6, 0],
                                     [3, -8, 0],
                                     [3, -10, 0],
                                     [0, -10, 0],
                                     [-3, -10, 0]],
                                    dtype=np.float32))
github BlueBrain / MorphIO / tests / test_0_API.py View on Github external
def test_doc_exists():
    cls = morphio.Morphology

    classes = [morphio.Morphology,
               morphio.mut.Morphology,
               morphio.Section,
               morphio.mut.Section,
               morphio.Soma,
               morphio.mut.Soma,
               morphio.MitoSection,
               morphio.mut.MitoSection,
               morphio.Mitochondria,
               morphio.mut.Mitochondria
               ]
    for cls in classes:
        public_methods = (method for method in dir(cls) if not method[:2] == '__')
        for method in public_methods:
            ok_(getattr(cls, method).__doc__,
                'Public method {} of class {} is not documented !'.format(method, cls))