-
Notifications
You must be signed in to change notification settings - Fork 1
/
interneuron.py
201 lines (182 loc) · 5.26 KB
/
interneuron.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
from neuron import h, gui
import random
import random
class interneuron(object):
'''
Interneuron class with parameters:
delay: bool
Does it have 5ht receptors?
-Yes: True
-No: False
soma: NEURON Section (creates by topol())
dend: NEURON Section (creates by topol())
axon: NEURON Section (creates by topol())
synlistinh: list (creates by synapses())
list of inhibitory synapses
synlistex: list (creates by synapses())
list of excitatory synapses
synlistees: list (creates by synapses())
list of excitatory synapses for connection with generators
x, y, z: int
3D coordinates (isn't used)
diffs: list
list of diffusion mechanisms (NEURON staff)
recs: list
list of receptors mechanisms (NEURON staff)
'''
def __init__(self, delay=False, stdp=False):
self.delay = delay
self.stdp = stdp
self.diffs = []
self.recs = []
self.topol()
# self.subsets()
self.geom()
# self.geom_nseg()
self.biophys()
self.synlistinh = []
self.synlistex = []
self.synlistees = []
self.synapses()
self.x = self.y = self.z = 0.
def __del__(self):
#print 'delete ', self
pass
def topol(self):
'''
Creates sections soma, dend, axon and connects them
if it's delay creates section dend[]: array
'''
self.soma = h.Section(name='soma', cell=self)
self.axon = h.Section(name='axon', cell= self)
self.dend = [h.Section(name='dend[%d]' % i) for i in range(random.randint(5,10))]
for sec in self.dend:
sec.connect(self.soma(0.5))
self.axon.connect(self.soma(1))
self.all_secs = h.SectionList()
# for sec in self.branch:
self.all_secs.append(sec=self.soma)
self.all_secs.append(sec=self.axon)
for sec in self.dend:
self.all_secs.append(sec=sec)
def subsets(self):
'''
NEURON staff
adds sections in NEURON SectionList
'''
self.all = h.SectionList()
# for sec in h.allsec():
# self.all.append(sec=sec)
def geom(self):
'''
Adds length and diameter to sections
'''
self.soma.L = self.soma.diam = 10#random.randint(5, 15) # microns
self.axon.L = 150 # microns
self.axon.diam = 1 # microns
for sec in self.dend:
sec.L = 200 # microns
sec.diam = 1#random.gauss(1, 0.1) # microns
def geom_nseg(self):
'''
Calculates numder of segments in section
'''
for sec in self.all:
sec.nseg = int((sec.L/(0.1*h.lambda_f(100)) + .9)/2.)*2 + 1
def biophys(self):
'''
Adds channels and their parameters
if delay is true, adds 5ht receptors
'''
# for sec in self.all:
# sec.cm = 1#random.gauss(1, 0.01) # cm uf/cm2 - membrane capacitance
self.soma.Ra = 100 # Ra ohm cm - membrane resistance
self.soma.insert('fastchannels')
self.soma.gnabar_fastchannels = 0.2
self.soma.gkbar_fastchannels = 0.08
self.soma.gl_fastchannels = 0.001
# self.soma.el_fastchannels = -70
self.soma.insert('extracellular') #adds extracellular mechanism for recording extracellular potential
for sec in self.dend:
sec.Ra = 100 # Ra ohm cm - membrane resistance
for sec in self.dend:
if self.delay:
sec.insert('fastchannels')
sec.gnabar_fastchannels = 0.35
sec.gkbar_fastchannels = 0.04
sec.gl_fastchannels = 0.001
self.add_5HTreceptors(sec, 10, 18)
else:
# sec.insert('pas')
sec.insert('fastchannels')
sec.gnabar_fastchannels = 0.1
sec.gkbar_fastchannels = 0.04
sec.gl_fastchannels = 0.001
# sec.g_pas = 0.0002
# sec.e_pas = -60
self.axon.Ra = 50
self.axon.insert('fastchannels')
self.axon.gnabar_fastchannels = 0.025
self.axon.gkbar_fastchannels = 0.02
self.axon.gl_fastchannels = 0.0001
self.axon.el_fastchannels = -65
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
'''
diff = h.slow_5HT(compartment(0.5))
diff.h = random.uniform(10, 2500)
diff.tx1 = time + 0 + (diff.h/50)*10#00
diff.c0cleft = 3
diff.a = 0.1
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 position(self, x, y, z):
'''
NEURON staff
Adds 3D position
'''
soma.push()
for i in range(h.n3d()):
h.pt3dchange(i, x-self.x+h.x3d(i), y-self.y+h.y3d(i), z-self.z+h.z3d(i), h.diam3d(i))
self.x = x; self.y = y; self.z = z
h.pop_section()
def connect2target(self, target):
'''
NEURON staff
Adds presynapses
Parameters
----------
target: NEURON cell
target neuron
Returns
-------
nc: NEURON NetCon
connection between neurons
'''
nc = h.NetCon(self.soma(1)._ref_v, target, sec = self.soma)
nc.threshold = 0
return nc
def synapses(self):
'''
Adds synapses
'''
for i in range(10):
s = h.GABAa_DynSyn(self.soma(0.5)) # Inhibitory
self.synlistinh.append(s)
#
def is_art(self):
return 0