-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsingle.py
85 lines (67 loc) · 2.28 KB
/
single.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
import arbor as A
from time import perf_counter as pc
import matplotlib.pyplot as plt
def make_hh():
tree = A.segment_tree()
tree.append(A.mnpos, A.mpoint(-3, 0, 0, 3), A.mpoint(3, 0, 0, 3), tag=1)
center = "(location 0 0.5)"
soma = "(tag 1)"
decor = (
A.decor()
.set_property(Vm=-65)
.paint(soma, A.density("hh", {}))
.place(center, A.threshold_detector(-50), "source")
.place(center, A.synapse("expsyn", {"tau": 0.5, "e": 0}), "synapse")
)
return A.cable_cell(tree, decor)
class recipe(A.recipe):
def __init__(self, scale=5e-7):
A.recipe.__init__(self)
# NOTE original background frequency times the indegree
self.f_background = 8e-3 * 1600 # kHz
# NOTE We need to scale down the weight to allow the HH mechanism to recover
self.weight_background = 585.39 * scale
# NOTE original background frequency times the indegree
self.f_thalamic = 15e-3 * 902 * 0.0983
# NOTE We need to scale down the weight to allow the HH mechanism to recover
self.weight_thalamic = 585.39 * scale
def num_cells(self):
return 1
def cell_kind(self, gid):
return A.cell_kind.cable
def cell_description(self, gid):
return make_hh()
def global_properties(self, kind):
return A.neuron_cable_properties()
def event_generators(self, gid):
return [
A.event_generator(
"synapse",
self.weight_background,
A.poisson_schedule(tstart=0.0, freq=self.f_background),
),
A.event_generator(
"synapse",
self.weight_thalamic,
A.poisson_schedule(tstart=0.0, freq=self.f_thalamic),
),
]
def probes(self, gid):
return [A.cable_probe_membrane_voltage("(location 0 0.5)")]
dt = 0.05 # ms
T = 100 # ms
rec = recipe()
sim = A.simulation(rec)
sim.record(A.spike_recording.all)
sim.progress_banner()
hdl = sim.sample((0, 0), A.regular_schedule(dt)) # gid, off
t0 = pc()
sim.run(100, 0.05)
t1 = pc()
print(sim.spikes())
fg, ax = plt.subplots()
for data, meta in sim.samples(hdl):
ax.plot(data[:, 0], data[:, 1])
fg.savefig("single.pdf")
fg.savefig("single.png")