#include #if !defined(MAX) #define MAX(A, B) ((A) > (B) ? (A) : (B)) #endif #if !defined(MIN) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #endif /*Function Prototypes*/ void LIFDAPmodel(double signal[], int length_signal, double f, double weight[], int length_weight, double g, double Lambda, double eta, double eta2, double tau_m, double tau_w, double wmax, double sptime[], double rec[], double weightafter[], int *nspikes, int *n2bursts, int *n4bursts); void governingloop(double sptime[], double bursttime4[], double bursttime2[], double w[], double signal[], double weight[], double rec[],double f, double g, double Lambda, double eta, double eta2, int numw, int m, double tau_m, double tau_w, double wmax,int *nspikes, int *n2bursts,int *n4bursts); /*This calling function only exists to call the time loop subroutine. This parallels the MATLAB calling function in LIFDAP.c */ void LIFDAPmodel(double signal[], int length_signal, double f, double weightbefore[], int length_weight, double g, double Lambda, double eta, double eta2, double tau_m, double tau_w, double wmax, double sptime[], double rec[], double weightafter[], int *nspikes, int *n2bursts, int *n4bursts) { double *bursttime2, *bursttime4; int spsize; spsize=length_signal/100; bursttime2= (double *) calloc(spsize, sizeof(double)); bursttime4= (double *) calloc(spsize, sizeof(double)); /* Call the LIF-DAP timeloop subroutine. */ governingloop(sptime,bursttime4,bursttime2, weightafter,signal,weightbefore,rec,f,g,Lambda,eta,eta2, length_weight,length_signal,tau_m, tau_w, wmax, nspikes, n2bursts, n4bursts); /*spttime, bursttime4, bursttime2, w and rec are outputs that are arrays signal and weight are inputs that are arrays the rest are individual inputs */ } /*-----------------------------------------------------------------------------------------------*/ void governingloop(double sptime[], double bursttime4[], double bursttime2[], double w[], double signal[], double weight[], double rec[],double f, double g, double Lambda, double eta, double eta2, int numw, int m, double tau_m, double tau_w, double wmax, int *nspikes, int *n2bursts,int *n4bursts) { /*Parameters from Noonan et al. 2003*/ double A=0.15*4, B=2, alpha=20, beta=0.35, D=0.1, E=3.5, tauref=0.1,taudend=50., b=0, somawidth=0.05*4, dendwidth=1.0, taudecay=1., thresh=1.0; double delt = 0.01, realt, avgw, Lwidth, Lwidth2, Bdef4,Bdef2, nper, burstT, *pfspike, *L, v=0.025, tref=0, Dxh, Dwh, Dyh, Dsh, Dx=0, Dy=0, Ds=0, Dw=0; int i, k, j, reci=0, index=4, index4=0, index2=0, count4=4, count2=2, countr=0; /*PF initialization */ pfspike= (double *) calloc(3*numw, sizeof(double)); L=(double *) calloc(3*numw, sizeof(double)); /*Burst definition and width*/ Bdef2=0.015/tau_m; /*defining a 2-spike burst (time is in units of tau_m within code so 15 ms = 0.015/tau_m)*/ Bdef4=3.0*Bdef2; /*4-spike burst has 3 ISIs so 3 x 2-spike burst definition */ Lwidth=0.1/tau_m; /*100 ms 4-spike burst learning rule width, from experimental data*/ Lwidth2=0.01/tau_m; /*10 ms 2-spike STDP width*/ tau_w=tau_w/tau_m; f=f*tau_m; nper=1/f/delt; /*number of timesteps in 1 period*/ /*Mapping given weight distribution to output weight matrix w */ for(i=0;itref){ /*GOVERNING EQUATION*/ v= v+delt*(-v + signal[i] + Lambda*(w[k]-g*v)); /*k is used to change the index of the weight that is active at a given time*/ /*Note absence of DAP*/ /* Do this if ISI beyond dendritic ref. period*/ if(taudend<(sptime[index-1]-sptime[index-2])){ if (dendwidth*Dx-somawidth*Ds > 0){ /*DAP is rectified*/ v=v+delt*alpha*(dendwidth*Dx-somawidth*Ds); /*DAP is added*/ } } }/*end of if realt > tref */ /*if V >threshold, a spike is fired and a burst might be recorded*/ if(v>thresh) { v=0; /*v reset to 0*/ tref=realt+tauref+delt/2; /*refractory period is updated*/ sptime[index]=realt; /*spike is recorded*/ index++; /*index now moves to vacant position*/ count4--; /*so each 4-spike burst has 4 unique spikes*/ count2--; /* so each 2-spike burst has 2 unique spikes */ /*DAP parameters are updated*/ b=b+A+ B*b*b; /*updating b*/ taudend=D+E*b; /*updating dendritic refractory period*/ dendwidth=beta*b; Dy=Dy+1/dendwidth/dendwidth; Dw=Dw+1/somawidth/somawidth; /*if the last spike occurred within Bdef2 of this spike and count2<1, then record a 2-sp burst*/ if((realt-sptime[index-2] L=0 often*/ }/*End of if 2-spike burst occurred*/ /*if the time between this spike and the 4th last spike is less than Bdef4, record a 4-spike burst*/ if((realt-sptime[index-4]