00001 #include "LinearPoissonNeuron.h" 00002 00003 #include <cmath> 00004 00005 ThreadSpecificRandomDistribution< NormalDistribution > LinearPoissonNeuron::noise_gen; 00006 ThreadSpecificRandomDistribution< UniformDistribution > LinearPoissonNeuron::spike_gen; 00007 00008 int LinearPoissonNeuron::reset( double dt ) 00009 { 00010 SingleOutputSpikeSender::reset(); 00011 noise_gen.set( NormalDistribution(0.0, 1.0) ); 00012 spike_gen.set( UniformDistribution(0.0,1.0) ); 00013 nStepsInRefr = -1; /* we are not refractory at the begining */ 00014 Twindow = dt; 00015 //cerr << "LifNeuron::reset\n\n"; 00016 clearSynapticInput(); 00017 return 0; 00018 } 00019 00020 00022 int LinearPoissonNeuron::advance(AdvanceInfo const & ai) 00023 { 00024 bool register hasFired = false; 00025 double spikeT = 0.0; 00026 00027 if (nStepsInRefr > 0) { 00028 --nStepsInRefr; 00029 } else { 00030 00031 double Itot = Isyn + Iinject; 00032 00033 if ( Inoise > 0.0 ) { 00034 Itot += ( noise_gen() * Inoise ); 00035 } 00036 00037 Vm = Itot / ( Gsyn + 1.0/ Rm ); 00038 00039 double Rate = Vm * C; 00040 00041 if ( spike_gen() < Rate * Twindow ) { 00042 // Note that the neuron has fired! 00043 hasFired = true; 00044 00045 // calculate the spike time ( for exact spike timing ) 00046 spikeT = (ai.dt.in_sec() - Twindow) + Twindow * spike_gen(); 00047 00048 // calc number of steps how long we are refractory and the last time window for exact spike timing 00049 nStepsInRefr = int( (Trefract - (ai.dt.in_sec() - spikeT) ) / ai.dt.in_sec() ); 00050 Twindow = ai.dt.in_sec() - (Trefract - (ai.dt.in_sec() - spikeT) - nStepsInRefr * ai.dt.in_sec() ); 00051 } 00052 else 00053 Twindow = ai.dt.in_sec(); 00054 } 00055 00056 // clear synaptic input for next time step 00057 clearSynapticInput(); 00058 00059 // Return proper value 00060 if( hasFired ) { 00061 out_port.setSpike( ai, spikeT + ai.t.in_sec() ); 00062 return ADVANCEFLAG_HASSPIKED; 00063 } else { 00064 return 0; 00065 } 00066 } 00067 00068 00069 00070 void LinearPoissonNeuron::clearSynapticInput(void) 00071 { 00072 Isyn = Gsyn = 0; 00073 } 00074 00075 void LinearPoissonNeuron::currentInput( double i ) 00076 { 00077 Isyn += i; 00078 } 00079 00080 00081 void LinearPoissonNeuron::conductanceInput( double g, double Erev ) 00082 { 00083 Gsyn += g; 00084 Isyn += (g*Erev); 00085 } 00086