Esempio n. 1
0
def run_stdp(NE,NI,v_init,C_e,C_ii,C_ie,mon_bin,dt):
    from brian.neurongroup import NeuronGroup
    from brian.monitor import PopulationRateMonitor
    from brian.stdunits import mV, ms, nS, pF, pA, Hz
    from brian.units import second
    from brian.equations import Equations
    from brian.network import Network
    from brian.connections import Connection
    from brian.stdp import STDP
    from brian.clock import Clock

    runtime = 10*second
   
    eta = 1e-2          # Learning rate
    tau_stdp = 20*ms    # STDP time constant
    alpha = 3*Hz*tau_stdp*2  # Target rate parameter
    gmax = 100               # Maximum inhibitory weight

    eqs_neurons='''
    dv/dt=(-gl*(v-el)-(g_ampa*w*v+g_gaba*(v-er)*w)+bgcurrent)/memc : volt
    dg_ampa/dt = -g_ampa/tau_ampa : 1
    dg_gaba/dt = -g_gaba/tau_gaba : 1
    '''
    namespace = {'tau_ampa':5.0*ms,'tau_gaba':10.0*ms,
                 'bgcurrent':200*pA,'memc':200.0*pF,
                 'el':-60*mV,'w':1.*nS,'gl':10.0*nS,'er':-80*mV}
    eqs_neurons = Equations(eqs_neurons, ** namespace)

    clock = Clock(dt)
    neurons=NeuronGroup(NE+NI,model=eqs_neurons,clock=clock,
                        threshold=-50.*mV,reset=-60*mV,refractory=5*ms)
    neurons.v = v_init
    Pe=neurons.subgroup(NE)
    Pi=neurons.subgroup(NI)
    rme = PopulationRateMonitor(Pe,mon_bin)
    rmi = PopulationRateMonitor(Pi,mon_bin)
   
    con_e = Connection(Pe,neurons,'g_ampa')
    con_ie = Connection(Pi,Pe,'g_gaba')
    con_ii = Connection(Pi,Pi,'g_gaba')
    con_e.connect_from_sparse(C_e, column_access=True)
    con_ie.connect_from_sparse(C_ie, column_access=True)
    con_ii.connect_from_sparse(C_ii, column_access=True)

    eqs_istdp = '''
    dA_pre/dt=-A_pre/tau_stdp : 1
    dA_post/dt=-A_post/tau_stdp : 1
    '''
    stdp_params = {'tau_stdp':tau_stdp, 'eta':eta, 'alpha':alpha}
    eqs_istdp = Equations(eqs_istdp, **stdp_params)
    stdp_ie = STDP(con_ie, eqs=eqs_istdp,
                   pre='''A_pre+=1.
                          w+=(A_post-alpha)*eta''',
                   post='''A_post+=1.
                           w+=A_pre*eta''',
                   wmax=gmax)
   
    net = Network(neurons, con_e, con_ie, con_ii, stdp_ie, rme, rmi)
    net.run(runtime,report='text')
    return (rme.times,rme.rate), (rmi.times,rmi.rate)
Esempio n. 2
0
def test_incorrect_pre_reference():
    G = NeuronGroup(1, '''v : 1
                          x : 1''', threshold='v>1', reset='v=0')
    G.v = 1.1  # spikes
    G2 = NeuronGroup(10, '')
    # The pre-synaptic x variable should be 10 in the end, because 10 synapses
    # were created and all of them increase the pre-synaptic variable by 1.
    # This does not work in Brian 1 (but it does work in Brian 2), we therefore
    # only throw an error to avoid this problem.
    assert_raises(ValueError, lambda: Synapses(G, G2, pre='x_pre += 1'))
Esempio n. 3
0
def test_incorrect_pre_reference():
    G = NeuronGroup(1,
                    '''v : 1
                          x : 1''',
                    threshold='v>1',
                    reset='v=0')
    G.v = 1.1  # spikes
    G2 = NeuronGroup(10, '')
    # The pre-synaptic x variable should be 10 in the end, because 10 synapses
    # were created and all of them increase the pre-synaptic variable by 1.
    # This does not work in Brian 1 (but it does work in Brian 2), we therefore
    # only throw an error to avoid this problem.
    assert_raises(ValueError, lambda: Synapses(G, G2, pre='x_pre += 1'))