forked from ModECI/MDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFN.py
104 lines (82 loc) · 2.35 KB
/
FN.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from neuromllite import (
Network,
Cell,
Population,
Synapse,
RectangularRegion,
RandomLayout,
)
from neuromllite import (
Projection,
RandomConnectivity,
OneToOneConnector,
Simulation,
InputSource,
Input,
)
from neuromllite.NetworkGenerator import check_to_generate_or_run
import sys
def generate():
dt = 0.05
simtime = 100
################################################################################
### Build new network
net = Network(id="FN")
net.notes = "FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS"
net.parameters = {
"initial_w": 0.0,
"initial_v": -1,
"a_v": -0.3333333333333333,
"b_v": 0.0,
"c_v": 1.0,
"d_v": 1,
"e_v": -1.0,
"f_v": 1.0,
"time_constant_v": 1.0,
"a_w": 1.0,
"b_w": -0.8,
"c_w": 0.7,
"time_constant_w": 12.5,
"threshold": -1.0,
"mode": 1.0,
"uncorrelated_activity": 0.0,
"Iext": 0,
}
cellInput = Cell(id="fn", lems_source_file="FN_Definitions.xml", parameters={})
for p in net.parameters:
cellInput.parameters[p] = p
net.cells.append(cellInput)
r1 = RectangularRegion(
id="region1", x=0, y=0, z=0, width=1000, height=100, depth=1000
)
net.regions.append(r1)
pop = Population(
id="FNpop",
size="1",
component=cellInput.id,
properties={"color": "0.2 0.2 0.2", "radius": 3},
random_layout=RandomLayout(region=r1.id),
)
net.populations.append(pop)
new_file = net.to_json_file("%s.json" % net.id)
################################################################################
### Build Simulation object & save as JSON
sim = Simulation(
id="Sim%s" % net.id,
network=new_file,
duration=simtime,
dt=dt,
seed=123,
recordVariables={"V": {"all": "*"}, "W": {"all": "*"}},
plots2D={
"VW": {"x_axis": "%s/0/fn/V" % pop.id, "y_axis": "%s/0/fn/W" % pop.id}
},
)
sim.to_json_file()
return sim, net
if __name__ == "__main__":
sim, net = generate()
################################################################################
### Run in some simulators
import sys
check_to_generate_or_run(sys.argv, sim)