So far, I have used the vector play command successfully to drive a current clamp with this external file, but I am struggling to get it to work properly to drive my extracellular potential.
For some reason, within my "for seg" loop that sets up the temporal Vext at each segment, only the last segment in the neuron seems to adopt the assigned characteristics. I have done a RangeVarPlot on Vext[0] at times when the field should be "on", and rather than being a linear increase across the length of the axon, it is 0 across the whole length until the last segment. Any help would be appreciated.
Here is my code (csv can be found here: https://drive.google.com/drive/folders/ ... share_link):
Code: Select all
from neuron import h
from neuron.units import ms, mV
import matplotlib.pyplot as plt
import numpy as np
h.load_file("stdrun.hoc")
# Simulation Params
trun = 10
# Set Up Axon Properties
axon = h.Section(name = "axon")
axon.L = 1000
axon.nseg = 101
axon.diam = 1
seglen = axon.L/axon.nseg # um
# Set Up External Field
Field = 100 # V/cm
FieldScaled = Field*1e-4*1e3 # need mV/um multiply by 1 cm/10000 um and by 1000 mV/V
axon.insert(h.hh)
h.nlayer_extracellular(1)
axon.insert(h.extracellular)
# Extracellular Stimulus
Data = np.loadtxt("wform.csv",delimiter=",")
tvals = Data[:,0]
Ivals = Data[:,1]
AMPvec = h.Vector().from_python(Ivals)
tvec = h.Vector(np.linspace(0,tvals[-1],len(tvals)))
h.dt = tvals[1]-tvals[0]
for seg in axon:
potential = seg.x*FieldScaled*axon.L
holdvec = AMPvec.c()
tmpvec = holdvec.mul(potential)
tmpvec.play(axon(seg.x)._ref_e_extracellular,tvec)
t = h.Vector().record(h._ref_t)
v = h.Vector().record(axon(0.1)._ref_v)
ik = h.Vector().record(axon(0.1)._ref_ik)
ina = h.Vector().record(axon(0.1)._ref_ina)
vex0 = h.Vector().record(axon(0.5)._ref_vext[0])
vex1 = h.Vector().record(axon(1)._ref_vext[0])
# Run
h.tstop = trun*ms
h.run()
# Plots
plt.figure()
plt.plot(t,v)
plt.figure()
plt.plot(t,vex0,label = "Vext at middle")
plt.plot(t,vex1,label = "Vext at end")
plt.legend()
plt.figure()
plt.plot(t,ina,label = "ina")
plt.plot(t,ik, label = "ik")
plt.legend()
plt.show()