def case_6(self): return [ arb.gap_junction_connection(arb.cell_member(2 + self.shift_, 0), 0, 0.1), arb.gap_junction_connection(arb.cell_member(7 + self.shift_, 0), 0, 0.1) ]
def case_2(self): return [ arb.gap_junction_connection(arb.cell_member(6 + self.shift_, 0), arb.cell_member(self.gid_, 0), 0.1), arb.gap_junction_connection(arb.cell_member(9 + self.shift_, 0), arb.cell_member(self.gid_, 0), 0.1) ]
def connections_on(self, gid): src = (gid - 1) % self.ncells w = 0.01 d = 5 return [ arbor.connection(arbor.cell_member(src, 0), arbor.cell_member(gid, 0), w, d) ]
def gap_junctions_on(self, gid): group = int(gid/self.groups) id = gid%self.size if (id == group and group != (self.groups - 1)): return [arb.gap_junction_connection(arb.cell_member(gid + self.size, 0), arb.cell_member(gid, 0), 0.1)] elif (id == group - 1): return [arb.gap_junction_connection(arb.cell_member(gid - self.size, 0), arb.cell_member(gid, 0), 0.1)] else: return []
def test_event_generator_explicit_schedule(self): cm = arb.cell_member(0, 42) es = arb.explicit_schedule([0, 1, 2, 3, 4.4]) eg = arb.event_generator(cm, -0.01, es) self.assertEqual(eg.target.gid, 0) self.assertEqual(eg.target.index, 42) self.assertAlmostEqual(eg.weight, -0.01)
def test_event_generator_regular_schedule(self): cm = arb.cell_member(42, 3) rs = arb.regular_schedule(2.0, 1., 100.) rg = arb.event_generator(cm, 3.14, rs) self.assertEqual(rg.target.gid, 42) self.assertEqual(rg.target.index, 3) self.assertAlmostEqual(rg.weight, 3.14)
def test_event_generator_poisson_schedule(self): cm = arb.cell_member(4, 2) ps = arb.poisson_schedule(0., 10., 0) pg = arb.event_generator(cm, 42., ps) self.assertEqual(pg.target.gid, 4) self.assertEqual(pg.target.index, 2) self.assertEqual(pg.weight, 42.)
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])
hints = dict([(arbor.cell_kind.cable, hint)]) decomp = arbor.partition_load_balance(recipe, context, hints) print(f'{decomp}') meters.checkpoint('load-balance', context) sim = arbor.simulation(recipe, decomp, context) meters.checkpoint('simulation-init', context) spike_recorder = arbor.attach_spike_recorder(sim) # Attach a sampler to the voltage probe on cell 0. # Sample rate of 10 sample every ms. samplers = [arbor.attach_sampler(sim, 0.1, arbor.cell_member(gid,0)) for gid in range(ncells)] tfinal=100 sim.run(tfinal) print(f'{sim} finished') meters.checkpoint('simulation-run', context) # Print profiling information print(f'{arbor.meter_report(meters, context)}') # Print spike times print('spikes:') for sp in spike_recorder.spikes: print(' ', sp)
hints = dict([(arbor.cell_kind.cable, hint)]) decomp = arbor.partition_load_balance(recipe, context, hints) print(f'{decomp}') meters.checkpoint('load-balance', context) sim = arbor.simulation(recipe, decomp, context) meters.checkpoint('simulation-init', context) spike_recorder = arbor.attach_spike_recorder(sim) # Attach a sampler to the voltage probe on cell 0. # Sample rate of 10 sample every ms. samplers = [ arbor.attach_sampler(sim, 0.1, arbor.cell_member(gid, 0)) for gid in range(ncells) ] tfinal = 100 sim.run(tfinal) print(f'{sim} finished') meters.checkpoint('simulation-run', context) # Print profiling information print(f'{arbor.meter_report(meters, context)}') # Print spike times print('spikes:') for sp in spike_recorder.spikes:
def test_set_git_index_cell_member(self): cm = arb.cell_member() cm.gid = 13 cm.index = 23 self.assertEqual(cm.gid, 13) self.assertEqual(cm.index, 23)
def test_gid_index_contor_cell_member(self): cm = arb.cell_member(17, 42) self.assertEqual(cm.gid, 17) self.assertEqual(cm.index, 42)
def test_default_cell_member(self): cm = arb.cell_member() self.assertEqual(cm.gid, 0) self.assertEqual(cm.index, 0)
# Pass the probe in a list because that it what single_recipe expects. #recipe = single_recipe(dd1_cell, [voltage_probe]) #, ca_conc_probe]) recipe = single_recipe(dd1_cell, [voltage_probe, ca_conc_probe]) context = arbor.context() domains = arbor.partition_load_balance(recipe, context) sim = arbor.simulation(recipe, domains, context) # Instruct the simulation to record the spikes sim.record(arbor.spike_recording.all) # Instruct the simulation to sample the probe (0, 0) # at a regular schedule with period = 0.1 ms (1000 Hz) voltage_probe_id = arbor.cell_member(0,0) ca_conc_probe_id = arbor.cell_member(0,1) volt_handle = sim.sample(voltage_probe_id, arbor.regular_schedule(0.1)) ca_conc_handle = sim.sample(ca_conc_probe_id, arbor.regular_schedule(0.1)) handles = [volt_handle, ca_conc_handle] sim.run(tfinal=500, dt=0.1) spikes = sim.spikes() # Print the number of spikes. print(len(spikes), 'spikes recorded:') # Print the spike times.
def event_generators(self, gid): if gid==0: sched = arbor.explicit_schedule([1]) return [arbor.event_generator(arbor.cell_member(0,0), 0.1, sched)] return []
context = arbor.context() # (5) Create a domain decomposition domains = arbor.partition_load_balance(recipe, context) # (6) Create a simulation sim = arbor.simulation(recipe, domains, context) # Instruct the simulation to record the spikes and sample the probe sim.record(arbor.spike_recording.all) probe_id = arbor.cell_member(0, 0) handle = sim.sample(probe_id, arbor.regular_schedule(0.02)) # (7) Run the simulation sim.run(tfinal=100, dt=0.025) # (8) Print or display the results spikes = sim.spikes() print(len(spikes), 'spikes recorded:') for s in spikes: print(s) data = [] meta = []
def connections_on(self, gid): src = (gid - 1) % self.ncells w = 0.01 d = 5 weight = 0.1 return [arbor.event_generator(arbor.cell_member(0, 0), weight, sched)]