def get_synapses(name, source, target, tau_I, A, U, tau_rec, tau_facil=None):
    """Construct connections and retrieve synapses

    name -- name of synapses
    source -- source of connections
    target -- target of connections
    tau_I -- inactivation time constant
    A -- absolute synaptic strength
    U -- utilization of synaptic efficacy
    tau_rec -- recovery time constant
    tau_facil -- facilitation time constant (optional)
    """

    synapses_eqs = """
    A : volt
    U : 1
    tau_I : second
    tau_rec : second

    dx/dt =  z/tau_rec : 1 (clock-driven) # recovered
    dy/dt = -y/tau_I   : 1 (clock-driven) # active
    z = 1 - x - y      : 1                # inactive
    I_syn_{}_post = A*y : volt (summed)
    """.format(name)

    if tau_facil:
        synapses_eqs += """
        du/dt = -u/tau_facil : 1 (clock-driven)
        tau_facil : second
        """

        synapses_action = """
        u += U*(1-u)
        y += u*x # important: update y first
        x += -u*x
        """
    else:
        synapses_action = """
        y += U*x # important: update y first
        x += -U*x
        """

    synapses = Synapses(
        source,
        target,
        model=synapses_eqs,
        on_pre=synapses_action,
        method="exact",
        name=name,
    )
    synapses.connect(p=0.1)

    N_syn = len(synapses)

    synapses.tau_I = tau_I

    A_min = min(0.2 * A, 2 * A)
    A_max = max(0.2 * A, 2 * A)
    synapses.A = (truncated_normal(
        A / mV, 0.5 * abs(A / mV), [A_min / mV, A_max / mV], size=N_syn) * mV)
    assert not any(synapses.A < A_min)
    assert not any(synapses.A > A_max)

    U_mean, U_min, U_max = U
    synapses.U = truncated_normal(U_mean,
                                  0.5 * U_mean, [U_min, U_max],
                                  size=N_syn)
    assert not any(synapses.U <= U_min)
    assert not any(synapses.U > U_max)

    tau_min = 5
    synapses.tau_rec = (truncated_normal(
        tau_rec / ms, 0.5 * tau_rec / ms, [tau_min, np.inf], size=N_syn) * ms)
    assert not any(synapses.tau_rec / ms <= tau_min)

    if tau_facil:
        synapses.tau_facil = (
            truncated_normal(tau_facil / ms,
                             0.5 * tau_facil / ms, [tau_min, np.inf],
                             size=N_syn) * ms)
        assert not any(synapses.tau_facil / ms <= tau_min)

    # start fully recovered
    synapses.x = 1

    return synapses
Exemple #2
0
        D=0.144 * second,
        F=0.06 * second,
        delay=0.8 * ms,
    )

    # place holder for stimulus
    stimulus = SpikeGeneratorGroup(1, [], [] * ms, name="stimulus")

    spike_monitor_stimulus = SpikeMonitor(stimulus)

    static_synapses_exc = Synapses(stimulus,
                                   exc_neurons,
                                   "A : ampere (shared, constant)",
                                   on_pre="I_stimulus += A")
    static_synapses_exc.connect(p=1)
    static_synapses_exc.A = 18 * nA

    static_synapses_inh = Synapses(stimulus,
                                   inh_neurons,
                                   "A : ampere (shared, constant)",
                                   on_pre="I_stimulus += A")
    static_synapses_inh.connect(p=1)
    static_synapses_inh.A = 9 * nA

    spike_monitor_exc = SpikeMonitor(exc_neurons, name="spike_monitor_exc")
    spike_monitor_inh = SpikeMonitor(inh_neurons, name="spike_monitor_inh")

    defaultclock.dt = DT

    net = Network([
        neurons,