// SPNET: Spiking neural network with axonal conduction delays and STDP // Created by Eugene M. Izhikevich, May 17, 2004, San Diego, CA // Saves spiking data each second in file spikes.dat // To plot spikes, use MATLAB code: load spikes.dat;plot(spikes(:,1),spikes(:,2),'.'); #include #include #include #include #define getrandom(max1) ((rand()%(int)((max1)))) // random integer between 0 and max-1 const int Ne = 800; // excitatory neurons const int Ni = 200; // inhibitory neurons const int N = Ne+Ni; // total number of neurons const int M = 100; // the number of synapses per neuron const int D = 20; // maximal axonal conduction delay float sm = 10.0; // maximal synaptic strength int post[N][M]; // indeces of postsynaptic neurons float s[N][M], sd[N][M]; // matrix of synaptic weights and their derivatives short delays_length[N][D]; // distribution of delays short delays[N][D][M]; // arrangement of delays int N_pre[N], I_pre[N][3*M], D_pre[N][3*M]; // presynaptic information float *s_pre[N][3*M], *sd_pre[N][3*M]; // presynaptic weights float LTP[N][1001+D], LTD[N]; // STDP functions float a[N], d[N]; // neuronal dynamics parameters float v[N], u[N]; // activity variables int N_firings; // the number of fired neurons const int N_firings_max=100*N; // upper limit on the number of fired neurons per sec int firings[N_firings_max][2]; // indeces and timings of spikes void initialize() { int i,j,k,jj,dd, exists, r; for (i=0;i exc only if (r==i) exists=1; // no self-synapses for (k=0;k=30) // did it fire? { v[i] = -65.0; // voltage reset u[i]+=d[i]; // recovery variable reset LTP[i][t+D]= 0.1; LTD[i]=0.12; for (j=0;j=0) fprintf(fs, "%d %d\n", firings[i][0], firings[i][1]); fclose(fs); for (i=0;ism) s[i][j]=sm; if (s[i][j]<0) s[i][j]=0.0; } } }