Goal: make below GABAa current with python
target figure
1. equation of synaptic current. I_syn(t)
t
: time.
gsyn(t)
: synaptic conductance. Here, g_syn
u(t)
: resting membrane potential. Here, E_memb
Esyn
: reversal potential. Here, E_rev
def I_syn(t, g_syn, E_memb, E_rev):
return g_syn(t)*(E_memb-E_rev)
Nothing difficult. Exact same function written from formula.
2. equation of synaptic conductance decay. g_syn(t)
g`_syn
: amplitude.
t^(f)
: arrival time of action potential
tau
: time constant of rise time.
theta(t-t^(f))
: Heavyside step function. If t^(f)
equals 0, it means event is happened at 0.
def create_g_syn(t, _g_syn=40, tf=0, tau=5):
def g_syn(t):
return _g_syn*np.exp(-(t-tf)/tau)*np.heaviside(t-tf, 1)
return g_syn
With numpy module. np.exp
and np.heaviside
usede here.
For heaviside function H(x),
second argument 0.5 is indicating value of 1/2 if x=0
.
_g_syn
is amplitude
here, defining function inside the function, we can flexibly change constants of _g_syn
, tf
, tau
.
3. equation of synaptic conductance rise and decay. g_syn2(t)
First [ ] shows rise,
Second [ ] shows decay, composed with fast and slow components.
if there is no rise element and a=1
, than it is similar with g_syn(t)
in part 2.
def create_g_syn2(t, _g_syn=40, tf=0, tau=5, tau_rise=1, a=1, tau_fast=6, tau_slow=100):
def g_syn2(t):
rise = 1-np.exp(-(t-tf)/tau_rise)
fast = a*np.exp(-(t-tf)/tau_fast)
slow = (1-a)*np.exp(-(t-tf)/tau_slow)
return _g_syn*rise*(fast+slow)*np.heaviside(t-tf, 0.5)
return g_syn2
this is creates g_syn2
function.
4. Finding constants in text.
For constant values,
5. plot and comparison of decay model and rise&decay model.
t = np.arange(-10,20, 0.1)
g_syn = create_g_syn(t, _g_syn=40, tf=0, tau=5)
y = -I_syn(t, g_syn=g_syn, E_memb=-65, E_rev=-70)
g_syn2 = create_g_syn2(t, _g_syn=40, tf=0, tau=5)
y2 = -I_syn(t, g_syn=g_syn2, E_memb=-65, E_rev=-70)
plt.plot(t, y)
plt.plot(t, y2)
6. Full code. GABAa synaptic conductance!
import numpy as np
import matplotlib.pyplot as pltdef I_syn(t, g_syn, E_memb, E_rev):
return g_syn(t)*(E_memb-E_rev)def create_g_syn(t, _g_syn=40, tf=0, tau=5):
def g_syn(t):
return _g_syn*np.exp(-(t-tf)/tau)*np.heaviside(t-tf, 0.5)
return g_syndef create_g_syn2(t, _g_syn=40, tf=0, tau=5, tau_rise=1, a=1, tau_fast=6, tau_slow=100):
def g_syn2(t):
rise = 1-np.exp(-(t-tf)/tau_rise)
fast = a*np.exp(-(t-tf)/tau_fast)
slow = (1-a)*np.exp(-(t-tf)/tau_slow)
return _g_syn*rise*(fast+slow)*np.heaviside(t-tf, 0.5)
return g_syn2t = np.arange(-10,500, 0.1)
# g_syn = create_g_syn(t, _g_syn=40, tf=0, tau=5)
# y = -I_syn(t, g_syn=g_syn, E_memb=-65, E_rev=-70)
g_syn2 = create_g_syn2(t, _g_syn=40, tf=0, tau=5)
y2 = -I_syn(t, g_syn=g_syn2, E_memb=-65, E_rev=-70)
# plt.plot(t, y)
plt.plot(t, y2)
plt.xlim(-10, 500)
plt.ylim(-300, 400)
Written for study purpose.