So, since my neural networks were responding properly to set stimulus using Iclamps, I figured I would test out NetStim using a single neural compartment. I couldn't get that to work either! My code for this is below; what am I missing?
Code: Select all
from neuron import *
from neuron import h as nrn
from numpy import *
from neuronGen import *
from pylab import *
soma = h.Section()
stimNc = h.NetStim()
stimNc.noise = 0
stimNc.start = 1
stimNc.number = 1000
stimNc.interval = 0.1
soma.push()
stim = h.NetCon(soma(0.5)._ref_v, stimNc)
stim.weight[0] = 1
vec = {}
for var in 'v_1 ','t ':
vec[var] = h.Vector()
# record the membrane potentials and
# synaptic currents
vec['v_1 '].record(soma(0.5)._ref_v)
vec ['t '].record(h._ref_t)
# run the simulation
h.load_file("stdrun.hoc")
h.init()
h.tstop = 20.0
h.run()
# plot the results
figure()
plot(vec['t '],vec['v_1 '])
show()
Code: Select all
VecSoma= h.Vector()
VecSoma.record(neuron(0.5)._ref_v)
stim = h.IClamp(neuron(0))
stim.dur = simTime
vecCurrent = h.Vector()
vecCurrent.record(stim._ref_i)
time = h.Vector()
time.record(h._ref_t)
listOfStims = []
listOfTimes = []
times = linspace(0,1000,40001) #For 1000 simulation length
for i in times:
a = random.randint(1, 100)
if a > 90:
listOfStims.append(5)
else:
listOfStims.append(0)
#a = random.uniform(0,8)
#listOfStims.append(3)
#listOfTimes.append(i)
VecT = h.Vector(listOfTimes)
VecStim = h.Vector(listOfStims)
VecStim.play(stim._ref_amp, VecT, 1)