-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcfiber_potassium.py
304 lines (303 loc) · 10.9 KB
/
cfiber_potassium.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
from neuron import h, gui
import math
import random
#neuron.load_mechanisms("./mod")
class cfiber2(object):
'''
C-fiber class with parameters:
L: int (mkM)
length of compartment
d: float
diameter of fiber
num: int
number of compartments
coordinates: dict (updates by position())
coordinates of each section
zpozition: int
z - coordinate for few cells simulation
fast_diff: bool
Is there fast diffusion?
-Yes: True
-No: False
diffs: list
list of diffusion mechanisms (NEURON staff)
recs: list
list of receptors mechanisms (NEURON staff)
'''
def __init__(self, L, d, zpozition, x_application, fast_diff, numofmodel):
self.coordinates = dict()
self.distances = dict()
self.diffusions = dict()
self.fast_diff = fast_diff
self.diffs = []
self.recs = []
self.L = L
self.diam = d
self.zpozition = zpozition
self.x_application = x_application
self.numofmodel = numofmodel
if self.numofmodel == 11 or self.numofmodel == 12:
self.num = 170
else:
self.num = 10
self.create_sections()
self.build_topology()
self.build_subsets()
self.define_geometry()
self.position()
self.distance()
self.define_biophysics()
def create_sections(self):
'''
Creates sections (compartments)
'''
self.branch = h.Section(name='branch', cell=self)
self.stimsec = [h.Section(name='stimsec[%d]' % i) for i in range(self.num)]
def build_topology(self):
'''
Connects sections
'''
self.stimsec[0].connect(self.branch(0), 1)
if self.numofmodel == 11 or self.numofmodel == 12:
for i in range(1, 70):
self.stimsec[i].connect(self.stimsec[i-1])
for i in range(70, 120):
self.stimsec[i].connect(self.stimsec[i-1])
for i in range(120, 170):
self.stimsec[i].connect(self.stimsec[i-1])
self.stimsec[70].connect(self.stimsec[69])
self.stimsec[120].connect(self.stimsec[69])
else:
for i in range(1, len(self.stimsec)):
self.stimsec[i].connect(self.stimsec[i-1])
def define_geometry(self):
'''
Adds length and diameter to sections
'''
for sec in self.stimsec:
sec.L = self.L# microns
sec.diam = self.diam # microns
self.branch.L = self.L
self.branch.diam = self.diam
self.branch.nseg = 1
h.define_shape() # Translate into 3D points.
def position(self):
'''
Adds 3D position
'''
if self.numofmodel == 11 or self.numofmodel == 12:
h.pt3dclear()
h.pt3dadd(0, 0, self.zpozition, self.diam)
h.pt3dadd(self.L, 0, self.zpozition, self.diam)
xyz = dict(x=self.L, y=0, z=0)
self.coordinates.update({self.branch: xyz})
for i in range(70):
h.pt3dclear()
h.pt3dadd(self.L*(i+1), 0, self.zpozition, self.diam)
h.pt3dadd(self.L*(i+2), 0, self.zpozition, self.diam)
xyz = dict(x=self.L*(i+2), y=0, z=0)
self.coordinates.update({self.stimsec[i]: xyz})
for i in range(70, 120):
h.pt3dclear()
h.pt3dadd(self.L*(i+1), (i-70)*8, self.zpozition, self.diam)
h.pt3dadd(self.L*(i+2), (i-69)*8, self.zpozition, self.diam)
xyz = dict(x=self.L*(i+2), y=(i-69)*8, z=0)
self.coordinates.update({self.stimsec[i]: xyz})
for i in range(120, 170):
h.pt3dclear()
h.pt3dadd(self.L*(i-49), (i-120)*(-8), self.zpozition, self.diam)
h.pt3dadd(self.L*(i-48), (i-119)*(-8), self.zpozition, self.diam)
xyz = dict(x=self.L*(i-48), y=(i-119)*(-8), z=0)
self.coordinates.update({self.stimsec[i]: xyz})
else:
i = 0
for sec in self.all:
h.pt3dclear()
h.pt3dadd(self.L*i, 0, self.zpozition, self.diam)
h.pt3dadd(self.L*(i+1), 0, self.zpozition, self.diam)
xyz = dict(x=self.L*(i+1), y=0, z=0)
self.coordinates.update({sec: xyz})
i+=1
def distance(self):
'''
Adds distances from application for every compartment
'''
#self.distances.clear()
if self.numofmodel == 11 or self.numofmodel == 12:
self.x_application = -400
for compartment in self.all:
distance = math.sqrt((30050-self.coordinates.get(compartment).get('x'))**2 + (self.x_application-self.coordinates.get(compartment).get('y'))**2 + (0.01-self.coordinates.get(compartment).get('z'))**2)
self.distances.update({compartment: distance})
else:
for compartment in self.all:
distance = math.sqrt((self.x_application-self.coordinates.get(compartment).get('x'))**2 + (50-self.coordinates.get(compartment).get('y'))**2 + (0.01-self.coordinates.get(compartment).get('z'))**2)
self.distances.update({compartment: distance})
def define_biophysics(self):
'''
Adds channels and their parameters
'''
for sec in self.all: # 'all' defined in build_subsets
sec.Ra = 35 # Axial resistance in Ohm * cm
sec.cm = 1 # Membrane capacitance in micro Farads / cm^2
sec.insert('navv1p8')
sec.insert('extrapump')
sec.insert('koi')
sec.insert('naoi')
sec.insert('nakpump')
sec.insert('nattxs')
sec.insert('kdr')
sec.insert('iKCa')
sec.insert('kad')
sec.insert('kap')
sec.insert('leak')
sec.insert('Nav1_3')
sec.insert('iCaL')
sec.insert('CaIntraCellDyn')
sec.insert('extracellular')
ap_diff = h.AtP_slow(sec(0.5))
ap_diff.h = self.distances.get(sec)
ap_diff.tx1 = 1000 + 0 + (ap_diff.h/1250)*1000
ap_diff.c0cleft = 100
self.diffs.append(ap_diff)
for seg in sec:
h.setpointer(ap_diff._ref_atp, 'im', seg.kdr)
h.setpointer(ap_diff._ref_atp, 'im', seg.kad)
h.setpointer(ap_diff._ref_atp, 'im', seg.kap)
if self.numofmodel == 8 or self.numofmodel >= 11:
sec.gbar_navv1p8 = 0.2
elif self.numofmodel == 7:
sec.gbar_navv1p8 = 0.1
else:
sec.gbar_navv1p8 = 0
sec.gbar_kdr = 0.01
sec.gbar_kad = 0.1
sec.gbar_kap = 0.1
sec.gbar_iKCa = 0.0015
sec.depth_CaIntraCellDyn = 0.1
sec.cai_tau_CaIntraCellDyn = 2.0
sec.cai_inf_CaIntraCellDyn = 50.0e-6
sec.pcabar_iCaL = 0.0001
if self.numofmodel == 6:
sec.gbar_nattxs = 0.2
else:
sec.gbar_nattxs = 0.1
sec.gbar_Nav1_3 = 0.2
sec.smalla_nakpump = -0.0047891
sec.theta_naoi = 0.029
sec.theta_koi = 0.029
sec.celsiusT_nattxs = 37
sec.celsiusT_navv1p8 = 37
sec.celsiusT_nakpump = 37
for sec in self.stimsec:
if self.numofmodel == 13 or self.numofmodel == 14:
self.add_5HTreceptors(sec, 10, 1)
else:
self.add_P2Xreceptors(sec, 100, 3)
def add_P2Xreceptors(self, compartment, time, g):
'''
Adds P2X3 receptors
Parameters
----------
compartment: section of NEURON cell
part of neuron
x: int
x - coordinate of ATP application
time: int (ms)
time of ATP application
g: float
receptor conductance
'''
if self.fast_diff:
diff = h.AtP_42(compartment(0.5))
diff.h = self.distances.get(compartment)
diff.tx1 = time
diff.Deff = 0.8
if self.numofmodel == 4 or self.numofmodel == 5:
diff.c0cleft = 10
else:
diff.c0cleft = 1
if self.numofmodel == 1:
diff.k = 0
elif self.numofmodel == 3:
diff.k = 0.6
else:
diff.k = 0.01
else:
diff = h.AtP_slow(compartment(0.5))
diff.h = self.distances.get(compartment)
diff.tx1 = time + 0 + (diff.h/1250)*1000
diff.c0cleft = 100
self.diffusions.update({diff: compartment})
rec = h.p2x3(compartment(0.5))
rec.gmax = g
rec.Ev = 5
if self.numofmodel == 4 or self.numofmodel == 5:
rec2 = h.p2x2(compartment(0.5))
rec2.Ev = -7
rec2.gmax = 1
h.setpointer(diff._ref_atp, 'patp', rec2)
self.recs.append(rec2)
if self.numofmodel == 4:
rec.gmax = 0
if self.numofmodel == 5:
rec.gmax = 0.2
rec2.gmax = 0.2
h.setpointer(diff._ref_atp, 'patp', rec)
self.recs.append(rec)
self.diffs.append(diff)
def add_5HTreceptors(self, compartment, time, g):
'''
Adds 5HT receptors
Parameters
----------
compartment: section of NEURON cell
part of neuron
x: int
x - coordinate of serotonin application
time: int (ms)
time of serotonin application
g: float
receptor conductance
'''
if self.fast_diff:
diff = h.diff_5HT(compartment(0.5))
diff.h = self.distances.get(compartment)
diff.tx1 = time
if self.numofmodel == 14:
diff.a = 0.25
else:
diff.a = 0
diff.Deff = 0.2
diff.c0cleft = 3
else:
diff = h.slow_5HT(compartment(0.5))
diff.h = self.distances.get(compartment)
diff.tx1 = time + 0 + (diff.h/50)*10#00
diff.c0cleft = 3
rec = h.r5ht3a(compartment(0.5))
rec.gmax = g
h.setpointer(diff._ref_serotonin, 'serotonin', rec)
self.diffs.append(diff)
self.recs.append(rec)
def build_subsets(self):
'''
adds sections in NEURON SectionList
'''
self.all = h.SectionList()
for sec in h.allsec():
self.all.append(sec=sec)
def connect2target(self, target):
'''
Adds presynapses
Parameters
----------
target: NEURON cell
target neuron
Returns
-------
nc: NEURON NetCon
connection between neurons
'''
nc = h.NetCon(self.branch(1)._ref_v, target, sec = self.branch)
nc.threshold = 10
return nc