I am trying to understand how NEURON calculates membrane potential, but for some reason, I cannot figure it out. I have created a very simple model, with a single compartment
Code: Select all
proc celldef() {
topol()
subsets()
geom()
biophys()
geom_nseg()
}
create soma
proc topol() { local i
basic_shape()
}
proc basic_shape() {
soma {pt3dclear() pt3dadd(0, 0, 0, 1) pt3dadd(15, 0, 0, 1)}
}
objref all
proc subsets() { local i
objref all
all = new SectionList()
soma all.append()
}
proc geom() {
forsec all { }
soma.L = 20
soma.diam = 20
}
proc geom_nseg() {
}
proc biophys() {
soma {
Ra = 35.4
cm = 1
insert pas
g_pas = 0.001
e_pas = -20
insert hh
gnabar_hh = 0.57
gkbar_hh = 0.07
gl_hh = 0.0003
el_hh = -54.3
}
}
access soma
celldef()
Then I recorded Ik, Ina and Vm from the cell and written it to a txt.
I looked up the differential equation governing Vm, and I came upon CdV/dt =−gV +I. The solution to this equation is V(t) = 1/g * (I - (I - g*V(0)) * e^((-g*t)/C)) if I am not mistaken. Then I tried solving this in python:
Code: Select all
ik = np.loadtxt("ik.txt")
ina = np.loadtxt("ina.txt")
vm = np.loadtxt("vm.txt")
pred_vm = []
for i in range(1,ik.shape[0]):
V0 = vm[i-1]
#if i > 1:
#V0 = pred_vm[-1]
I = (ik[i]+ina[i])
g = 0.001
t = 0.025
C = 12.566371
pred_vm.append( (1/g) * (I - (I - g*V0) * np.exp((-g*t)/C)) )
#print(pred_vm[-1], vm[i])
plt.plot(pred_vm[:3000])
plt.plot(vm[0:3000])
plt.show()
plt.plot(vm)
plt.plot(pred_vm)
plt.show()
plt.plot(pred_vm[:-1], vm[2:], "go")
plt.show()
plt.plot(pred_vm[:-1] - vm[2:])