A NN with synaptic depression for testing the effects of connectivity on dynamics (Jacob et al 2019)

 Download zip file 
Help downloading and running models
Accession:261623
Here we used a 10,000 neuron model. The neurons are a mixture of excitatory and inhibitory integrate-and-fire neurons connected with synapses that exhibit synaptic depression. Three different connectivity paradigms were tested to look for spontaneous transition between interictal spiking and seizure: uniform, small-world network, and scale-free. All three model types are included here.
Reference:
1 . Jacob T, Lillis KP, Wang Z, Swiercz W, Rahmati N, Staley KJ (2019) A Proposed Mechanism for Spontaneous Transitions between Interictal and Ictal Activity. J Neurosci 39:557-575 [PubMed]
Model Information (Click on a link to find other models with that property)
Model Type: Connectionist Network;
Brain Region(s)/Organism: Mouse; Hippocampus;
Cell Type(s): Abstract integrate-and-fire neuron;
Channel(s): I_K,Na;
Gap Junctions:
Receptor(s): GabaA; Glutamate;
Gene(s):
Transmitter(s): Gaba; Glutamate;
Simulation Environment: C or C++ program;
Model Concept(s): Connectivity matrix; Epilepsy;
Implementer(s): Jacob, Theju ;
Search NeuronDB for information about:  GabaA; Glutamate; I_K,Na; Gaba; Glutamate;
#include "layer.h"

double distribution_max;

