| 1 |
#!/usr/bin/env python |
| 2 |
""" |
| 3 |
Slope-threshold relationship with noisy inputs, in the adaptive threshold model |
| 4 |
------------------------------------------------------------------------------- |
| 5 |
Fig. 5E,F from: |
| 6 |
|
| 7 |
Platkiewicz J and R Brette (2011). Impact of Fast Sodium Channel Inactivation on Spike |
| 8 |
Threshold Dynamics and Synaptic Integration. PLoS Comp Biol 7(5): |
| 9 |
e1001129. doi:10.1371/journal.pcbi.1001129 |
| 10 |
""" |
| 11 |
from scipy import optimize |
| 12 |
from scipy.stats import linregress |
| 13 |
|
| 14 |
from brian2 import * |
| 15 |
|
| 16 |
N = 200 # 200 neurons to get more statistics, only one is shown |
| 17 |
duration = 1*second |
| 18 |
# --Biophysical parameters |
| 19 |
ENa = 60*mV |
| 20 |
EL = -70*mV |
| 21 |
vT = -55*mV |
| 22 |
Vi = -63*mV |
| 23 |
tauh = 5*ms |
| 24 |
tau = 5*ms |
| 25 |
ka = 5*mV |
| 26 |
ki = 6*mV |
| 27 |
a = ka / ki |
| 28 |
tauI = 5*ms |
| 29 |
mu = 15*mV |
| 30 |
sigma = 6*mV / sqrt(tauI / (tauI + tau)) |
| 31 |
|
| 32 |
# --Theoretical prediction for the slope-threshold relationship (approximation: a=1+epsilon) |
| 33 |
thresh = lambda slope, a: Vi - slope * tauh * log(1 + (Vi - vT / a) / (slope * tauh)) |
| 34 |
# -----Exact calculation of the slope-threshold relationship |
| 35 |
# (note that optimize.fsolve does not work with units, we therefore let th be a |
| 36 |
# unitless quantity, i.e. the value in volt). |
| 37 |
thresh_ex = lambda s: optimize.fsolve(lambda th: (a*s*tauh*exp((Vi-th*volt)/(s*tauh))-th*volt*(1-a)-a*(s*tauh+Vi)+vT)/volt, |
| 38 |
thresh(s, a))*volt |
| 39 |
|
| 40 |
eqs = """ |
| 41 |
dv/dt=(EL-v+mu+sigma*I)/tau : volt |
| 42 |
dtheta/dt=(vT+a*clip(v-Vi, 0*mV, inf*mV)-theta)/tauh : volt |
| 43 |
dI/dt=-I/tauI+(2/tauI)**.5*xi : 1 # Ornstein-Uhlenbeck |
| 44 |
""" |
| 45 |
neurons = NeuronGroup(N, eqs, threshold="v>theta", reset='v=EL', |
| 46 |
refractory=5*ms) |
| 47 |
neurons.v = EL |
| 48 |
neurons.theta = vT |
| 49 |
neurons.I = 0 |
| 50 |
S = SpikeMonitor(neurons) |
| 51 |
M = StateMonitor(neurons, 'v', record=True) |
| 52 |
Mt = StateMonitor(neurons, 'theta', record=0) |
| 53 |
|
| 54 |
run(duration, report='text') |
| 55 |
|
| 56 |
# Linear regression gives depolarization slope before spikes |
| 57 |
tx = M.t[(M.t > 0*second) & (M.t < 1.5 * tauh)] |
| 58 |
slope, threshold = [], [] |
| 59 |
|
| 60 |
for (i, t) in zip(S.i, S.t): |
| 61 |
ind = (M.t < t) & (M.t > t - tauh) |
| 62 |
mx = M.v[i, ind] |
| 63 |
s, _, _, _, _ = linregress(tx[:len(mx)]/ms, mx/mV) |
| 64 |
slope.append(s) |
| 65 |
threshold.append(mx[-1]) |
| 66 |
|
| 67 |
# Figure |
| 68 |
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 4)) |
| 69 |
|
| 70 |
ax1.plot(M.t/ms, M.v[0]/mV, 'k') |
| 71 |
ax1.plot(Mt.t/ms, Mt.theta[0]/mV, 'r') |
| 72 |
# Display spikes on the trace |
| 73 |
spike_timesteps = np.round(S.t[S.i == 0]/defaultclock.dt).astype(int) |
| 74 |
ax1.vlines(S.t[S.i == 0]/ms, |
| 75 |
M.v[0, spike_timesteps]/mV, |
| 76 |
0, color='r') |
| 77 |
ax1.plot(S.t[S.i == 0]/ms, M.v[0, spike_timesteps]/mV, 'ro', ms=3) |
| 78 |
ax1.set(xlabel='Time (ms)', ylabel='Voltage (mV)', xlim=(0, 500), |
| 79 |
ylim=(-75, -35)) |
| 80 |
|
| 81 |
ax2.plot(slope, Quantity(threshold)/mV, 'r.') |
| 82 |
sx = linspace(0.5*mV/ms, 4*mV/ms, 100) |
| 83 |
t = Quantity([thresh_ex(s) for s in sx]) |
| 84 |
ax2.plot(sx/(mV/ms), t/mV, 'k') |
| 85 |
ax2.set(xlim=(0.5, 4), xlabel='Depolarization slope (mV/ms)', |
| 86 |
ylabel='Threshold (mV)') |
| 87 |
|
| 88 |
fig.tight_layout() |
| 89 |
plt.show() |