I have two NetStim objects, one with a .start set to 0 and another with .start set to 50. When I run the model, I see two sets of spikes, one starting from 0ms and another from 50ms as expected.
Code: Select all
from neuron import h
import neuron
import numpy as np
import matplotlib.pyplot as plt
class HHNeuron():
def __init__(self):
self.soma = h.Section()
self.ap_dend = h.Section()
self.soma.L = 30
self.soma.diam = 30
self.soma.nseg = 1
self.soma.insert('hh')
self.ap_dend.L = 500
self.ap_dend.diam = 2
self.ap_dend.nseg = 23
self.ap_dend.insert('hh')
self.ap_dend.gnabar_hh = 0.012
self.ap_dend.gkbar_hh = 0.0036
self.ap_dend.gl_hh = 0.00003
self.ap_dend.connect(self.soma,1,0)
self.esyn = h.Exp2Syn(0.5,sec=self.ap_dend)
self.esyn.tau1 = 0.5
self.esyn.tau2 = 1.0
self.esyn.e = 0
tstop = 100
v_init = -65.0
hh_neuron = [HHNeuron() for i in range(2)]
stim1 = h.NetStim(0.5)
stim1.interval = 2
stim1.number = 20
stim1.start = 0
stim1.noise = 0
stim2 = h.NetStim(0.5)
stim2.interval = 2
stim2.number = 20
stim2.start = 50
stim2.noise = 0
nclist = []
nclist.append(h.NetCon(stim1, hh_neuron[0].esyn, 0.0, 0, 0.02))
nclist.append(h.NetCon(stim2, hh_neuron[0].esyn, 0.0, 0, 0.02))
nclist.append(h.NetCon(hh_neuron[0].soma(0.5)._ref_v, hh_neuron[1].esyn,10,1,0.02))
tv = h.Vector()
vs0 = h.Vector()
vs1 = h.Vector()
tv.record(h._ref_t)
vs0.record(hh_neuron[0].soma(0.5)._ref_v)
vs1.record(hh_neuron[1].soma(0.5)._ref_v)
h.finitialize(v_init)
h.fcurrent()
while h.t < tstop:
neuron.run(h.t+0.05)
ax = plt.subplot()
ax.plot(tv.as_numpy(),vs0.as_numpy())
ax.plot(tv.as_numpy(),vs1.as_numpy())
plt.xlabel('Time(ms)')
plt.ylabel('Potential (mV)')
plt.savefig('test.png')
plt.show()
Code: Select all
from neuron import h
import neuron
import numpy as np
import matplotlib.pyplot as plt
def set_ees_input(nowt):
stim2.start = nowt+10
class HHNeuron():
def __init__(self):
self.soma = h.Section()
self.ap_dend = h.Section()
self.soma.L = 30
self.soma.diam = 30
self.soma.nseg = 1
self.soma.insert('hh')
self.ap_dend.L = 500
self.ap_dend.diam = 2
self.ap_dend.nseg = 23
self.ap_dend.insert('hh')
self.ap_dend.gnabar_hh = 0.012
self.ap_dend.gkbar_hh = 0.0036
self.ap_dend.gl_hh = 0.00003
self.ap_dend.connect(self.soma,1,0)
self.esyn = h.Exp2Syn(0.5,sec=self.ap_dend)
self.esyn.tau1 = 0.5
self.esyn.tau2 = 1.0
self.esyn.e = 0
tstop = 100
v_init = -65.0
hh_neuron = [HHNeuron() for i in range(2)]
stim1 = h.NetStim(0.5)
stim1.interval = 2
stim1.number = 20
stim1.start = 0
stim1.noise = 0
stim2 = h.NetStim(0.5)
stim2.interval = 2
stim2.number = 20
stim2.start = -1
stim2.noise = 0
nclist = []
nclist.append(h.NetCon(stim1, hh_neuron[0].esyn, 0.0, 0, 0.02))
nclist.append(h.NetCon(stim2, hh_neuron[0].esyn, 0.0, 0, 0.02))
nclist.append(h.NetCon(hh_neuron[0].soma(0.5)._ref_v, hh_neuron[1].esyn,10,1,0.02))
tv = h.Vector()
vs0 = h.Vector()
vs1 = h.Vector()
tv.record(h._ref_t)
vs0.record(hh_neuron[0].soma(0.5)._ref_v)
vs1.record(hh_neuron[1].soma(0.5)._ref_v)
h.finitialize(v_init)
h.fcurrent()
stim2_set = False
while h.t < tstop:
if stim2_set == False and h.t > 40.0:
set_ees_input(40.0)
stim2_set = True
neuron.run(h.t+0.05)
ax = plt.subplot()
ax.plot(tv.as_numpy(),vs0.as_numpy())
ax.plot(tv.as_numpy(),vs1.as_numpy())
plt.xlabel('Time(ms)')
plt.ylabel('Potential (mV)')
plt.savefig('test.png')
plt.show()
Code: Select all
from neuron import h
import neuron
import numpy as np
import matplotlib.pyplot as plt
def set_ees_input(nowt):
global nclist
stim2 = h.NetStim(0.5)
stim2.interval = 2
stim2.number = 20
stim2.start = nowt+10
stim2.noise = 0
nclist.append(h.NetCon(stim2, hh_neuron[0].esyn, 0.0, 0, 0.02))
class HHNeuron():
def __init__(self):
self.soma = h.Section()
self.ap_dend = h.Section()
self.soma.L = 30
self.soma.diam = 30
self.soma.nseg = 1
self.soma.insert('hh')
self.ap_dend.L = 500
self.ap_dend.diam = 2
self.ap_dend.nseg = 23
self.ap_dend.insert('hh')
self.ap_dend.gnabar_hh = 0.012
self.ap_dend.gkbar_hh = 0.0036
self.ap_dend.gl_hh = 0.00003
self.ap_dend.connect(self.soma,1,0)
self.esyn = h.Exp2Syn(0.5,sec=self.ap_dend)
self.esyn.tau1 = 0.5
self.esyn.tau2 = 1.0
self.esyn.e = 0
tstop = 100
v_init = -65.0
hh_neuron = [HHNeuron() for i in range(2)]
stim1 = h.NetStim(0.5)
stim1.interval = 2
stim1.number = 20
stim1.start = 0
stim1.noise = 0
nclist = []
nclist.append(h.NetCon(stim1, hh_neuron[0].esyn, 0.0, 0, 0.02))
nclist.append(h.NetCon(hh_neuron[0].soma(0.5)._ref_v, hh_neuron[1].esyn,10,1,0.02))
tv = h.Vector()
vs0 = h.Vector()
vs1 = h.Vector()
tv.record(h._ref_t)
vs0.record(hh_neuron[0].soma(0.5)._ref_v)
vs1.record(hh_neuron[1].soma(0.5)._ref_v)
h.finitialize(v_init)
h.fcurrent()
stim2_set = False
while h.t < tstop:
if stim2_set == False and h.t > 40.0:
set_ees_input(40.0)
stim2_set = True
neuron.run(h.t+0.05)
ax = plt.subplot()
ax.plot(tv.as_numpy(),vs0.as_numpy())
ax.plot(tv.as_numpy(),vs1.as_numpy())
plt.xlabel('Time(ms)')
plt.ylabel('Potential (mV)')
plt.savefig('test.png')
plt.show()