Layer::Layer(int row, int clm){
	rows = row;
	clms = clm;
	availableGlutamate = new double*[row]();
	for(int i = 0; i < row; i++)
		availableGlutamate[i] = new double[clm]();
	releasableGlutamate = new double*[row]();
	for(int i = 0; i < row; i++)
		releasableGlutamate[i] = new double[clm]();
}
//add Neurons to grid
int Layer::addNeurons(Param* param){
	int i, j;
	double mean, stddev;
	distribution_max = 0;
	mean = 50; stddev = 10.0;
	default_random_engine generator;
	normal_distribution<double> distribution(mean,stddev);
	//The initial plan was to pass the param pointer to the constructor. However, that would have involved initializing the neurons in a loop, as C++ does not have a method to initialize an array created with new without passing param to each instance in a loop.
	NeuronLayer = new Neuron*[rows]();
	for (i = 0; i < rows; i++){ 
		NeuronLayer[i] = new Neuron[clms]();
	}
	for(i = 0; i < rows; i++){
		for(j =0; j < clms; j++){
			availableGlutamate[i][j] = 0;
			releasableGlutamate[i][j] = 0;
			NeuronLayer[i][j].row = i;
			NeuronLayer[i][j].clm = j;		
			if((i%5 == 0) && (j%5 == 0)){
				NeuronLayer[i][j].excitatory = false;
				NeuronLayer[i][j].Inhibitory();
				NeuronLayer[i][j].Tgk = param->InTgk;
				NeuronLayer[i][j].Tth = param->InTth;
				NeuronLayer[i][j].B   = param->InB;
				NeuronLayer[i][j].Te1 = param->InTe1;
				NeuronLayer[i][j].Te2 = param->InTe2;
				NeuronLayer[i][j].Ti1 = param->InTi1;
				NeuronLayer[i][j].Ti2 = param->InTi2;
				//cout << i << " " << j << endl;
			}
			else{
				NeuronLayer[i][j].excitatory = true;
				NeuronLayer[i][j].Tgk = param->ExTgk;
				NeuronLayer[i][j].Tth = param->ExTth;
				NeuronLayer[i][j].B   = param->ExB;
				NeuronLayer[i][j].Te1 = param->ExTe1;
				NeuronLayer[i][j].Te2 = param->ExTe2;
				NeuronLayer[i][j].Ti1 = param->ExTi1;
				NeuronLayer[i][j].Ti2 = param->ExTi2;
				NeuronLayer[i][j].TauRelease	= param->TauRelease;
				NeuronLayer[i][j].TauReplenish	= param->TauReplenish;
				NeuronLayer[i][j].SpontRelease	= param->SpontRelease;
				NeuronLayer[i][j].glutamate_pr = distribution(generator);
				if(distribution_max < NeuronLayer[i][j].glutamate_pr)
					distribution_max = NeuronLayer[i][j].glutamate_pr;
			}
		}
	}
	return 0;
}
//add synaptic connections
int Layer::addSynapse(int no_wts, Param* param){
	int i, j, k, m, n, count, connect;
	double d = param->Neighborhood, value, value_uniform,p, in_Glut, wt;
	double **trackweight;
	trackweight = new double*[rows*clms]();
	for(int i = 0; i < rows*clms; i++)
		trackweight[i] = new double[rows*clms]();
	FILE *gmFile = fopen("glutamatemap.txt","w");
	FILE *igmFile = fopen("initialglutamatemap.txt","w");
	FILE *wtFile = fopen("weightmap.txt","w");
	ConnectionMatrix  = new vector<Synapse>*[rows]();
	for(i = 0; i < rows; i++){
		ConnectionMatrix[i] = new vector<Synapse>[clms]();
	}
	
//#pragma omp parallel for private(i,j,k,p,value,count,m,n)
	for(i = 0; i < rows; i++){
		for(j = 0; j < clms; j++){
			count = 0;
			in_Glut = 0;
			for(m = 0; m < rows; m++){
				for(n = 0; n < clms; n++){
					//initial connection criteria: distance between 2 neurons
					//no self feedback
					//(sqrt((i - m)*(i - m) + (j - n)*(j - n)) < d) &&
					value = drand48();
					value_uniform = drand48();
					//(value_uniform < 0.625) && 
					if((value < exp(-((i - m)*(i - m))/5 -((j - n)*(j - n))/5)) &&  (!(i == m && j == n)) && (!(!NeuronLayer[i][j].excitatory && !NeuronLayer[m][n].excitatory)) ){
					ConnectionMatrix[i][j].push_back(Synapse());
					ConnectionMatrix[i][j][count].row = m;
					ConnectionMatrix[i][j][count].clm = n;
					value = drand48();
					ConnectionMatrix[i][j][count].weight = value;
					trackweight[i*rows+j][m*rows+n] = value;
					if(NeuronLayer[m][n].excitatory){
						ConnectionMatrix[i][j][count].excitatory = true;
						ConnectionMatrix[i][j][count].NRmax = (param->NRmax)*value;
						ConnectionMatrix[i][j][count].tau	= 0;
					}
					else{
						ConnectionMatrix[i][j][count].excitatory = false;
						ConnectionMatrix[i][j][count].NRmax = 0;
						ConnectionMatrix[i][j][count].tau	= 0;
						ConnectionMatrix[i][j][count].NR    = 0;
					}
					in_Glut = in_Glut + ConnectionMatrix[i][j][count].NRmax;
					count = count+1;
					//fprintf(cFile,"%f ",value);
					}					
				}
			}		
  			//cout << count << " " ;
			//fprintf(gmFile,"%f ", in_Glut);
		}
		//fprintf(gmFile,"\n");
	}
//exit(0);	
//#pragma omp parallel for private(i,j)
	for(i = 0; i < rows; i++){
		for(j = 0; j < clms; j++){
			NeuronLayer[i][j].glutamateinitialize(ConnectionMatrix[i][j], NeuronLayer);
		}
	}
	//exit(0);	
	for(i = 0; i < rows; i++){
		for(j = 0; j < clms; j++){
			in_Glut = 0;
			for(count = 0; count < ConnectionMatrix[i][j].size(); count++){
				in_Glut = in_Glut + ConnectionMatrix[i][j][count].NR;
				if(ConnectionMatrix[i][j][count].excitatory)
					NeuronLayer[ConnectionMatrix[i][j][count].row][ConnectionMatrix[i][j][count].clm].glutamate += ConnectionMatrix[i][j][count].NR;
			}
			//fprintf(igmFile,"%f ", in_Glut);
		}
		//fprintf(igmFile,"\n");
	}
	for(i = 0; i < rows*clms; i++){
		for(j = 0; j < rows*clms; j++){
			//fprintf(wtFile,"%f ", trackweight[i][j]);
		}
		//fprintf(wtFile,"\n");
	}
	fclose(gmFile);
	fclose(igmFile);
	fclose(wtFile);
	//exit(0);
	return 0;
}
//main simulation loop
int Layer::stimulateNeurons(){
	int index, iterations;
	int i, j, espikes, ispikes, count;
    double avg_glutamate;
	FILE *pFile = fopen("spikes.txt","w");
	FILE *eFile = fopen("potential.txt","w");
	FILE *rrFile = fopen("releasedglutamate.txt","w");
	FILE *rgFile = fopen("releasableglutamate.txt","w");
	FILE *agFile = fopen("availableglutamate.txt","w");
	FILE *gbFile = fopen("gaba.txt","w");
	FILE *spFile = fopen("spikepatterns.txt","w");
	FILE *kFile = fopen("kconductance.txt","w");
	//variable index can be used to apply a stimulating current to random neuron(s) in each iteration
	for(iterations = 0; iterations < 60000; iterations++){
		index = rand()%(rows*clms);
		espikes = 0;
		ispikes = 0;
        avg_glutamate = 0;
		//loop to keep track of available glutamate vesicles at each neuron
		for(i = 0; i < rows; i++){
			for(j = 0; j < clms; j++){
				for(count = 0; count < ConnectionMatrix[i][j].size(); count++){
					if(ConnectionMatrix[i][j][count].excitatory){
						 availableGlutamate[ConnectionMatrix[i][j][count].row][ConnectionMatrix[i][j][count].clm] += ConnectionMatrix[i][j][count].NR;						
						}
					releasableGlutamate[i][j] += ConnectionMatrix[i][j][count].NR;//*ConnectionMatrix[i][j][count].weight;
					}
				}
		}
        //loop to record the average glutamate released and the number of excitatory and inhibitory neurons firing
		for(i = 0; i < rows; i++){
			for(j = 0; j < clms; j++){
              /*if((iterations > 5000) && (iterations < 65000)){
					fprintf(eFile,"%f ", NeuronLayer[i][j].E);
					fprintf(rrFile,"%f ", NeuronLayer[i][j].glutamate);
					fprintf(rgFile,"%f ", releasableGlutamate[i][j]);
					fprintf(agFile,"%f ", availableGlutamate[i][j]);
					fprintf(gbFile,"%f ", NeuronLayer[i][j].gaba);
					fprintf(spFile,"%d ",NeuronLayer[i][j].S);
					fprintf(kFile,"%f ",NeuronLayer[i][j].Gk);
				}*/
                avg_glutamate += NeuronLayer[i][j].glutamate;
				availableGlutamate[i][j] = 0;
				releasableGlutamate[i][j] = 0;
				if((i%5 == 0) && (j%5 == 0))
					ispikes += NeuronLayer[i][j].S;
				else
					espikes += NeuronLayer[i][j].S;
			}
		}
       /*if((iterations > 5000) && (iterations < 65000)){
			fprintf(eFile,"\n");
			fprintf(rrFile,"\n");
			fprintf(rgFile,"\n");
			fprintf(agFile,"\n");
			fprintf(gbFile,"\n");
			fprintf(spFile,"\n");
			fprintf(kFile,"\n");
		}*/
		//cout << espikes << " " << ispikes << " ";// << endl;
        //fprintf(gFile,"%f\n", avg_glutamate/(rows*clms));
		fprintf(pFile,"%d %d %d\n",iterations,espikes,ispikes);
#pragma omp parallel for private(i,j)
		for(i = 0; i < rows; i++){
			for(j = 0; j < clms; j++){				
				NeuronLayer[i][j].glutamaterelease(ConnectionMatrix[i][j],NeuronLayer,iterations);
			}
		}
#pragma omp barrier
#pragma omp parallel for private(i,j)
		for(i = 0; i < rows; i++){
			for(j = 0; j < clms; j++){				
				//if(i*clms+j == index)
					NeuronLayer[i][j].computePotential(ConnectionMatrix[i][j],0, iterations);
				//else
					//NeuronLayer[i][j].computePotential(ConnectionMatrix[i][j],0, iterations);
			}
		}
#pragma omp barrier
		recordPotential(iterations);
	}
	fclose(eFile);
	fclose(rrFile);
	fclose(rgFile);
	fclose(agFile);
	fclose(gbFile);
	fclose(spFile);
	fclose(kFile);
	fclose(pFile);
	return 0;
}

int Layer::recordPotential(int iterations){
	int i,j, center_i, center_j;
	double distance, potential, sigma = 2;
	center_i = rows/2;
	center_j = clms/2;
	//potential is assumed to be recorded from the center of the layer. 
	//neuron membrane potentials are multiplied by a Gaussian centered at the center.
	potential = 0.0;
	for(i = 0; i < rows; i++){
		for(j = 0; j < clms; j++){
			distance = ((double)1/sqrt((double)2*M_PI*sigma*sigma))*exp(-((center_i - i)*(center_i - i) + (center_j - j)*(center_j - j))/(double)2*sigma*sigma);
			potential += distance*NeuronLayer[i][j].E;
		}
	}
	cout << potential << " " << iterations << endl;
	return 0;
}

Loading data, please wait...