Auryn simulator

Simulator for spiking neural networks with synaptic plasticity

User Tools

Site Tools


examples:sim_background

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
examples:sim_background [2014/01/20 11:21] – [How to run the code] zenkeexamples:sim_background [2014/01/20 11:31] – [The important bits] zenke
Line 18: Line 18:
 ===== The important bits ===== ===== The important bits =====
  
 +Similar to other network simulations such as [[sim_isp_orig]] we start by defining two [[manual:NeuronGroup|neuron groups]]. The ''sim_background'' simulation supports a selection of different neuron models via command line parameters which is why this section looks a little more sophisticated than examples you might have encountered before. The simulation file further allows to specify the conductance ratio between AMPA and NMDA conductance via the function calls ''set_ampa_nmda_ratio(ratio)''
 +
 +<code c++>
 +    NeuronGroup * neurons_e;
 +    if ( adapt ) {
 +        neurons_e = new AIFGroup(ne);
 +        ((AIFGroup*)neurons_e)->set_ampa_nmda_ratio(ampa_nmda_ratio);
 +        ((AIFGroup*)neurons_e)->dg_adapt1=1.0;
 +    } else {
 +        if ( loadbalance ) 
 +            neurons_e = new IFGroup(ne,1.2,(1.2*ne+ni));
 +        else
 +            neurons_e = new IFGroup(ne);
 +        ((IFGroup*)neurons_e)->set_ampa_nmda_ratio(ampa_nmda_ratio);
 +    }
 +    IFGroup * neurons_i = new IFGroup(ni);
 +
 +    // initialize membranes
 +    neurons_i->set_tau_mem(10e-3);
 +    neurons_e->random_mem(-60e-3,10e-3);
 +    neurons_i->random_mem(-60e-3,10e-3);
 +
 +    ((IFGroup*)neurons_i)->set_ampa_nmda_ratio(ampa_nmda_ratio);
 +</code>
 +
 +The non-plastic connections between the different neuron groups are set up in this section 
 +<code c++>
 +msg = "Setting up I connections ...";
 +    logger->msg(msg,PROGRESS,true);
 +    SparseConnection * con_ie = new SparseConnection(neurons_i,neurons_e,
 +            w_ie,sparseness,GABA);
 +    SparseConnection * con_ii = new SparseConnection(neurons_i,neurons_i,
 +            w_ii,sparseness,GABA);
 +
 +    msg =  "Setting up E connections ...";
 +    logger->msg(msg,PROGRESS,true);
 +    SparseConnection * con_ei;
 +    if ( !ei_plastic ) {
 +        con_ei = new SparseConnection(neurons_e,neurons_i,
 +                w_ei, sparseness,GLUT);
 +    } else {
 +        if (infilename.empty()) {
 +            con_ei = new TripletConnection(neurons_e,neurons_i,
 +                w_ei, sparseness,
 +                tau_hom, eta, kappa, wmax, GLUT);
 +        } else {
 +            string str;
 +            str = infilename;
 +            str += ".ei.wmat";
 +            stringstream oss;
 +            oss << "Loading weight matrix from " << str;
 +            logger->msg(oss.str(),PROGRESS,true);
 +            con_ei = new TripletConnection(neurons_e,neurons_i,
 +                str.c_str(),
 +                tau_hom, eta, kappa, wmax, GLUT);
 +        }
 +    }
 +
 +</code>
 +
 +
 +Finally triplet STDP is setup here. The code again looks a bit more complicated since the simulation supports the use of different flavours of [[TripletSTDPConnection]], the optional addition of Gaussian noise on the initial weights the loading of a predefined connectivity matrix via [[wmat]] file.
 +<code c++>
 +TripletConnection * con_ee;
 +
 +    if (infilename.empty()) {
 +        if (decay)
 +            con_ee = new TripletDecayConnection(neurons_e,neurons_e,
 +                w_ee, sparseness,
 +                tau_hom, eta, tau_decay,
 +                kappa, wdecay, wmax, GLUT);
 +        else
 +            con_ee = new TripletConnection(neurons_e,neurons_e,
 +                w_ee, sparseness,
 +                tau_hom, eta, kappa, wmax, GLUT);
 +
 +        // con_ee->set_min_weight(wmin);
 +        if ( noisyweights )
 +            con_ee->random_data(w_ee,w_ee/4);
 +        for ( int i = 0 ; i < n_strengthen ; ++i ) {
 +            con_ee->set_data(i,i*(wmax/n_strengthen));
 +        }
 +    }
 +    else {
 +        string str;
 +        str = infilename;
 +        str += ".wmat";
 +        stringstream oss;
 +        oss << "Loading weight matrix from " << str;
 +        logger->msg(oss.str(),PROGRESS,true);
 +        if (decay)
 +            con_ee = new TripletDecayConnection(neurons_e,neurons_e,
 +                str.c_str(),tau_hom,eta,tau_decay,kappa,wdecay,wmax,GLUT);
 +        else
 +            con_ee = new TripletConnection(neurons_e,neurons_e,
 +                str.c_str(),tau_hom,eta,kappa,wmax,GLUT);
 +
 +
 +        sprintf(strbuf, "%s.e.nstate", infilename.c_str());
 +        neurons_e->load_from_file(strbuf);
 +        sprintf(strbuf, "%s.i.nstate", infilename.c_str());
 +        neurons_i->load_from_file(strbuf);
 +
 +        // primetime = 0;
 +    }
 +
 +</code>
  
examples/sim_background.txt · Last modified: 2014/03/20 09:04 by zenke