User Tools

Site Tools


neurali:ispike_esempio2

come compilare:

g++ prova.cpp -lboost_system -liSpike -lnemo -lnemo_base -L /usr/local/lib

#include <exception>
#include <iostream>
#include <iSpike/Reader/FileAngleReader.hpp>
#include <iSpike/Channel/InputChannel/JointInputChannel.hpp>
#include <map>
 
// solo per nemo 
 
#include <vector>
#include <string>
#include <nemo.hpp>
#include <boost/random.hpp>
#include <nemo/Configuration.hpp>
#include <nemo/Network.hpp>
#include <nemo/Simulation.hpp>
 
int main() 
{
 
    ispike::FileAngleReader* far = new ispike::FileAngleReader();
    map<string,ispike::Property> farp = far->getProperties();
    farp.at("File Name") = ispike::Property("prova.txt", "File Name", "description", true);
 
    far->initialize(farp);
 
    ispike::JointInputChannel* jc = new ispike::JointInputChannel();
    map<string,ispike::Property> jcp = jc->getProperties();
    //jcp.at("minAngle") = ispike::Property(ispike::Property::Double, -90.0, "Minimum Angle", "The minimum angle to read",true);
    jc->initialize(far, jcp);
 
    //Se non diversamente specificato, iSpike genera impulsi per una rete il cui input è composto 
    // da una sezione di 10x1 neuroni
 
    /* 
     * 	addProperty(Property(Property::Integer, 0, DEGREE_OF_FREEDOM_NAME, "The degree of freedom to read from this joint", false));
	addProperty(Property(Property::Double, 0.5, STANDARD_DEVIATION_NAME, "The standard deviation as a percentage of neurons covered", true));
	addProperty(Property(Property::Double, -90.0, MIN_ANGLE_NAME, "The minimum angle to read", true));
	addProperty(Property(Property::Double, 90.0, MAX_ANGLE_NAME, "The maximum angle to read", true));
	addProperty(Property(Property::Integer, 10, NEURON_WIDTH_NAME, "Width of the neuron network", true));
	addProperty(Property(Property::Integer, 1, NEURON_HEIGHT_NAME, "Height of the neuron network", true));
	addProperty(Property(Property::Double, 0.1, PARAM_A_NAME, "Parameter A of the Izhikevich Neuron Model", false));
	addProperty(Property(Property::Double, 0.2, PARAM_B_NAME, "Parameter B of the Izhikevich Neuron Model", false));
	addProperty(Property(Property::Double, -65.0, PARAM_C_NAME, "Parameter C of the Izhikevich Neuron Model", false));
	addProperty(Property(Property::Double, 2.0, PARAM_D_NAME, "Parameter D of the Izhikevich Neuron Model", false));
	addProperty(Property(Property::Double, 40.0, PEAK_CURRENT_NAME, "Maximum current that will be injected into neuron", true));
	addProperty(Property(Property::Double, 0.0, CONSTANT_CURRENT_NAME, "This value is added to the incoming current", false));
    * 
    * 
    * 
    */
    /*--------- inizio config. nemo -----------*/
 
    //Promemoria: la rete di nemo deve avere tanti neuroni di input quanti ne ho 
    //deciso anche su ispike, quindi sono 10, se non diversam. specificato
 
    /*---------- fine config. nemo -----------*/
 
 
    /*--------- inizio simulazione -----------*/
 
   // promemoria: la simulaz. ispike e la simulaz. nemo devono essere rese sincrone.
 
   for (unsigned ms=0; ms<10; ms++)
    {
	jc->step(); //avanza simulazione canale 
	const vector<unsigned>& spiked = jc->getFiring();  // restituisce impulsi prodotti nella riga precedente
 
	/* posso vedere il contenuto di questo vector con un for*/
	for(std::vector<unsigned>::const_iterator fi = spiked.begin(); fi != spiked.end(); ++fi) 
	    std::cout << "ispike: "<< ms << " ms " << *fi << "\n";  // ad ogni passo stampa id neuroni che hanno pulsato
 
    //poi passare questi impulsi al simulatore NeMo per simulazione nemo:	
    }
 
    return 0;
 
}

output in caso di angolo di 89 gradi (mancano degli step?????)

 ispike: 1 ms 9
 ispike: 3 ms 9
 ispike: 5 ms 8
 ispike: 5 ms 9
 ispike: 7 ms 9
 ispike: 9 ms 9
neurali/ispike_esempio2.txt · Last modified: 2020/06/08 22:20 by 127.0.0.1