예제 #1
0
    def test_place_pwlin_id(self):
        # Single branch, discontiguous segments.
        s0p = A.mpoint(0, 0, 0, 10)
        s0d = A.mpoint(1, 0, 0, 10)
        s1p = A.mpoint(3, 0, 0, 10)
        s1d = A.mpoint(4, 0, 0, 10)

        tree = A.segment_tree()
        i = tree.append(A.mnpos, s0p, s0d, 1)
        tree.append(i, s1p, s1d, 2)

        m = A.morphology(tree)
        place = A.place_pwlin(m)

        L0 = place.at(A.location(0, 0))
        L0s = place.all_at(A.location(0, 0))
        self.assertEqual(s0p, L0)
        self.assertEqual([s0p], L0s)

        Lhalf = place.at(A.location(0, 0.5))
        Lhalfs = place.all_at(A.location(0, 0.5))
        self.assertTrue(s0d == Lhalf or s1p == Lhalf)
        self.assertTrue([s0d, s1p] == Lhalfs)

        Chalf = [(s.prox, s.dist)
                 for s in place.segments([A.cable(0, 0., 0.5)])]
        self.assertEqual([(s0p, s0d)], Chalf)

        Chalf_all = [(s.prox, s.dist)
                     for s in place.all_segments([A.cable(0, 0., 0.5)])]
        self.assertEqual([(s0p, s0d), (s1p, s1p)], Chalf_all)
예제 #2
0
    def test_probe_meta(self):
        sim = self.init_sim(cc2_recipe())

        self.assertEqual([A.location(1, 1)], sim.probe_metadata((0, 0)))
        self.assertEqual([A.location(2, 1)], sim.probe_metadata((0, 1)))
        self.assertEqual([A.location(1, 1), A.location(2, 1)],
                         sorted(sim.probe_metadata((0, 2)),
                                key=lambda x: (x.branch, x.pos)))

        # Default CV policy is one per branch, which also gives a tivial CV over the branch point.
        # Expect metadata cables to be one for each full branch, plus three length-zero cables corresponding to the branch point.
        self.assertEqual([
            A.cable(0, 0, 1),
            A.cable(0, 1, 1),
            A.cable(1, 0, 0),
            A.cable(1, 0, 1),
            A.cable(2, 0, 0),
            A.cable(2, 0, 1)
        ],
                         sorted(sim.probe_metadata((1, 0))[0],
                                key=lambda x: (x.branch, x.prox, x.dist)))

        # Four expsyn synapses; the two on branch zero should be coalesced, giving a multiplicity of 2.
        # Expect entries to be in target index order.
        m11 = sim.probe_metadata((1, 1))[0]
        self.assertEqual(4, len(m11))
        self.assertEqual([0, 1, 2, 3], [x.target for x in m11])
        self.assertEqual([2, 2, 1, 1], [x.multiplicity for x in m11])
        self.assertEqual([
            A.location(0, 0.3),
            A.location(0, 0.6),
            A.location(1, 0.3),
            A.location(2, 0.3)
        ], [x.location for x in m11])
예제 #3
0
    def test_place_pwlin_isometry(self):
        # Single branch, discontiguous segments.
        s0p = A.mpoint(0, 0, 0, 10)
        s0d = A.mpoint(1, 0, 0, 10)
        s1p = A.mpoint(3, 0, 0, 10)
        s1d = A.mpoint(4, 0, 0, 10)

        tree = A.segment_tree()
        i = tree.append(A.mnpos, s0p, s0d, 1)
        tree.append(i, s1p, s1d, 2)

        m = A.morphology(tree)
        iso = A.isometry.translate(2, 3, 4)
        place = A.place_pwlin(m, iso)

        x0p = iso(s0p)
        x0d = iso(s0d)
        x1p = iso(s1p)
        x1d = iso(s1d)

        L0 = place.at(A.location(0, 0))
        L0s = place.all_at(A.location(0, 0))
        self.assertEqual(x0p, L0)
        self.assertEqual([x0p], L0s)

        Lhalf = place.at(A.location(0, 0.5))
        Lhalfs = place.all_at(A.location(0, 0.5))
        self.assertTrue(x0d == Lhalf or x1p == Lhalf)
        self.assertTrue([x0d, x1p] == Lhalfs)

        Chalf = [(s.prox, s.dist)
                 for s in place.segments([A.cable(0, 0., 0.5)])]
        self.assertEqual([(x0p, x0d)], Chalf)

        Chalf_all = [(s.prox, s.dist)
                     for s in place.all_segments([A.cable(0, 0., 0.5)])]
        self.assertEqual([(x0p, x0d), (x1p, x1p)], Chalf_all)
