Created
May 21, 2018 21:36
-
-
Save kingjr/16a4c5a6a2b9669460f218450631da07 to your computer and use it in GitHub Desktop.
Wang and Wong perceptual decision making model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Wang and Wong 2006 perceptual decision making model | |
adapted from https://github.com/xjwanglab/book/blob/b0a8e775a9f687cefbcbb4fcbe3fc19b6343bd70/wong2006/wong2006.py # noqa | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def run(coherence=.3): | |
NT = 4000 | |
t_plot = np.arange(NT) | |
t_stim = (t_plot > 100) * (t_plot < 1000) | |
mean_stim = np.ones(NT)*0.0104 | |
diff_stim = mean_stim*coherence | |
Istim = np.array([(mean_stim + diff_stim) * t_stim, | |
(mean_stim - diff_stim) * t_stim]) | |
# Initialize S1 and S | |
S = np.zeros((2, NT)) | |
r = np.zeros((2, NT)) | |
S[:, 0] = .1 | |
# Loop over time points in a trial | |
for t in xrange(NT-1): | |
# Firing ratea | |
I0 = 0.3255 | |
gE = 0.2609 | |
gI = -0.0497 | |
def F(I, a=270., b=108., d=0.154): | |
# Relu | |
return (a*I - b)/(1.-np.exp(-d*(a*I - b))) | |
r[0, t] = F(gE*S[0, t] + gI*S[1, t] + Istim[0, t] + I0) | |
r[1, t] = F(gE*S[1, t] + gI*S[0, t] + Istim[1, t] + I0) | |
# Mean NMDA-mediated synaptic dynamics updating | |
gamma = 0.641 * 0.0005 | |
S[:, t+1] = S[:, t] * (.995 - gamma*r[:, t]) + gamma*r[:, t] | |
return r, S | |
coherences = (.1, .3, .5, .9) | |
cmap = plt.get_cmap('viridis') | |
colors = cmap(np.linspace(0, 1, len(coherences))) | |
fig, axes = plt.subplots(2, 1) | |
for coherence, color in zip(coherences, colors): | |
r, S = run(coherence) | |
axes[0].plot(S[0], color=color) | |
axes[0].plot(S[1], color=color, linestyle=':') | |
axes[1].plot(r[0], color=color) | |
axes[1].plot(r[1], color=color, linestyle=':') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment