Auryn simulator

Simulator for spiking neural networks with synaptic plasticity

User Tools

Site Tools


examples:sim_coba_benchmark

This is an old revision of the document!


sim_coba_benchmark

This is the Vogels-Abbott Benchmark (from Brette et al. 2007) network adapted from the examples included in PyNN. It implements a smaller version of the conductance based, self-sustained balanced network from (Vogels and Abbott (2005)).

Running the program

To run the program the network first needs priming with external Poisson noise before it can self-sustain its activity. To do that invoke the program with the following command line arguments

./sim_coba_benchmark --dir /tmp --simtime 5

The prime keyword in the first command causes the network to run with external Poisson input and save its network state at the end of the run to a set of files created under /tmp. Note that you can give any other directory name where you want the files to be created. The second call to the progrem without the –prime argument causes the program to read the current network state from these saved files and runs the network for the specified period in simtime. All spiking output and the memory trace (mem file) of a single neuron are written to the directory specified with –dir and are prefixed with coba.*.

If you are interested in running the code in parallel please see the parallel execution howto.

Output example

In the above example the output is written to /tmp.

bash-4.1$ ls -l /tmp/coba.0.*
   8 -rw-r--r-- 1 zenke lcn1    5447 Jan 13 11:17 /tmp/coba.0.log
3208 -rw-r--r-- 1 zenke lcn1 3282541 Jan 13 11:17 /tmp/coba.0.e.ras
 764 -rw-r--r-- 1 zenke lcn1  780757 Jan 13 11:17 /tmp/coba.0.i.ras
 928 -rw-r--r-- 1 zenke lcn1  950019 Jan 13 11:17 /tmp/coba.0.e.mem
 916 -rw-r--r-- 1 zenke lcn1  935976 Jan 13 11:17 /tmp/coba.0.e.gaba
 880 -rw-r--r-- 1 zenke lcn1  900018 Jan 13 11:17 /tmp/coba.0.e.ampa

This figure shows the rasterplot of the spiking activity of the excitatory population written to /tmp/coba.0.e.ras.

The figure shows the evolution of the membrane potential of one excitatory cell during the simulation.

The important bits

TIFGroup * neurons_e = new TIFGroup( ne);
TIFGroup * neurons_i = new TIFGroup( ni);
 
neurons_e->random_mem(-70e-3,10e-3);
neurons_i->random_mem(-70e-3,10e-3);

This part instatiates two groups of neurons of type TIFGroup which corresponds to the conductance based model with exponentially decaying PSCs and an absolute refractoriness of 5ms. The random_mem methods randomize the initial membrane potentials with a Gaussian (mean=-70mV and standard deviation 10e-3mV).

The sparse random connectivity is initialized as follows:

SparseConnection * con_ee 
   = new SparseConnection( neurons_e,neurons_e, w, sparseness, GLUT);
 
SparseConnection * con_ei 
   = new SparseConection( neurons_e,neurons_i, w,sparseness,GLUT);
 
SparseConnection * con_ie 
   = new SparseConnection( neurons_i,neurons_e,wi,sparseness,GABA);
 
SparseConnection * con_ii 
   = new SparseConnection( neurons_i,neurons_i,wi,sparseness,GABA);

here w contains the synaptic weight of excitatory synapses and wi the one of their inhibitory counter part. The network has a global sparseness of 2%.

The folling code snipped is responsible for running the simulation for simtime seconds. The second parameter true indicates that we wan the simulation to be interrupted if the RateChecker detects too high firing rates, which usually suggests that something is going wrong.

if (!sys->run(simtime,true)) 
    errcode = 1;
 
if ( prime ) { 
    oss.str("");
    oss << dir << "/save";
    sys->save_network_state(oss.str());
}

The second part of the above code saves the network state if prime==true and is therefore used to create the initial conditions of the self-sustained activity.

The full program

Note you might find a more recent version of this code in the auryn/examples directory.

/* 
* Copyright 2014 Friedemann Zenke
*
* This file is part of Auryn, a simulation package for plastic
* spiking neural networks.
* 
* Auryn is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* Auryn is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with Auryn.  If not, see <http://www.gnu.org/licenses/>.
*/
 
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <string>
 
#include <boost/program_options.hpp>
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <boost/mpi.hpp>
 
#include "System.h"
#include "IFGroup.h"
#include "TIFGroup.h"
#include "PoissonGroup.h"
#include "SparseConnection.h"
#include "SymmetricSTDPConnection.h"
#include "WeightSumMonitor.h"
#include "SpikeMonitor.h"
#include "DelayedSpikeMonitor.h"
#include "StateMonitor.h"
#include "RateChecker.h"
 
using namespace std;
 
namespace po = boost::program_options;
namespace mpi = boost::mpi;
 
