Skip to content

Commit

Permalink
added GenericSynapse
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-s committed Mar 9, 2020
1 parent a05311e commit 561e1be
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 0 deletions.
144 changes: 144 additions & 0 deletions c++/synapses/nadim98/GenericSynapse.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// GENERICSYNAPSE Synapse
#ifndef GENERICSYNAPSE
#define GENERICSYNAPSE
#include "synapse.hpp"

class GenericSynapse: public synapse {

public:


double k;
double Vk;
double tau3;
double tau4;
double lambda;
double Vlambda;


// specify parameters + initial conditions
GenericSynapse(double gmax_, double s_, double k_, double Vk_, double tau3_, double tau4_, double lambda_, double Vlambda_)
{
gmax = gmax_;
k = k_;
Vk = Vk_;
tau3 = tau3_;
tau4 = tau4_;
lambda = lambda_;
Vlambda = Vlambda_;

// defaults
if (isnan (s)) { s = 0; }
if (isnan (gmax)) { gmax = 0; }
is_electrical = false;

}

void integrate(void);
void integrateMS(int, double, double);
void checkSolvers(int);

double s_inf(double);
double tau_s(double);
double sdot(double, double);

void connect(compartment *pcomp1_, compartment *pcomp2_);
int getFullState(double*, int);
int getFullStateSize(void);
};

int GenericSynapse::getFullStateSize() {
return 2;
}


double GenericSynapse::s_inf(double V_pre) {
return 1.0/(1.0+exp((V_pre - Vk)*k));
}

double GenericSynapse::tau_s(double V_pre) {
return tau3 + tau4/(1 + exp(lambda*(V_pre - Vlambda)));
}

double GenericSynapse::sdot(double V_pre, double s_) {
return (s_inf(V_pre) - s_)/tau_s(V_pre);
}

void GenericSynapse::integrate(void) {
// figure out the voltage of the pre-synaptic neuron
double V_pre = pre_syn->V;
double sinf = s_inf(V_pre);

// integrate using exponential Euler
s = sinf + (s - sinf)*exp(-dt/tau_s(sinf));

g = gmax*s;

}

void GenericSynapse::integrateMS(int k, double V, double Ca) {

double V_pre;

if (k == 0) {
V_pre = pre_syn->V_prev;
k_s[0] = dt*(sdot(V_pre, s));

} else if (k == 1) {
V_pre = pre_syn->V_prev + pre_syn->k_V[0]/2;
k_s[1] = dt*(sdot(V_pre, s + k_s[0]/2));


} else if (k == 2) {
V_pre = pre_syn->V_prev + pre_syn->k_V[1]/2;
k_s[2] = dt*(sdot(V_pre, s + k_s[1]/2));


} else if (k == 3) {
V_pre = pre_syn->V_prev + pre_syn->k_V[2];
k_s[3] = dt*(sdot(V_pre, s + k_s[2]));


} else {
// last step
s = s + (k_s[0] + 2*k_s[1] + 2*k_s[2] + k_s[3])/6;

if (s < 0) {s = 0;}
if (s > 1) {s = 1;}
}

}

void GenericSynapse::checkSolvers(int k){
if (k == 0) {
return;
} else if (k == 4) {
return;
}
mexErrMsgTxt("[GenericSynapse] Unsupported solver order\n");
}

int GenericSynapse::getFullState(double *syn_state, int idx) {
// give it the current synapse variable
syn_state[idx] = s;

idx++;

// also return the current from this synapse
syn_state[idx] = gmax*s*(post_syn->V - E);
idx++;
return idx;
}

void GenericSynapse::connect(compartment *pcomp1_, compartment *pcomp2_) {
pre_syn = pcomp1_;
post_syn = pcomp2_;

// tell the post-synaptic cell that we're connecting to it
post_syn->addSynapse(this);
}




#endif
27 changes: 27 additions & 0 deletions examples/integer_coupling.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@

close all

x = xolotl;


% make Int1
x.add('compartment','Int1','radius',.025,'len',.05);
x.add('compartment','Int1Neurite','len',1,'radius',1.25);
x.add('compartment','Int1Axon','len',1,'radius',1.25);
x.connect('Int1','Int1Neurite','Axial')
x.connect('Int1Neurite','Int1','Axial')
x.connect('Int1Axon','Int1Neurite','Axial')
x.connect('Int1Neurite','Int1Axon','Axial')



% add channels to Int1
x.Int1Axon.add('nadim98/GenericChannel','NaV','gbar',35,'E',45,'p',3,'km',-.08,'Vkm',-26,'lm',0,'Vlm',0,'tau1m',1,'tau2m',0,'q',1,'kh',.13,'Vkh',-38,'lh',-.12,'Vlh',-67,'tau1h',0,'tau2h',5);
Expand All @@ -16,6 +24,25 @@
x.Int1.add('Leak','gbar',1,'E',-40)
x.Int1Neurite.add('Leak','gbar',1,'E',-40)




% make LG
x.add('compartment','LG','radius',.025,'len',.05);
x.add('compartment','LGNeurite','len',1,'radius',1.25);
x.add('compartment','LGAxon','len',1,'radius',1.25);
x.connect('LG','LGNeurite','Axial')
x.connect('LGNeurite','LG','Axial')
x.connect('LGAxon','LGNeurite','Axial')
x.connect('LGNeurite','LGAxon','Axial')

x.LGAxon.add('nadim98/GenericChannel','NaV','gbar',35,'E',45,'p',3,'km',-.08,'Vkm',-21,'lm',0,'Vlm',0,'tau1m',1,'tau2m',0,'q',1,'kh',.13,'Vkh',-33,'lh',-.12,'Vlh',-62,'tau1h',0,'tau2h',5);
x.LGAxon.add('nadim98/GenericChannel','Kd','gbar',40,'E',-80,'p',4,'km',-.045,'Vkm',-33,'lm',-.065,'Vlm',-5,'tau1m',4,'tau2m',100,'q',0,'kh',0,'Vkh',0,'lh',0,'Vlh',0,'tau1h',0,'tau2h',0);

x.show(x.LGAxon)

x.plot('LGAxon')

return

%Add conductances
Expand Down

0 comments on commit 561e1be

Please sign in to comment.