solving differential equation describing Vm

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
finesniper
Posts: 6
Joined: Thu Jan 14, 2016 5:23 am

solving differential equation describing Vm

Post by finesniper »

Hi All,

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()
Importantly, this model contains no current injection, but spikes continuously due to the elevated resting.

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:])

But comparing the original Vm to my solution, I found that there is a mistake somewhere. Can you please explain what I am doing wrong?
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: solving differential equation describing Vm

Post by ted »

The biggest problem is omitting i_pas.

Save your time. NEURON's numerical methods are detailed in chapter 4 of The NEURON Book.
Post Reply