/* * * Example-program: intnfire.c * */ # include # include "nn.h" /* always include this */ # include "vector.h" /* matrix and vector math. */ # include "random.h" /* random numbers are used */ /* * * define simulation variables and parameters * */ # define N 25 /* number of neurons */ int n; /* number of units */ double I, /* input to all units */ tau, /* membrane time const. */ J0, /* avg. couplingstrength */ J_dev; /* dev. " */ Vector pot; /* potentials */ Matrix J; /* connections */ bVector o; /* vector of spikes */ Vector v1; /* for help */ /* * * define switch and slider variables needed * to build the grapical interface * */ SliderValue snoise = 0; SliderValue sinput = 100; SliderValue sJ = 50; /* * * Definition of graphical interface * */ BEGIN_DISPLAY /* The following 2 declarations are only needed if you do not want line * graphs that scroll to the left, if the right edge of display windows is * reached */ Graph * gr; Raster * ra; /* define 3 sliders for interactive * control of simulation parameters. */ SLIDER( "noise", snoise, 0, 100) SLIDER( "input", sinput, 0, 200) SLIDER( "coupling", sJ, 0, 200) /* define a window .... */ WINDOW("time courses") /* .... containing the time-courses of the vector-variables * pot and o, and the sum of spikes in each time bin. */ IMAGE( "pot", AR, AC, pot, VECTOR, 3, 5, 0.0, 1.0, 9) ra = RASTER( "pot", NR, AC, pot, VECTOR, N, 0, 0.0, 1.0, 1) ra->flags = RESET; // if you comment this out, you'll get left-scrolling gr = GRAPH( "pot", NR, AC, pot, VECTOR, N, 0, 0, 0, -.01, 1.01 ) gr->flags = DOTS | RESET; ra = RASTER( "out", NR, AC, o, bVECTOR, N, 0, -.01, 1.01, 2) ra->flags = RESET; /* define a second window .... */ WINDOW("couplings") /* .. displaying the random coupling matrix */ IMAGE( "J", AR, AC, J, CONSTANT MATRIX, N, N, -4./N, 4./N, 4) END_DISPLAY BEGIN_OUTPUT OUTFILE("potentials") SET_SAVE_FILE_FLAG( THISFILE, ASCII, ON) SAVE_VARIABLE( "pot", pot, VECTOR, N, 0, 0, 0, 0 ) OUTFILE("spikes") SET_SAVE_FILE_FLAG( THISFILE, ASCII, ON) SAVE_VARIABLE( "out", o, bVECTOR, N, 0, 0, 0, 0 ) END_OUTPUT /* * * Initializations, that appear only once. * */ int main_init() { /* initialize parameters */ SET_STEPSIZE( .05 ) I = 1.0; J0 = 1.0/N; J_dev = .4/N; tau = 1.0; /* allocate vectors and matrices */ J = Get_Matrix( N, N ); pot = Get_Vector( N ); o = Get_bVector( N ); v1 = Get_Vector( N ); /* init. random number generation */ randomize( 100 ); } /* * * Initializations that are needed any * time the simulation is restarted. * */ int init() { int i,j; Clear_bVector(N,o); Clear_Vector(N,v1); /* init. potentials with values between 0 and 1 */ for (i=0; i