def CUBA(geometry, ref=5.0, name='CUBA'): var2index = dict(V=0, ge=1, gi=2) num, geometry = nn.format_geometry(geometry) state = nn.initial_neu_state(3, num) state[0] = Vr + np.random.rand(num) * (Vt - Vr) def update_state(neu_state, t): # get neuron state not_ref = (t - neu_state[-2]) > ref not_ref_idx = np.where(not_ref)[0] # neu_state[-5] = not_ref V = neu_state[0][not_ref_idx] ge = neu_state[1][not_ref_idx] gi = neu_state[2][not_ref_idx] # calculate neuron state ge -= ge / taue * dt gi -= gi / taui * dt V += (ge + gi - (V - El)) / taum * dt neu_state[0][not_ref_idx] = V neu_state[1][not_ref_idx] = ge neu_state[2][not_ref_idx] = gi spike_idx = nn.judge_spike(neu_state, Vt, t) neu_state[0][spike_idx] = Vr return nn.Neurons(**locals())
def COBA(geometry, ref=5.0, name='COBA'): var2index = dict(V=0, ge=1, gi=2) num, geometry = nn.format_geometry(geometry) state = nn.initial_neu_state(3, num) state[0] = np.random.randn(num) * 5. - 55. def update_state(neu_state, t): # get neuron index not in refractory not_ref = (t - neu_state[-2]) > ref not_ref_idx = np.where(not_ref)[0] neu_state[-5] = not_ref # get neuron state V = neu_state[0][not_ref_idx] ge = neu_state[1][not_ref_idx] gi = neu_state[2][not_ref_idx] # calculate neuron state ge -= ge / taue * dt gi -= gi / taui * dt V += (ge * (Erev_exc - V) + gi * (Erev_inh - V) - (V - El) + I) / taum * dt neu_state[0][not_ref_idx] = V neu_state[1][not_ref_idx] = ge neu_state[2][not_ref_idx] = gi spike_idx = nn.judge_spike(neu_state, Vt, t) neu_state[0][spike_idx] = Vr return nn.Neurons(**locals())
def LIF(geometry, tau=100, V_reset=0., Vth=1.): var2index = dict(V=0) num, geometry = nn.format_geometry(geometry) state = nn.initial_neu_state(1, num) state[0] = V_reset @nn.integrate def int_f(V, t, Isyn): return (-V + Isyn) / tau def update_state(neu_state, t): V_new = int_f(neu_state[0], t, neu_state[-1]) neu_state[0] = V_new spike_idx = nn.judge_spike(neu_state, Vth, t) neu_state[0][spike_idx] = V_reset return nn.Neurons(**locals())
def COBA_HH(geometry, name='COBA_HH'): var2index = dict(V=0, m=1, h=2, n=3, ge=4, gi=5) num, geometry = nn.format_geometry(geometry) # V, m, h, n, ge, gi state = nn.initial_neu_state(6, num) state[0] = El + (np.random.randn(num_exc + num_inh) * 5 - 5) state[4] = (np.random.randn(num_exc + num_inh) * 1.5 + 4) * 10. / unit state[5] = (np.random.randn(num_exc + num_inh) * 12 + 20) * 10. / unit def update_state(neu_state, t): # get neuron state V = neu_state[0] m = neu_state[1] h = neu_state[2] n = neu_state[3] ge = neu_state[4] gi = neu_state[5] # calculate neuron state m_alpha = 0.32 * (13 - V + VT) / (np.exp((13 - V + VT) / 4) - 1.) m_beta = 0.28 * (V - VT - 40) / (np.exp((V - VT - 40) / 5) - 1) h_alpha = 0.128 * np.exp((17 - V + VT) / 18) h_beta = 4. / (1 + np.exp((40 - V + VT) / 5)) n_alpha = 0.032 * (15 - V + VT) / (np.exp((15 - V + VT) / 5) - 1.) n_beta = .5 * np.exp((10 - V + VT) / 40) # m channel fm = (m_alpha * (1 - m) - m_beta * m) dfm_dm = - m_alpha - m_beta m = m + (np.exp(dfm_dm * dt) - 1) / dfm_dm * fm neu_state[1] = m # h channel fh = (h_alpha * (1 - h) - h_beta * h) dfh_dh = - h_alpha - h_beta h = h + (np.exp(dfh_dh * dt) - 1) / dfh_dh * fh neu_state[2] = h # n channel fn = (n_alpha * (1 - n) - n_beta * n) dfn_dn = - n_alpha - h_beta n = n + (np.exp(dfn_dn * dt) - 1) / dfn_dn * fn neu_state[3] = n # ge fge = - ge / taue dfge_dge = - 1 / taue ge = ge + (np.exp(dfge_dge * dt) - 1) / dfge_dge * fge neu_state[4] = ge # gi fgi = - gi / taui dfgi_dgi = - 1 / taui gi = gi + (np.exp(dfgi_dgi * dt) - 1) / dfgi_dgi * fgi neu_state[5] = gi # V g_na_ = g_na * (m * m * m) * h g_kd_ = g_kd * (n * n * n * n) fv = (gl * (El - V) + ge * (Ee - V) + gi * (Ei - V) - g_na_ * (V - ENa) - g_kd_ * (V - EK)) / Cm dfv_dv = (-gl - ge - gi - g_na_ - g_kd_) / Cm V = V + (np.exp(dfv_dv * dt) - 1) / dfv_dv * fv neu_state[0] = V # spike nn.judge_spike(neu_state, Vt, t) return nn.Neurons(**locals())