Skip to content

Commit d45fc5f

Browse files
author
Dilawar Singh
committed
Works with new bindings as well.
1 parent 94c186f commit d45fc5f

File tree

4 files changed

+61
-53
lines changed

4 files changed

+61
-53
lines changed

squid/electronics.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import numpy
3232
import moose
3333

34-
class ClampCircuit(moose.Neutral):
34+
class ClampCircuit(object):
3535
"""Container for a Voltage-Clamp/Current clamp circuit."""
3636
defaults = {
3737
'level1': 25.0,
@@ -41,8 +41,9 @@ class ClampCircuit(moose.Neutral):
4141
'trigMode': 0,
4242
'delay3': 1e9
4343
}
44-
def __init__(self, path, compartment):
45-
moose.Neutral.__init__(self, path)
44+
def __init__(self, path, squid):
45+
self.path = path
46+
moose.Neutral(path)
4647
self.pulsegen = moose.PulseGen(path+"/pulse") # holding voltage/current generator
4748
self.pulsegen.count = 2
4849
self.pulsegen.firstLevel = 25.0
@@ -71,15 +72,15 @@ def __init__(self, path, compartment):
7172
self.pid.saturation = 1e10
7273
# Connect current clamp circuitry
7374
moose.connect(self.pulsegen, "output", self.iclamp, "plusIn")
74-
moose.connect(self.iclamp, "output", compartment, "injectMsg")
75+
moose.connect(self.iclamp, "output", squid.C, "injectMsg")
7576
# Connect voltage clamp circuitry
7677
moose.connect(self.pulsegen, "output", self.lowpass, "injectIn")
7778
moose.connect(self.lowpass, "output", self.vclamp, "plusIn")
7879
moose.connect(self.vclamp, "output", self.pid, "commandIn")
79-
moose.connect(compartment, "VmOut", self.pid, "sensedIn")
80-
moose.connect(self.pid, "output", compartment, "injectMsg")
80+
moose.connect(squid.C, "VmOut", self.pid, "sensedIn")
81+
moose.connect(self.pid, "output", squid.C, "injectMsg")
8182
current_table = moose.Table("/data/Im")
82-
moose.connect(current_table, "requestOut", compartment, "getIm")
83+
moose.connect(current_table, "requestOut", squid.C, "getIm")
8384

8485
def configure_pulses(self, baseLevel=0.0, firstLevel=0.1, firstDelay=5.0, firstWidth=40.0, secondLevel=0.0, secondDelay=1e6, secondWidth=0.0, singlePulse=True):
8586
"""Set up the pulse generator."""

squid/squid.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self, name, compartment, specific_gbar, e_rev, Xpower, Ypower=0.0,
6161
self.chan.Xpower = Xpower
6262
self.chan.Ypower = Ypower
6363
self.chan.Zpower = Zpower
64-
moose.connect(self.chan, 'channel', compartment, 'channel')
64+
moose.connect(self.chan, 'channel', compartment.C, 'channel')
6565

