-
Notifications
You must be signed in to change notification settings - Fork 0
/
netParams.py
278 lines (238 loc) · 7.16 KB
/
netParams.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
import numpy as np
from netpyne import specs
from network_cell_choice import cell_choice, cell_id, allpops, pop_to_cell
netParams = (
specs.NetParams()
) # object of class NetParams to store the network parameters
# ------------------------------------------------------------------------------
# Cell parameters
# ------------------------------------------------------------------------------
# StochKv_deterministic.mod
for cellName in cell_choice:
cellRuleLabel = cellName + "_rule"
cellRule = netParams.importCellParams(
label=cellRuleLabel,
somaAtOrigin=False,
conds={"cellType": cellName, "cellModel": "HH_full"},
fileName="cellwrapper3.py",
cellName="loadCell_tmsneurosim",
cellInstance=True,
cellArgs={"cellName": cellName, "id": cell_id},
)
cellSecLists = cellRule["secLists"]
cellSecs = cellRule["secs"]
cellSecLists["all"] = list(cellSecs.keys())
cellSecLists["somatic"] = [sec for sec in list(cellSecs.keys()) if "soma" in sec]
cellSecLists["apical"] = [sec for sec in list(cellSecs.keys()) if "apic" in sec]
cellSecLists["basal"] = [sec for sec in list(cellSecs.keys()) if "dend" in sec]
cellSecLists["axonal"] = [
sec
for sec in list(cellSecs.keys())
if "Node" in sec or "axon" in sec or "y" in sec
]
for sec in cellSecs.values():
# sec["mechs"]["extracellular"] = {}
del sec.mechs.xtra
if sec["geom"]["diam"] > 10:
sec["geom"]["diam"] = 1.0
sec["geom"]["pt3d"] = [
(pt[0], pt[1], pt[2], 1.0) for pt in sec["geom"]["pt3d"]
]
print(
f"Axon sections ({cellName}): "
+ str(len(netParams.cellParams[cellRuleLabel]["secLists"]["axonal"]))
)
# ------------------------------------------------------------------------------
# Population parameters
# ------------------------------------------------------------------------------
"""
From 'Large-scale biophysically detailed model of somatosensory thalamocortical circuits in NetPyNE'
https://www.frontiersin.org/articles/10.3389/fninf.2022.884245/full
Layer height (um) height (normal) from to
L1 165 0.079 0.000 0.079
L2 149 0.072 0.079 0.151
L3 353 0.170 0.151 0.320
L4 190 0.091 0.320 0.412
L5 525 0.252 0.412 0.664
L6 700 0.336 0.664 1.000
L23 502 0.241 0.079 0.320
All 2082 1.000
"""
# Primary axis of neurons & neural column is in the z-direction
netParams.sizeZ = 2082 # um
norm_layer_z_ranges = {
"L1": [0.0, 0.079],
"L2": [0.079, 0.151],
"L3": [0.151, 0.320],
"L23": [0.079, 0.320],
"L4": [0.320, 0.412],
"L5": [0.412, 0.664],
"L6": [0.664, 1.0],
"longS1": [2.2, 2.3],
"longS2": [2.3, 2.4],
} # normalized layer boundaries
# layer_y_ranges = {'L1': [0, 165], 'L23': [165, 667], 'L4': [667, 857], 'L5': [857, 1382], 'L6': [1382, 2082]}
def scale_layer_norm_ranges(
norm_ranges: dict[str, list[float]]
) -> dict[str, list[float]]:
"""
norm_ranges should be a dict of the form {'layer': [low_bound, up_bound], ...}
"""
return {
layer: [val * netParams.sizeZ for val in values]
for layer, values in norm_ranges.items()
}
layer_z_ranges = scale_layer_norm_ranges(norm_layer_z_ranges)
def pop_to_layer(pop: str) -> str:
return pop[: pop.find("_")]
# positions = [[{'x': x-857 , 'y': x , 'z': 0}] for x in range(857, 1382, 250)]
for pop in allpops:
cellName = pop_to_cell[pop]
position = [{"x": 0, "y": 0, "z": -1*np.mean(layer_z_ranges[pop_to_layer(pop)])}]
print(pop, position)
netParams.popParams[pop] = {
"cellType": cellName,
"cellModel": "HH_full",
"cellsList": position,
}
# Network connections WORK IN PROGRESS
## Synaptic mechanism parameters
netParams.synMechParams["exc"] = {
"mod": "Exp2Syn",
"tau1": 0.2,
"tau2": 5.0,
"e": 0,
} # excitatory synaptic mechanism
netParams.synMechParams["inh"] = {
"mod": "Exp2Syn",
"tau1": 0.2,
"tau2": 5.0,
"e": -70,
} # inhibitory synaptic mechanism
# Stimulation parameters
netParams.stimSourceParams["bkg"] = {"type": "NetStim", "rate": 5, "noise": 1.0} # hz
netParams.stimTargetParams["bkg->all"] = {
"source": "bkg",
"conds": {"pop": allpops},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
## Cell connectivity rules
netParams.connParams["L2_PV->L2_PV"] = {
"preConds": {"pop": "L2_PV"},
"postConds": {"pop": "L2_PV"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
netParams.connParams["L2_PV->L3_P"] = {
"preConds": {"pop": "L2_PV"},
"postConds": {"pop": "L3_P"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
netParams.connParams["L3_P->L2_PV"] = {
"preConds": {"pop": "L3_P"},
"postConds": {"pop": "L2_PV"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L3_P->L3_P"] = {
"preConds": {"pop": "L3_P"},
"postConds": {"pop": "L3_P"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L3_P->L5_P"] = {
"preConds": {"pop": "L3_P"},
"postConds": {"pop": "L5_P"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L3_SS->L5_P"] = {
"preConds": {"pop": "L3_SS"},
"postConds": {"pop": "L5_P"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L4_SST->L5_P"] = {
"preConds": {"pop": "L4_SST"},
"postConds": {"pop": "L5_P"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
netParams.connParams["L4_SS->L5_P"] = {
"preConds": {"pop": "L4_SS"},
"postConds": {"pop": "L5_P"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L4_PV->L4_PV"] = {
"preConds": {"pop": "L4_PV"},
"postConds": {"pop": "L4_PV"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
netParams.connParams["L4_PV->L5_P"] = {
"preConds": {"pop": "L4_PV"},
"postConds": {"pop": "L5_P"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
netParams.connParams["L5_P->L3_SS"] = {
"preConds": {"pop": "L5_P"},
"postConds": {"pop": "L3_SS"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L5_P->L4_SST"] = {
"preConds": {"pop": "L5_P"},
"postConds": {"pop": "L4_SST"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L5_P->L4_SS"] = {
"preConds": {"pop": "L5_P"},
"postConds": {"pop": "L4_SS"},
"weight": 0.05,
"delay": 5,
"synMech": "exc",
}
netParams.connParams["L5_PV->L5_P"] = {
"preConds": {"pop": "L5_PV"},
"postConds": {"pop": "L5_P"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
netParams.connParams["L5_PV->L5_PV"] = {
"preConds": {"pop": "L5_PV"},
"postConds": {"pop": "L5_PV"},
"weight": 0.05,
"delay": 5,
"synMech": "inh",
}
# netParams.connParams['->'] = {
# 'preConds': {'pop': },
# 'postConds': {'pop': },
# 'weight': 0.05,
# 'delay': 5,
# 'synMech': 'exc'}
# netParams.connParams['->'] = {
# 'preConds': {'pop': },
# 'postConds': {'pop': },
# 'weight': 0.05,
# 'delay': 5,
# 'synMech': 'inh'}