コード例 #1
0
    def __init__(
        self,
        size,
        tau_neu=10.,
        tau_syn=0.5,
        tau_ref=2.,
        V_reset=-65.,
        V_th=-50.,
        Cm=0.25,
    ):
        super(LIF, self).__init__(size=size)

        # parameters
        self.tau_neu = tau_neu  # membrane time constant [ms]
        self.tau_syn = tau_syn  # Post-synaptic current time constant [ms]
        self.tau_ref = tau_ref  # absolute refractory period [ms]
        self.Cm = Cm  # membrane capacity [nF]
        self.V_reset = V_reset  # reset potential [mV]
        self.V_th = V_th  # fixed firing threshold [mV]
        self.Iext = 0.  # constant external current [nA]

        # variables
        self.V = bm.Variable(-65. + 5.0 * bm.random.randn(self.num))  # [mV]
        self.I = bm.Variable(bm.zeros(self.num))  # synaptic currents [nA]
        self.spike = bm.Variable(bm.zeros(self.num, dtype=bool))
        self.t_last_spike = bm.Variable(bm.ones(self.num) * -1e7)

        # function
        self.integral = bp.odeint(bp.JointEq([self.dV, self.dI]),
                                  method='exp_auto')
コード例 #2
0
  def test_ode2(self):
    a, b, tau=0.7, 0.8, 12.5
    dV = lambda V, t, w, Iext:  V - V * V * V / 3 - w + Iext
    dw = lambda w, t, V: (V + a - b * w) / tau
    fhn = bp.odeint(bp.JointEq([dV, dw]), method='rk4', dt=0.1)

    runner = bp.IntegratorRunner(fhn, monitors=['V', 'w'], inits=[1., 1.], args=dict(Iext=1.5))
    runner.run(100.)
    bp.visualize.line_plot(runner.mon.ts, runner.mon['V'], legend='V')
    bp.visualize.line_plot(runner.mon.ts, runner.mon['w'], legend='w', show=True)
コード例 #3
0
  def test_ode3(self):
    a, b, tau=0.7, 0.8, 12.5
    dV = lambda V, t, w, Iext:  V - V * V * V / 3 - w + Iext
    dw = lambda w, t, V: (V + a - b * w) / tau
    fhn = bp.odeint(bp.JointEq([dV, dw]), method='rk4', dt=0.1)

    Iext, duration = bp.inputs.section_input([0., 1., 0.5], [200, 500, 200], return_length=True)
    runner = bp.IntegratorRunner(fhn, monitors=['V', 'w'], inits=[1., 1.],
                                 dyn_args=dict(Iext=Iext))
    runner.run(duration)
    bp.visualize.line_plot(runner.mon.ts, runner.mon['V'], legend='V')
    bp.visualize.line_plot(runner.mon.ts, runner.mon['w'], legend='w', show=True)
コード例 #4
0
    def __init__(self, size, method='exp_auto'):
        super(HH, self).__init__(size)

        # variables
        self.V = bm.Variable(El + (bm.random.randn(self.num) * 5 - 5))
        self.m = bm.Variable(bm.zeros(self.num))
        self.n = bm.Variable(bm.zeros(self.num))
        self.h = bm.Variable(bm.zeros(self.num))
        self.spike = bm.Variable(bm.zeros(self.num, dtype=bool))
        self.input = bm.Variable(bm.zeros(size))

        def dV(V, t, m, h, n, Isyn):
            gna = g_Na * (m * m * m) * h
            gkd = g_Kd * (n * n * n * n)
            dVdt = (-gl * (V - El) - gna * (V - ENa) - gkd *
                    (V - EK) + Isyn) / Cm
            return dVdt

        def dm(
            m,
            t,
            V,
        ):
            m_alpha = 0.32 * (13 - V + VT) / (bm.exp((13 - V + VT) / 4) - 1.)
            m_beta = 0.28 * (V - VT - 40) / (bm.exp((V - VT - 40) / 5) - 1)
            dmdt = (m_alpha * (1 - m) - m_beta * m)
            return dmdt

        def dh(h, t, V):
            h_alpha = 0.128 * bm.exp((17 - V + VT) / 18)
            h_beta = 4. / (1 + bm.exp(-(V - VT - 40) / 5))
            dhdt = (h_alpha * (1 - h) - h_beta * h)
            return dhdt

        def dn(n, t, V):
            c = 15 - V + VT
            n_alpha = 0.032 * c / (bm.exp(c / 5) - 1.)
            n_beta = .5 * bm.exp((10 - V + VT) / 40)
            dndt = (n_alpha * (1 - n) - n_beta * n)
            return dndt

        # functions
        self.integral = bp.odeint(bp.JointEq([dV, dm, dh, dn]), method=method)
コード例 #5
0
    def __init__(self, num, C=135., method='exp_auto'):
        super(JansenRitModel, self).__init__()

        self.num = num

        # parameters #
        self.v_max = 5.  # maximum firing rate
        self.v0 = 6.  # firing threshold
        self.r = 0.56  # slope of the sigmoid
        # other parameters
        self.A = 3.25
        self.B = 22.
        self.a = 100.
        self.tau_e = 0.01  # second
        self.tau_i = 0.02  # second
        self.b = 50.
        self.e0 = 2.5
        # The connectivity constants
        self.C1 = C
        self.C2 = 0.8 * C
        self.C3 = 0.25 * C
        self.C4 = 0.25 * C

        # variables #
        # y0, y1 and y2 representing the firing rate of
        # pyramidal, excitatory and inhibitory neurones.
        self.y0 = bm.Variable(bm.zeros(self.num))
        self.y1 = bm.Variable(bm.zeros(self.num))
        self.y2 = bm.Variable(bm.zeros(self.num))
        self.y3 = bm.Variable(bm.zeros(self.num))
        self.y4 = bm.Variable(bm.zeros(self.num))
        self.y5 = bm.Variable(bm.zeros(self.num))
        self.p = bm.Variable(bm.ones(self.num) * 220.)

        # integral function
        self.derivative = bp.JointEq(
            [self.dy0, self.dy1, self.dy2, self.dy3, self.dy4, self.dy5])
        self.integral = bp.odeint(self.derivative, method=method)
コード例 #6
0
 def derivative(self):
     return bp.JointEq([self.dp, self.dq])
コード例 #7
0
ファイル: AdExIF.py プロジェクト: PKU-NIP-Lab/BrainModels
 def derivative(self):
   return bp.JointEq([self.dV, self.dw])
コード例 #8
0
ファイル: dual_exp.py プロジェクト: PKU-NIP-Lab/BrainModels
 def derivative(self):
     dg = lambda g, t, h: -g / self.tau_decay + h
     dh = lambda h, t: -h / self.tau_rise
     return bp.JointEq([dg, dh])
コード例 #9
0
ファイル: NMDA.py プロジェクト: PKU-NIP-Lab/BrainModels
 def derivative(self):
     dg = lambda g, t, x: -g / self.tau_decay + self.a * x * (1 - g)
     dx = lambda x, t: -x / self.tau_rise
     return bp.JointEq([dg, dx])
コード例 #10
0
ファイル: GIF.py プロジェクト: PKU-NIP-Lab/BrainModels
 def derivative(self):
     return bp.JointEq([self.dI1, self.dI2, self.dVth, self.dV])
コード例 #11
0
ファイル: HH.py プロジェクト: PKU-NIP-Lab/BrainModels
 def derivative(self):
     return bp.JointEq([self.dV, self.dm, self.dh, self.dn])