예제 #4
0
    def test_probe_scalar_recorders(self):
        sim = self.init_sim(cc2_recipe())
        ts = [0, 0.1, 0.3, 0.7]
        h = sim.sample((0, 0), A.explicit_schedule(ts))
        dt = 0.01
        sim.run(10., dt)
        s, meta = sim.samples(h)[0]
        self.assertEqual(A.location(1, 1), meta)
        for i, t in enumerate(s[:, 0]):
            self.assertLess(abs(t - ts[i]), dt)

        sim.remove_sampler(h)
        sim.reset()
        h = sim.sample(A.cell_member(0, 0), A.explicit_schedule(ts),
                       A.sampling_policy.exact)
        sim.run(10., dt)
        s, meta = sim.samples(h)[0]
        for i, t in enumerate(s[:, 0]):
            self.assertEqual(t, ts[i])
예제 #5
0
 def get_probe(self, id):
     loc = arbor.location(0, 0) # at the soma
     return arbor.cable_probe('voltage', id, loc)
예제 #6
0
 def get_probes(self, gid):
     loc = arbor.location(0, 0)  # at the soma
     return [arbor.cable_probe('voltage', loc)]
예제 #7
0
    def test_probe_addr_metadata(self):
        recipe = cc_recipe()
        context = A.context()
        dd = A.partition_load_balance(recipe, context)
        sim = A.simulation(recipe, dd, context)

        all_cv_cables = [A.cable(0, 0, 1)]

        m = sim.probe_metadata((0, 0))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.0), m[0])

        m = sim.probe_metadata((0, 1))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 2))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.02), m[0])

        m = sim.probe_metadata((0, 3))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.03), m[0])

        m = sim.probe_metadata((0, 4))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 5))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 6))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.06), m[0])

        m = sim.probe_metadata((0, 7))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 8))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.08), m[0].location)
        self.assertEqual(1, m[0].multiplicity)
        self.assertEqual(0, m[0].target)

        m = sim.probe_metadata((0, 9))
        self.assertEqual(1, len(m))
        self.assertEqual(1, len(m[0]))
        self.assertEqual(A.location(0, 0.09), m[0][0].location)
        self.assertEqual(1, m[0][0].multiplicity)
        self.assertEqual(1, m[0][0].target)

        m = sim.probe_metadata((0, 10))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.10), m[0])

        m = sim.probe_metadata((0, 11))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 12))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.12), m[0])

        m = sim.probe_metadata((0, 13))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 14))
        self.assertEqual(1, len(m))
        self.assertEqual(A.location(0, 0.14), m[0])

        m = sim.probe_metadata((0, 15))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])

        m = sim.probe_metadata((0, 16))
        self.assertEqual(1, len(m))
        self.assertEqual(all_cv_cables, m[0])
예제 #8
0
        ]


# Read the SWC filename from input
# Example from docs: single_cell_detailed.swc
if len(sys.argv) < 2:
    print("No SWC file passed to the program")
    sys.exit(0)

filename = sys.argv[1]

# define morphology (needed for ``arbor.place_pwlin`` and ``arbor.cable_cell`` below)
morphology = arbor.load_swc_arbor(filename)

# define a location on morphology for current clamp
clamp_location = arbor.location(4, 1 / 6)


def make_cable_cell(morphology, clamp_location):
    # number of CVs per branch
    cvs_per_branch = 3

    # Label dictionary
    defs = {}
    labels = arbor.label_dict(defs)

    # decor
    decor = arbor.decor()

    # set initial voltage, temperature, axial resistivity, membrane capacitance
    decor.set_property(