time shift in SEClamp
Posted: Fri Feb 05, 2016 8:50 am
I played a vector into a SEClamp and then recorded the membrane potential to see whether it matches the played vector but it did not. Firstly the beginning can be quite different if v_init does not match the first value in the played vector. But also the second value still did not match. Secondly, all the following values resembled the played vector more but still deviated by a certain amount.
Why is this the case?
How can one get exactly the membrane potential that was feeded into the SEClamp?
In the end I also want the current traces to correspond to the current produced at the clamped potential. How can the current trace be matched to the clamped potential? (probably the same answer as for the question above).
The following code demonstrates the problem:
Why is this the case?
How can one get exactly the membrane potential that was feeded into the SEClamp?
In the end I also want the current traces to correspond to the current produced at the clamped potential. How can the current trace be matched to the clamped potential? (probably the same answer as for the question above).
The following code demonstrates the problem:
Code: Select all
from neuron import h
import numpy as np
import pylab as pl
h.load_file("stdrun.hoc") # load NEURON libraries
h("""cvode.active(0)""") # unvariable time step in NEURON
# create simple cell model
cell = h.Section(name='soma')
cell.cm = 1
cell.Ra = 100
cell.diam = 100
cell.L = 100
cell.nseg = 1
cell.insert('pas')
# create membrane potential trace
tstop = 50
dt = 0.025
t = np.arange(0, tstop+dt, dt)
v = np.linspace(-80, -50, len(t))
t_clamp = h.Vector()
t_clamp.from_python(t)
v_clamp = h.Vector()
v_clamp.from_python(v)
# seclamp
stim = h.SEClamp(0.5, sec=cell)
stim.rs = 1e-3 # series resistance should be much smaller than input resistance of the cell
stim.dur1 = 1e9
v_clamp.play(stim._ref_amp1, dt)
# recordings
ipas = h.Vector()
ipas.record(cell(.5).pas._ref_i)
v_rec = h.Vector()
v_rec.record(cell(.5)._ref_v)
t_rec = h.Vector()
t_rec.record(h._ref_t)
# run simulation
h.tstop = t[-1] + dt
h.dt = dt
# h.v_init = np.array(v_clamp)[0]
h.init()
h.run()
# plot
f, (ax1, ax2) = pl.subplots(2, 1, sharex=True)
ax1.plot(np.array(t_rec), np.array(v_rec), 'k', label='recorded v')
ax1.plot(np.array(t_clamp), np.array(v_clamp), 'b', label='clamped v')
ax1.set_ylabel('Membrane\npotential (mV)')
ax2.plot(np.array(t_rec), np.array(ipas), 'k', label='ipas')
ax2.set_ylabel('Current (mA/cm2)')
ax2.set_xlabel('Time (ms)')
ax1.legend()
pl.show()