Download October 25, 2009

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
'''
ODE neuron: Computation with scipy
This file integrates the DPI neuron equations.
A constant current is directly injected into the soma.
'''
#libraries and utils
import random
import scipy as sp
import numpy as np
from pylab import *
from scipy.integrate import odeint
#neuron circuit equations
def Ilk(Vm):
return ILK * (1. - exp(-(Vm/ut)) + Vm/ve)
def Ifb(Vm):
return Iinv(Vm) / ( 1. + ( (Iinv(Vm)/Io) * exp( -(vdd-v0(Vm))/ut) ))
def Iinv(Vm):
return Io * exp( (k**2 )/(k+1.) * (Vm /ut) )
def Irr(Vm, Vrr):
return IR * (1. - exp(-(Vm/ut)) ) * exp( k * Vrr/ut )
def Irf(Vm,Vrr):
return IRF * (1. - exp( - (V1(Vm,Vrr)/ut) )) *(1. - exp(-(Vrr/ut) ))
def V1(Vm,Vrr):
return ut * log( (Io*exp(k*(v0(Vm)/ut)))/(IRF) +1)
def v0(Vm):
return vdd * 1./(1. + exp(-a * ((vth1 - Vm)/ut) ))
def Iup(Vm,Vrr):
return IUP * exp( k * ((vdd-v0(Vm))/ut) ) * (1. - exp( - ((vdd-Vrr)/ut)) )
def func(y, t, current):
Vm = y[0]
Vrr = y[1]
dydt[0] = (1./Cm) * ( + Ifb(Vm) - Ilk(Vm) - Irr(Vm, Vrr) + (Inj) )
dydt[1] = (1./Cr) * ( Iup(Vm,Vrr) - Irf(Vm,Vrr) )
return dydt
#Integration parameters
D=2
numParam = 13
timestep = 0.01
timeInit = 0.
timeAqs = 5.
timetot = timeInit + timeAqs
numInitSteps = timeInit/timestep
#Injection of constant current into the soma
Inj = 1.9e-9
#Output parameters
timeStart = 0.
timeStop = timeAqs
t = sp.linspace(0, timetot, timetot/timestep + 1)
yI = zeros(D)
y = zeros(D)
p = zeros(numParam)
dydt = zeros(D)
Iinj = zeros(int(timetot/timestep + 1) )
#Number of neurons
N=1
#neurons parameters (guessed) nb: voltages are scaled in mV
Cm = 1.2e-12 #capacitor
Cr = 9.5e-15 #capacitor feedback
ut = 27.
#thermal voltage (it scales with the temperature)
ve = 500000.
#early voltage
k = 0.75
#
Io = 10.e-14
#current
vdd = 3300.
#voltage vdd
a = 0.88
#adimensional constant
vth1 = 900.
#threshold voltage
#leaky currents
IR = 1.e-15
IUP = 1.e-15
#others currents
ILK = 25.e-12
IRF = 18.e-12
#prepare result array and time arrays
t = sp.linspace(0, timetot, timetot/timestep + 1)
yI = zeros(D)
y = zeros(D)
p = zeros(numParam)
dydt = zeros(D)
#initial conditions
yI[0]=0.
yI[0]=0.
#we use odeint from scipy library
y = odeint(func, yI, t, args=(3.e-9,), full_output=True, mxstep=4000)
#save results
trace = y[0][:,0].reshape(len(y[0][:,0]),1)
filename = 'trace.dat'
savetxt(filename,trace)
#plot state variables, membrane potential and feedback signal
plot(y[0][:,1],'r*-')
plot(y[0][:,0],'b+-')
xlabel('time [ms]')
ylabel('Vr, Vm [mV]')
show()
Related documents