-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadelta2.py
262 lines (244 loc) · 8.46 KB
/
adelta2.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
from neuron import h
h.load_file('stdlib.hoc') #for h.lambda_f
import random
import math
from axon import axon
class adelta2(object):
'''
bio-axon class with parameters:
axon parameters from: https://senselab.med.yale.edu/ModelDB/ShowModel.cshtml?model=3810&file=/MRGaxon/MRGaxon.hoc#tabs-2
number:
number of nodes of Ranvier
'''
def __init__(self, dt, diff_type):
self.dt = dt
self.coordinates = dict()
self.distances = dict()
self.diffusions = dict()
self.diffs = []
self.recs = []
self.axons = []
self.synlistinh = []
self.synlistex = []
self.axon1 = axon(17)
self.axon2 = axon(10)
self.axon3 = axon(10)
self.synapses()
# self.axon4 = axon(10)
self.axons.append(self.axon2)
self.axons.append(self.axon3)
self.axons.append(self.axon1)
self.x_application = 5600
self.fast_diff = diff_type
self.build_subsets()
self.add_receptors()
def build_subsets(self):
'''
adds sections in NEURON SectionList
'''
self.soma = h.Section(name='soma', cell=self)
self.all_secs = h.SectionList()
# for sec in self.branch:
for axon in self.axons:
for sec in axon.all_secs:
self.all_secs.append(sec=sec)
self.all_secs.append(sec=self.soma)
# self.all = h.SectionList()
# for sec in h.allsec():
# self.all.append(sec=sec)
def position(self, axon, last_x, plus_y):
'''
Adds 3D position
'''
i = 0
z = 0#random.randint(0, 2500)
for sec in axon.node:
# h.pt3dclear()
# h.pt3dadd((last_x + axon.interlength*i), i*plus_y, z, axon.nodeD)
# h.pt3dadd((last_x + axon.interlength*i + axon.nodelength), i*2*plus_y, z, axon.nodeD)
xyz = dict(x=(last_x + axon.interlength*i + axon.nodelength), y=i*2*plus_y, z=z)
self.coordinates.update({sec: xyz})
i+=1
def distance(self, compartment, x_app, y_app, z_app):
'''
Adds distances from application for every compartment
'''
#self.distances.clear()
distance = math.sqrt((x_app-self.coordinates.get(compartment).get('x'))**2 + (y_app-self.coordinates.get(compartment).get('y'))**2 + (z_app-self.coordinates.get(compartment).get('z'))**2)
return distance
def __del__(self):
#print 'delete ', self
pass
def add_receptors(self):
# self.axon1.node[0].connect(self.soma(0))
self.axon2.node[0].connect(self.axon1.MYSA[len(self.axon1.MYSA)-1](0))
self.axon3.node[0].connect(self.axon1.MYSA[len(self.axon1.MYSA)-1](0))
# self.axon4.node[0].connect(self.axon1.MYSA[len(self.axon1.MYSA)-1](1))
self.position(self.axon1, 0, 0)
# self.distance(self.axon1)
# print(self.distances.get(self.axon1.node[len(self.axon1.node)-1]))
self.position(self.axon2, self.coordinates.get(self.axon1.node[len(self.axon1.node)-1]).get('x'), 100)
self.position(self.axon3, self.coordinates.get(self.axon1.node[len(self.axon1.node)-1]).get('x'), -100)
# self.position(self.axon4, self.coordinates.get(self.axon1.node[len(self.axon1.node)-1]).get('x'), 10)
# self.distance(self.axon2)
# self.distance(self.axon3)
self.soma.Ra = 100
self.soma.nseg = 10
self.soma.L = self.soma.diam = 20
# self.soma.insert('nav1p8')
# self.soma.insert('nattxs')
# self.soma.insert('nav11_L263V')
# self.soma.insert('nav1p6')
# self.soma.insert('pas')
# self.soma.insert('kv1')
# self.soma.insert('kv3')
# self.soma.insert('kv4')
#
# self.soma.gbar_nav1p8 = 0.0005
# self.soma.gnabar_nav1p6 = 0.1#random.uniform(0.35, 0.5)
# self.soma.gnabar_nav11_L263V = 0.1#random.uniform(0.35, 0.5)
#
# self.soma.gkbar_kv1 = 0.002#random.uniform(0.02, 0.06)
# self.soma.gkbar_kv3 = 0.002#random.uniform(0.02, 0.06)
# self.soma.gkbar_kv4 = 0.0001
# self.soma.gbar_nattxs = 0.05# random.uniform(0.3, 0.5)
#
# self.soma.g_pas = 0.002
# self.soma.e_pas = -60
# self.soma.ena = 55
# self.soma.ek = -90
#
# self.soma.celsiusT_nattxs = 37
# self.soma.celsiusT_nav1p8 = 37
# print(self.coordinates)
# self.add_5HTreceptors(sec, 10, 1)
# for sec in self.axon1.node:
# self.add_5HTreceptors(sec, 10, 15)
# self.add_P2Xreceptors(sec, 10, 15)
for sec in self.axon2.node:
self.add_5HTreceptors(sec, random.randint(10, 20), 29)
# self.add_P2Xreceptors(sec, 10, 20)
for sec in self.axon3.node:
self.add_5HTreceptors(sec, random.randint(10, 20), 29)
# self.add_P2Xreceptors(sec, 10, 20)
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
'''
x = [13485, 13485]
y = [1800, -1800]
z = [0, 0, 0]
if self.fast_diff:
for i in range(len(x)):
diff = h.AtP_42(compartment(0.5))
# if i > 0:
# y = y*(-1)
diff.h = self.distance(compartment, x[i], y[i], z[i])
# print(compartment)
# print(diff.h)
diff.tx1 = time + i*self.dt
diff.Deff = 0.8
diff.c0cleft = 1
diff.k = 0.001
rec = h.p2x3(compartment(0.5))
rec.gmax = random.gauss(g, g / 10)
rec.Ev = 5
rec2 = h.p2x2(compartment(0.5))
rec2.gmax = 0
rec2.Ev = -7
h.setpointer(diff._ref_atp, 'patp', rec)
self.recs.append(rec)
h.setpointer(diff._ref_atp, 'patp', rec2)
self.recs.append(rec2)
self.diffs.append(diff)
else:
diff = h.AtP_slow(compartment(0.5))
diff.h = self.distance(compartment, x[0], y[0], z[0])
diff.tx1 = time + 0 #+ (diff.h/1250)*1000
diff.c0cleft = 0.200
# self.diffusions.update({diff: compartment})
rec = h.p2x3(compartment(0.5))
rec.gmax = random.gauss(g, g / 10)
rec.Ev = 5
h.setpointer(diff._ref_c0cleft, '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
'''
x = [13485, 13485]
y = [1800, -1800]
z = [0, 0, 0]
if self.fast_diff:
for i in range(len(x)):
diff = h.diff_5HT(compartment(0.5))
diff.h = self.distance(compartment, x[i], y[i], z[i])
# print(compartment)
# print(diff.h)
diff.tx1 = time + i*self.dt
diff.a = 1
diff.Deff = 0.4
diff.c0cleft = 2
rec = h.r5ht3a(compartment(0.5))
rec.gmax = random.gauss(g, g / 10)
h.setpointer(diff._ref_serotonin, 'serotonin', rec)
self.recs.append(rec)
self.diffs.append(diff)
else:
diff = h.slow_5HT(compartment(0.5))
diff.h = self.distance(compartment, x[0], y[0], z[0])
diff.tx1 = time + 0 + (diff.h/50)*10#00
diff.c0cleft = 3
diff.a = 10
rec = h.r5ht3a(compartment(0.5))
rec.gmax = random.gauss(g, g / 10)
h.setpointer(diff._ref_serotonin, 'serotonin', rec)
self.diffs.append(diff)
self.recs.append(rec)
def synapses(self):
'''
Adds synapses
'''
for i in range(10):
s = h.GABAa_DynSyn(self.axon2.node[0](0.5)) # Inhibitory
self.synlistinh.append(s)
s = h.ExpSyn(self.axon2.node[0](0.5)) # Excitatory
s.tau = 0.15
s.e = 50
self.synlistex.append(s)
def connect2target(self, target):
'''
Adds presynapses
Parameters
----------
target: NEURON cell
target neuron
Returns
-------
nc: NEURON NetCon
connection between neurons
'''
nc = h.NetCon(self.axon1.node[len(self.axon1.node)-1](1)._ref_v, target, sec = self.axon1.node[len(self.axon1.node)-1])
nc.threshold = 10
return nc