int main(int ac,char *av[]) {
	string dir = "/tmp";
 
	string fwmat_ee = "";
	string fwmat_ei = "";
	string fwmat_ie = "";
	string fwmat_ii = "";
 
	stringstream oss;
	string strbuf ;
	string msg;
 
	double w = 0.4; // [g_leak]
	double wi = 5.1; // [g_leak]
 
 
 
	double sparseness = 0.02;
	double simtime = 20.;
 
	NeuronID ne = 3200;
	NeuronID ni = 800;
 
	bool fast = false;
 
	int errcode = 0;
 
 
    try {
 
        po::options_description desc("Allowed options");
        desc.add_options()
            ("help", "produce help message")
            ("simtime", po::value<double>(), "simulation time")
            ("fast", "turns off most monitoring to reduce IO")
            ("dir", po::value<string>(), "load/save directory")
            ("fee", po::value<string>(), "file with EE connections")
            ("fei", po::value<string>(), "file with EI connections")
            ("fie", po::value<string>(), "file with IE connections")
            ("fii", po::value<string>(), "file with II connections")
        ;
 
        po::variables_map vm;        
        po::store(po::parse_command_line(ac, av, desc), vm);
        po::notify(vm);    
 
        if (vm.count("help")) {
            cout << desc << "\n";
            return 1;
        }
 
        if (vm.count("simtime")) {
			simtime = vm["simtime"].as<double>();
        } 
 
        if (vm.count("fast")) {
			fast = true;
        } 
 
        if (vm.count("dir")) {
			dir = vm["dir"].as<string>();
        } 
 
        if (vm.count("fee")) {
			fwmat_ee = vm["fee"].as<string>();
        } 
 
        if (vm.count("fie")) {
			fwmat_ie = vm["fie"].as<string>();
        } 
 
        if (vm.count("fei")) {
			fwmat_ei = vm["fei"].as<string>();
        } 
 
        if (vm.count("fii")) {
			fwmat_ii = vm["fii"].as<string>();
        } 
 
    }
    catch(exception& e) {
        cerr << "error: " << e.what() << "\n";
        return 1;
    }
    catch(...) {
        cerr << "Exception of unknown type!\n";
    }
 
	// BEGIN Global stuff
	mpi::environment env(ac, av);
	mpi::communicator world;
	communicator = &world;
 
	oss << dir  << "/coba." << world.rank() << ".";
	string outputfile = oss.str();
 
	char tmp [255];
	stringstream logfile;
	logfile << outputfile << "log";
	logger = new Logger(logfile.str(),world.rank(),PROGRESS,EVERYTHING);
 
	sys = new System(&world);
	// END Global stuff
 
	logger->msg("Setting up neuron groups ...",PROGRESS,true);
 
	TIFGroup * neurons_e = new TIFGroup( ne);
	TIFGroup * neurons_i = new TIFGroup( ni);
 
	neurons_e->set_state("bg_current",2e-2); // corresponding to 200pF for C=200pF and tau=20ms
	neurons_i->set_state("bg_current",2e-2);
 
 
	logger->msg("Setting up E connections ...",PROGRESS,true);
 
	SparseConnection * con_ee 
		= new SparseConnection( neurons_e,neurons_e, w, sparseness, GLUT);
 
	SparseConnection * con_ei 
		= new SparseConnection( neurons_e,neurons_i, w,sparseness,GLUT);
 
 
 
	logger->msg("Setting up I connections ...",PROGRESS,true);
	SparseConnection * con_ie 
		= new SparseConnection( neurons_i,neurons_e,wi,sparseness,GABA);
 
	SparseConnection * con_ii 
		= new SparseConnection( neurons_i,neurons_i,wi,sparseness,GABA);
 
	if ( !fwmat_ee.empty() ) con_ee->load_from_complete_file(fwmat_ee);
	if ( !fwmat_ei.empty() ) con_ei->load_from_complete_file(fwmat_ei);
	if ( !fwmat_ie.empty() ) con_ie->load_from_complete_file(fwmat_ie);
	if ( !fwmat_ii.empty() ) con_ii->load_from_complete_file(fwmat_ii);
 
 
	if ( !fast ) {
		msg = "Setting up monitors ...";
		logger->msg(msg,PROGRESS,true);
 
		stringstream filename;
		filename << outputfile << "e.ras";
		SpikeMonitor * smon_e = new SpikeMonitor( neurons_e, filename.str().c_str() );
 
		// filename.str("");
		// filename.clear();
		// filename << outputfile << "e.dras";
		// DelayedSpikeMonitor * dsmon_e = new DelayedSpikeMonitor( neurons_e, filename.str().c_str() );
 
		filename.str("");
		filename.clear();
		filename << outputfile << "i.ras";
		SpikeMonitor * smon_i = new SpikeMonitor( neurons_i, filename.str().c_str() );
 
		filename.str("");
		filename << outputfile << "e.mem";
		StateMonitor * smon_mem = new StateMonitor( neurons_e, 7, "mem", filename.str() ,dt ); 
 
		filename.str("");
		filename << outputfile << "e.ampa";
		StateMonitor * smon_ampa = new StateMonitor( neurons_e, 7, "g_ampa", filename.str() );
 
		filename.str("");
		filename << outputfile << "e.gaba";
		StateMonitor * smon_gaba = new StateMonitor( neurons_e, 7, "g_gaba", filename.str() );
	}
 
 
	RateChecker * chk = new RateChecker( neurons_e , -0.1 , 1000. , 100e-3);
 
	logger->msg("Running sanity check ...",PROGRESS,true);
	con_ee->sanity_check();
	con_ei->sanity_check();
	con_ie->sanity_check();
	con_ii->sanity_check();
 
	logger->msg("Simulating ..." ,PROGRESS,true);
	if (!sys->run(simtime,true)) 
			errcode = 1;
 
	logger->msg("Freeing ..." ,PROGRESS,true);
	delete sys;
 
	if (errcode)
		env.abort(errcode);
 
	return errcode;
}
examples/sim_coba_benchmark.1431558743.txt.gz · Last modified: 2015/05/13 23:12 by zenke