6666
def setupAlpha(self, gate, params, vdivs, vmin, vmax):
6767
"""Setup alpha and beta parameters of specified gate.
@@ -118,7 +118,7 @@ def beta_h(self):
118118
return numpy.array(moose.element('%s/gateY' % (self.path)).tableB) \
119119
- numpy.array(moose.element('%s/gateY' % (self.path)).tableA)
120120

121-
class SquidAxon(moose.Compartment):
121+
class SquidAxon(object):
122122
EREST_ACT = 0.0 # can be -70 mV if not following original HH convention
123123
VMIN = -30.0
124124
VMAX = 120.0
@@ -175,7 +175,9 @@ class SquidAxon(moose.Compartment):
175175
"""Compartment class enhanced with specific values of passive
176176
electrical properties set and calculated using dimensions."""
177177
def __init__(self, path):
178-
moose.Compartment.__init__(self, path)
178+
# moose.Compartment.__init__(self, path)
179+
self.path = path
180+
self.C = moose.Compartment(self.path)
179181
self.temperature = SquidAxon.defaults['temperature']
180182
self.K_out = SquidAxon.defaults['K_out']
181183
self.Na_out = SquidAxon.defaults['Na_out']
@@ -187,10 +189,11 @@ def __init__(self, path):
187189
self.Cl_out = SquidAxon.defaults['Cl_out']
188190
self.Cl_in = SquidAxon.defaults['Cl_in']
189191

190-
self.length = SquidAxon.defaults['length']
191-
self.diameter = SquidAxon.defaults['diameter']
192-
self.Em = SquidAxon.defaults['Em']
193-
self.initVm = SquidAxon.defaults['initVm']
192+
self.C.length = SquidAxon.defaults['length']
193+
self.C.diameter = SquidAxon.defaults['diameter']
194+
self.C.Em = SquidAxon.defaults['Em']
195+
self.C.initVm = SquidAxon.defaults['initVm']
196+
194197
self.specific_cm = SquidAxon.defaults['specific_cm']
195198
self.specific_gl = SquidAxon.defaults['specific_gl']
196199
self.specific_ra = SquidAxon.defaults['specific_ra']
@@ -229,40 +232,43 @@ def reversal_potential(cls, temp, c_out, c_in):
229232
@property
230233
def xarea(self):
231234
"""Area of cross section in cm^2 when length and diameter are in um"""
232-
return 1e-8 * numpy.pi * self.diameter * self.diameter / 4.0 # cm^2
235+
return 1e-8 * numpy.pi * self.C.diameter * self.C.diameter / 4.0 # cm^2
233236

234237
@property
235238
def area(self):
236239
"""Area in cm^2 when length and diameter are in um"""
237-
return 1e-8 * self.length * numpy.pi * self.diameter # cm^2
240+
return 1e-8 * self.C.length * numpy.pi * self.C.diameter # cm^2
238241

239242
@property
240243
def specific_ra(self):
241-
return self.Ra * self.xarea / self.length
244+
return self.C.Ra * self.xarea / self.C.length
242245
@specific_ra.setter
243246
def specific_ra(self, value):
244-
self.Ra = value * self.length / self.xarea
247+
self.C.Ra = value * self.C.length / self.xarea
245248

246249
@property
247250
def specific_cm(self):
248-
return self.Cm / self.area
251+
return self.C.Cm / self.area
252+
249253
@specific_cm.setter
250254
def specific_cm(self, value):
251-
self.Cm = value * self.area
255+
self.C.Cm = value * self.area
252256

253257
@property
254258
def specific_gl(self):
255-
return 1.0/(self.Rm * self.area)
259+
return 1.0/(self.C.Rm * self.area)
260+
256261
@specific_gl.setter
257262
def specific_gl(self, value):
258-
self.Rm = 1.0/(value * self.area)
263+
self.C.Rm = 1.0/(value * self.area)
259264

260265
@property
261266
def specific_rm(self):
262-
return self.Rm * self.area
267+
return self.C.Rm * self.area
268+
263269
@specific_rm.setter
264270
def specific_rm(self, value):
265-
self.Rm = value / self.area
271+
self.C.Rm = value / self.area
266272

267273
@property
268274
def specific_gNa(self):
@@ -308,21 +314,22 @@ def use_defaults(self):
308314
for field, value in list(SquidAxon.defaults.items()):
309315
setattr(self, field, value)
310316

311-
class SquidModel(moose.Neutral):
317+
class SquidModel(object):
312318
"""Container for squid demo."""
313319
def __init__(self, path):
314-
moose.Neutral.__init__(self, path)
320+
self.path = path
321+
moose.Neutral(self.path)
315322
self.squid_axon = SquidAxon(path+'/squid_axon')
316323
print((self.squid_axon.Na_channel.chan.Gbar, self.squid_axon.K_channel.chan.Gbar))
317324
self.current_clamp = moose.PulseGen(path+'/pulsegen')
318325
self.current_clamp.firstDelay = 5.0 # ms
319326
self.current_clamp.firstWidth = 40 # ms
320327
self.current_clamp.firstLevel = 0.1 # uA
321328
self.current_clamp.secondDelay = 1e9
322-
print(('Current clamp connected:', moose.connect(self.current_clamp, 'output', self.squid_axon, 'injectMsg')))
329+
moose.connect(self.current_clamp, 'output', self.squid_axon.C, 'injectMsg')
323330

324331
self.Vm_table = moose.Table('%s/Vm' % (self.path))
325-
moose.connect(self.Vm_table, 'requestOut', self.squid_axon, 'getVm')
332+
moose.connect(self.Vm_table, 'requestOut', self.squid_axon.C, 'getVm')
326333
self.gK_table = moose.Table('%s/gK' % (self.path))
327334
moose.connect(self.gK_table, 'requestOut',
328335
self.squid_axon.K_channel.chan, 'getGk')

squid/squid_demo.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -296,23 +296,23 @@ def _createChannelControl(self):
296296
self._kConductanceToggle = QCheckBox('Block K+ channel', self._channelCtrlBox)
297297
self._kConductanceToggle.setToolTip('<html>%s</html>' % (tooltip_KChan))
298298
self._kOutLabel = QLabel('[K+]out (mM)', self._channelCtrlBox)
299-
self._kOutEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.K_out),
299+
self._kOutEdit = QLineEdit('%g' % (self.squid_setup.axon.K_out),
300300
self._channelCtrlBox)
301301
self._kOutLabel.setToolTip('<html>%s</html>' % (tooltip_Nernst))
302302
self._kOutEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
303303
set_default_line_edit_size(self._kOutEdit)
304304
self._naOutLabel = QLabel('[Na+]out (mM)', self._channelCtrlBox)
305-
self._naOutEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.Na_out),
305+
self._naOutEdit = QLineEdit('%g' % (self.squid_setup.axon.Na_out),
306306
self._channelCtrlBox)
307307
self._naOutLabel.setToolTip('<html>%s</html>' % (tooltip_Nernst))
308308
self._naOutEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
309309
set_default_line_edit_size(self._naOutEdit)
310310
self._kInLabel = QLabel('[K+]in (mM)', self._channelCtrlBox)
311-
self._kInEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.K_in),
311+
self._kInEdit = QLineEdit('%g' % (self.squid_setup.axon.K_in),
312312
self._channelCtrlBox)
313313
self._kInEdit.setToolTip(tooltip_Nernst)
314314
self._naInLabel = QLabel('[Na+]in (mM)', self._channelCtrlBox)
315-
self._naInEdit = QLineEdit('%g' % (self.squid_setup.squid_axon.Na_in),
315+
self._naInEdit = QLineEdit('%g' % (self.squid_setup.axon.Na_in),
316316
self._channelCtrlBox)
317317
self._naInEdit.setToolTip('<html>%s</html>' % (tooltip_Nernst))
318318
self._temperatureLabel = QLabel('Temperature (C)', self._channelCtrlBox)
@@ -636,19 +636,19 @@ def _runSlot(self):
636636
secondLevel=secondLevel,
637637
singlePulse=singlePulse)
638638
if self._kConductanceToggle.isChecked():
639-
self.squid_setup.squid_axon.specific_gK = 0.0
639+
self.squid_setup.axon.specific_gK = 0.0
640640
else:
641-
self.squid_setup.squid_axon.specific_gK = SquidAxon.defaults['specific_gK']
641+
self.squid_setup.axon.specific_gK = SquidAxon.defaults['specific_gK']
642642
if self._naConductanceToggle.isChecked():
643-
self.squid_setup.squid_axon.specific_gNa = 0.0
643+
self.squid_setup.axon.specific_gNa = 0.0
644644
else:
645-
self.squid_setup.squid_axon.specific_gNa = SquidAxon.defaults['specific_gNa']
646-
self.squid_setup.squid_axon.celsius = self.getFloatInput(self._temperatureEdit, self._temperatureLabel.text())
647-
self.squid_setup.squid_axon.K_out = self.getFloatInput(self._kOutEdit, self._kOutLabel.text())
648-
self.squid_setup.squid_axon.Na_out = self.getFloatInput(self._naOutEdit, self._naOutLabel.text())
649-
self.squid_setup.squid_axon.K_in = self.getFloatInput(self._kInEdit, self._kInLabel.text())
650-
self.squid_setup.squid_axon.Na_in = self.getFloatInput(self._naInEdit, self._naInLabel.text())
651-
self.squid_setup.squid_axon.updateEk()
645+
self.squid_setup.axon.specific_gNa = SquidAxon.defaults['specific_gNa']
646+
self.squid_setup.axon.celsius = self.getFloatInput(self._temperatureEdit, self._temperatureLabel.text())
647+
self.squid_setup.axon.K_out = self.getFloatInput(self._kOutEdit, self._kOutLabel.text())
648+
self.squid_setup.axon.Na_out = self.getFloatInput(self._naOutEdit, self._naOutLabel.text())
649+
self.squid_setup.axon.K_in = self.getFloatInput(self._kInEdit, self._kInLabel.text())
650+
self.squid_setup.axon.Na_in = self.getFloatInput(self._naInEdit, self._naInLabel.text())
651+
self.squid_setup.axon.updateEk()
652652
self.squid_setup.schedule(self._simdt, self._plotdt, clampMode)
653653
# The following line is for use with Qthread
654654
self.squid_setup.run(self._runtime)

squid/squid_setup.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,36 @@ def __init__(self):
3838
self.scheduled = False
3939
self.model_container = moose.Neutral('/model')
4040
self.data_container = moose.Neutral('/data')
41-
self.squid_axon = SquidAxon('/model/squid_axon')
42-
self.clamp_ckt = ClampCircuit('/model/electronics', self.squid_axon)
41+
self.axon = SquidAxon('/model/axon')
42+
self.clamp_ckt = ClampCircuit('/model/electronics', self.axon)
4343
self.simdt = 0.0
4444
self.plotdt = 0.0
4545
self.setup_recording()
4646

4747
def setup_recording(self):
4848
# Setup data collection
4949
self.vm_table = moose.Table('/data/Vm')
50-
moose.connect(self.vm_table, 'requestOut', self.squid_axon, 'getVm')
50+
moose.connect(self.vm_table, 'requestOut', self.axon.C, 'getVm')
5151
self.cmd_table = moose.Table('/data/command')
5252
moose.connect(self.cmd_table, 'requestOut', self.clamp_ckt.vclamp, 'getOutputValue')
5353
self.iclamp_table = moose.Table('/data/Iclamp')
5454
moose.connect(self.iclamp_table, 'requestOut', self.clamp_ckt.iclamp, 'getOutputValue')
5555
self.vclamp_table = moose.Table('/data/Vclamp')
5656
moose.connect(self.vclamp_table, 'requestOut', self.clamp_ckt.pid, 'getOutputValue')
5757
self.m_table = moose.Table('/data/m')
58-
moose.connect(self.m_table, 'requestOut', self.squid_axon.Na_channel, 'getX')
58+
moose.connect(self.m_table, 'requestOut', self.axon.Na_channel.chan, 'getX')
5959
self.h_table = moose.Table('/data/h')
60-
moose.connect(self.h_table, 'requestOut', self.squid_axon.Na_channel, 'getY')
60+
moose.connect(self.h_table, 'requestOut', self.axon.Na_channel.chan, 'getY')
6161
self.n_table = moose.Table('/data/n')
62-
moose.connect(self.n_table, 'requestOut', self.squid_axon.K_channel, 'getX')
62+
moose.connect(self.n_table, 'requestOut', self.axon.K_channel.chan, 'getX')
6363
self.ina_table = moose.Table('/data/INa')
64-
moose.connect(self.ina_table, 'requestOut', self.squid_axon.Na_channel, 'getIk')
64+
moose.connect(self.ina_table, 'requestOut', self.axon.Na_channel.chan, 'getIk')
6565
self.ik_table = moose.Table('/data/IK')
66-
moose.connect(self.ik_table, 'requestOut', self.squid_axon.K_channel, 'getIk')
66+
moose.connect(self.ik_table, 'requestOut', self.axon.K_channel.chan, 'getIk')
6767
self.gna_table = moose.Table('/data/GNa')
68-
moose.connect(self.gna_table, 'requestOut', self.squid_axon.Na_channel, 'getGk')
68+
moose.connect(self.gna_table, 'requestOut', self.axon.Na_channel.chan, 'getGk')
6969
self.gk_table = moose.Table('/data/GK')
70-
moose.connect(self.gk_table, 'requestOut', self.squid_axon.K_channel, 'getGk')
70+
moose.connect(self.gk_table, 'requestOut', self.axon.K_channel.chan, 'getGk')
7171

7272
def schedule(self, simdt, plotdt, clampmode):
7373
self.simdt = simdt
@@ -85,7 +85,7 @@ def schedule(self, simdt, plotdt, clampmode):
8585
moose.useClock(0, '%s/#[TYPE=Compartment]' % (self.model_container.path), 'init')
8686
moose.useClock(0, '%s/##' % (self.clamp_ckt.path), 'process')
8787
moose.useClock(1, '%s/#[TYPE=Compartment]' % (self.model_container.path), 'process')
88-
moose.useClock(2, '%s/#[TYPE=HHChannel]' % (self.squid_axon.path), 'process')
88+
moose.useClock(2, '%s/#[TYPE=HHChannel]' % (self.axon.path), 'process')
8989
moose.useClock(3, '%s/#[TYPE=Table]' % (self.data_container.path), 'process')
9090
self.scheduled = True
9191
moose.reinit()

0 commit comments

Comments
 (0)