Skip to content

Commit 4e7e2bf

Browse files
author
Paula Sanz-Leon
committed
Resolve conflict
2 parents a7c1af7 + 3ec75fc commit 4e7e2bf

28 files changed

+274
-57
lines changed

configs/dendrite_integral.conf

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Example configuration file for the Robinson et. al. corticothalamic model
2+
3+
Connection 1 - Excitatory -> Excitatory
4+
Connection 2 - Inhibitory -> Excitatory
5+
Connection 3 - Relay -> Excitatory
6+
Connection 4 - Excitatory -> Inhibitory
7+
Connection 5 - Inhibitory -> Inhibitory
8+
Connection 6 - Relay -> Inhibitory
9+
Connection 7 - Excitatory -> Reticular
10+
Connection 8 - Relay -> Reticular
11+
Connection 9 - Excitatory -> Relay
12+
Connection 10 - Reticular -> Relay
13+
Connection 11 - Stimulus -> Relay
14+
15+
Time: 15 Deltat: 0.0001
16+
Nodes: 144
17+
18+
Connection matrix:
19+
From: 1 2 3 4 5
20+
To 1: 1 2 0 3 0
21+
To 2: 4 5 0 6 0
22+
To 3: 7 0 0 8 0
23+
To 4: 9 0 10 0 11
24+
To 5: 0 0 0 0 0
25+
26+
Population 1: Excitatory
27+
Length: 0.5
28+
Q: 5.248361515
29+
Firing: Sigmoid - Theta: 0.01292 Sigma: 0.0038 Qmax: 340
30+
Dendrite 1: Integral - alpha: 83.33333333 beta: 769.2307692
31+
Dendrite 2: Integral - alpha: 83.33333333 beta: 769.2307692
32+
Dendrite 3: Integral - alpha: 83.33333333 beta: 769.2307692
33+
34+
Population 2: Inhibitory
35+
Length: 0.5
36+
Q: 5.248361515
37+
Firing: Sigmoid - Theta: 0.01292 Sigma: 0.0038 Qmax: 340
38+
Dendrite 4: Integral - alpha: 83.33333333 beta: 769.2307692
39+
Dendrite 5: Integral - alpha: 83.33333333 beta: 769.2307692
40+
Dendrite 6: Integral - alpha: 83.33333333 beta: 769.2307692
41+
42+
Population 3: Reticular
43+
Length: 0.5
44+
Q: 15.39601978
45+
Firing: Sigmoid - Theta: 0.01292 Sigma: 0.0038 Qmax: 340
46+
Dendrite 7: Integral - alpha: 83.33333333 beta: 769.2307692
47+
Dendrite 8: Integral - alpha: 83.33333333 beta: 769.2307692
48+
49+
Population 4: Relay
50+
Length: 0.5
51+
Q: 8.789733431
52+
Firing: Sigmoid - Theta: 0.01292 Sigma: 0.0038 Qmax: 340
53+
Dendrite 9: Integral - alpha: 83.33333333 beta: 769.2307692
54+
Dendrite 10: Integral - alpha: 83.33333333 beta: 769.2307692
55+
Dendrite 11: Integral - alpha: 83.33333333 beta: 769.2307692
56+
57+
Population 5: Stimulation
58+
Length: 0.5
59+
Stimulus: White - Onset: 0 Mean: 1 Psd: 1e-05
60+
61+
Propagator 1: Wave - Tau: 0 Range: 0.086 gamma: 116
62+
Propagator 2: Map - Tau: 0
63+
Propagator 3: Map - Tau: 0.0425
64+
Propagator 4: Wave - Tau: 0 Range: 0.086 gamma: 116
65+
Propagator 5: Map - Tau: 0
66+
Propagator 6: Map - Tau: 0.0425
67+
Propagator 7: Wave - Tau: 0.0425 Range: 0.086 gamma: 116
68+
Propagator 8: Map - Tau: 0
69+
Propagator 9: Wave - Tau: 0.0425 Range: 0.086 gamma: 116
70+
Propagator 10: Map - Tau: 0
71+
Propagator 11: Map - Tau: 0
72+
73+
Coupling 1: Map - nu: 0.001525377176
74+
Coupling 2: Map - nu: -0.003022754434
75+
Coupling 3: Map - nu: 0.0005674779589
76+
Coupling 4: Map - nu: 0.001525377176
77+
Coupling 5: Map - nu: -0.003022754434
78+
Coupling 6: Map - nu: 0.0005674779589
79+
Coupling 7: Map - nu: 0.0001695899041
80+
Coupling 8: Map - nu: 5.070036187e-05
81+
Coupling 9: Map - nu: 0.003447358203
82+
Coupling 10: Map - nu: -0.001465128967
83+
Coupling 11: Map - nu: 0.003593330094
84+
85+
Output: Node: All Start: 5 Interval: 0.5e-2
86+
Population: 1
87+
Dendrite:
88+
Propagator: 1
89+
Coupling:

src/de.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ class RK4 : public Integrator {
8888
void operator=(RK4&);
8989
protected:
9090
double h6; ///< == deltat/6
91+
double deltat5; ///< == deltat*0.5
9192

9293
vector<double> k1;
9394
vector<double> k2;
9495
vector<double> k3;
9596
vector<double> k4;
9697
vector<double> temp;
9798
public:
98-
explicit RK4( DE& de ) : Integrator(de), h6(de.deltat/6.),
99+
explicit RK4( DE& de ) : Integrator(de), h6(de.deltat/6.), deltat5(de.deltat*0.5),
99100
k1(de.n), k2(de.n), k3(de.n), k4(de.n), temp(de.n) {}
100101
~RK4(void) override = default;
101102

@@ -106,19 +107,19 @@ class RK4 : public Integrator {
106107
}
107108
de.rhs(temp,k1);
108109
for( vvd_size_type i=0; i<de.n; i++ ) {
109-
temp[i] = de.variables[i][j] +de.deltat*.5*k1[i];
110+
temp[i] = de.variables[i][j] +deltat5*k1[i];
110111
}
111112
de.rhs(temp,k2);
112113
for( vvd_size_type i=0; i<de.n; i++ ) {
113-
temp[i] = de.variables[i][j] +de.deltat*.5*k2[i];
114+
temp[i] = de.variables[i][j] +deltat5*k2[i];
114115
}
115116
de.rhs(temp,k3);
116117
for( vvd_size_type i=0; i<de.n; i++ ) {
117118
temp[i] = de.variables[i][j] +de.deltat*k3[i];
118119
}
119120
de.rhs(temp,k4);
120121
for( vvd_size_type i=0; i<de.n; i++ ) {
121-
de.variables[i][j] += h6*( k1[i] +2*k2[i] +2*k3[i] +k4[i] );
122+
de.variables[i][j] += h6*( k1[i] +2.0*k2[i] +2.0*k3[i] +k4[i] );
122123
}
123124
}
124125
}

src/dendrite.cpp

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@
99
#include "dendrite.h"
1010
using std::endl;
1111

12+
/**
13+
@brief Computes the derivatives of the dendritic response function.
14+
15+
The dendritic response function is given by:
16+
\f{eqnarray*}{
17+
\frac{dv}{dt}&=&W \\
18+
\frac{dW}{dt}&=&\left(\nu\phi - V - \left(\frac{1}{\alpha} + \frac{1}{\beta}\right) W\right) \alpha \beta \\
19+
\frac{d\nu\phi}{dt}&=&0
20+
\f}
21+
*/
22+
void Dendrite::DendriteDE::rhs( const vector<double>& y, vector<double>& dydt ) {
23+
// y = {V,W==dv/dt,nuphi}
24+
// dydt = {dv/dt==W, dW/dt==d^2V/dt^2,dnuphi/dt} d(nuphi)/dt from precouple
25+
dydt[0] = y[1];
26+
27+
dydt[1] = (y[2] - y[0] - factorab * y[1]) * alphaxbeta;
28+
29+
dydt[2] = 0.0;
30+
}
31+
1232
void Dendrite::init( Configf& configf ) {
1333
if( !configf.next( label("Dendrite ",index+1) )) {
1434
std::cerr<<"Dendrite "<<index+1<<" not found."<<endl;
@@ -23,51 +43,53 @@ void Dendrite::init( Configf& configf ) {
2343
} else {
2444
v.resize(nodes,atof(buffer.c_str()));
2545
}
26-
oldnp = v;
46+
2747
configf.param("alpha",alpha);
2848
configf.param("beta",beta);
2949

30-
aminusb = alpha - beta;
31-
expa = exp(-alpha*deltat);
32-
expb = exp(-beta*deltat);
50+
// Initialize constant factors to speed up computation.
3351
factorab = 1./alpha + 1./beta;
52+
alphaxbeta = alpha * beta;
53+
54+
de->init(v[0]); // call Dendrite::DendriteDE::init
55+
de->factorab = factorab;
56+
de->alphaxbeta = alphaxbeta;
57+
}
58+
59+
void Dendrite::DendriteDE::init(const double vinit) {
60+
variables[0].clear();
61+
variables[1].clear();
62+
variables[2].clear();
63+
variables[0].resize(nodes, vinit);
64+
variables[1].resize(nodes, 0.0);
65+
variables[2].resize(nodes, 0.0);
3466
}
3567

3668
Dendrite::Dendrite( size_type nodes, double deltat, size_type index,
3769
const Propagator& prepropag, const Coupling& precouple )
38-
: NF(nodes,deltat,index), v(nodes), dvdt(nodes,0), oldnp(nodes),
39-
prepropag(prepropag), precouple(precouple) {
70+
: NF(nodes,deltat,index), v(nodes), prepropag(prepropag), precouple(precouple) {
71+
de = new DendriteDE(nodes, deltat);
72+
rk4 = new RK4(*de);
4073
}
4174

42-
Dendrite::~Dendrite() = default;
75+
Dendrite::~Dendrite() {
76+
delete de;
77+
delete rk4;
78+
}
4379

4480
void Dendrite::step() {
45-
// assume that alpha, beta are constant and nu*phi is linear for the time step
46-
if(alpha!=beta) {
47-
for(size_type i=0; i<nodes; i++) {
48-
dpdt = ( precouple[i] -oldnp[i] )/deltat;
49-
adjustednp = oldnp[i] -factorab*dpdt -v[i];
50-
C1 = ( adjustednp*beta -dvdt[i] +dpdt )/aminusb;
51-
C1expa = C1*expa;
52-
C2expb = expb*(-C1-adjustednp);
53-
v[i] = C1expa+C2expb+precouple[i] -factorab*dpdt;
54-
dvdt[i] = C1expa*(-alpha) +C2expb*(-beta)+dpdt;
55-
oldnp[i]=precouple[i]; //Save current pulse density for next step
56-
}
57-
} else { // alpha==beta
58-
for(size_type i=0; i<nodes; i++) {
59-
dpdt = ( precouple[i] -oldnp[i] )/deltat;
60-
adjustednp = oldnp[i] -factorab*dpdt -v[i];
61-
C1 = dvdt[i] -alpha*adjustednp -dpdt;
62-
C1dtplusC2 = C1*deltat -adjustednp;
63-
v[i] = C1dtplusC2*expa +precouple[i] -factorab*dpdt;
64-
dvdt[i] = (C1-alpha*C1dtplusC2)*expa +dpdt;
65-
oldnp[i]=precouple[i]; //Save current pulse density for next step
66-
}
81+
//Copy the \nu\phi into their corresponding variable in the DE.
82+
for( size_type i=0; i<nodes; i++ ) {
83+
(*de)[2][i] = precouple[i]; // \nu\phi
84+
}
85+
//Integrate the dendritic response one step forward in time.
86+
rk4->step();
87+
//Copy the voltages from the updated DE to the local variable v.
88+
for( size_type i=0; i<nodes; i++ ) {
89+
v[i] = (*de)[0][i]; // Voltage
6790
}
6891
}
6992

70-
7193
void Dendrite::output( Output& output ) const {
7294
output("Dendrite",index+1,"V",v);
7395
}

src/dendrite.h

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,25 @@ class Dendrite : public NF {
1717
Dendrite(void); // default constructor
1818
Dendrite(Dendrite& ); // no copy constructor
1919

20-
// variables that are intialized once to speed up computation
21-
double aminusb; ///< == alpha - beta
22-
double expa; ///< == exp(-alpha*deltat)
23-
double expb; ///< == exp(-beta*deltat)
24-
double factorab; ///< == 1./alpha + 1./beta;
25-
26-
// variables that are used every timestep
27-
double adjustednp;
28-
double deltaPdeltat;
29-
double C1;
30-
double dpdt;
31-
double C1expa;
32-
double C2expb;
33-
double C1dtplusC2;
34-
protected:
35-
36-
double alpha; // needed here for DendriteRamp
37-
double beta;
20+
// variables that are initialized once to speed up computation
21+
double factorab; ///< == 1./alpha + 1./beta;
22+
double alphaxbeta; ///< == alpha * beta;
3823

39-
vector<double> v;
40-
vector<double> dvdt;
41-
//vector<double> np;
42-
vector<double> oldnp;
24+
protected:
25+
struct DendriteDE : public DE {
26+
double factorab, alphaxbeta;
27+
virtual void init( const double vinit);
28+
DendriteDE( size_type nodes, double deltat) : DE(nodes, deltat, 3) {}
29+
~DendriteDE(void) override = default;
30+
void rhs( const vector<double>& y, vector<double>& dydt ) override;
31+
};
32+
DendriteDE* de;
33+
RK4* rk4;
34+
35+
double alpha; ///< Mean decay rate of the soma response to a delta-function synaptic input (needed here for DendriteRamp).
36+
double beta; ///< Mean rise rate of the soma response to a delta-function synaptic input.
37+
38+
vector<double> v; ///< Membrane potential.
4339

4440
void init( Configf& configf ) override;
4541
//virtual void restart( Restartf& restartf );

src/dendrite_integral.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/** @file dendrite_integral.cpp
2+
@brief DendriteIntegral handles the dendritic response of the postsynaptic
3+
population using the integral form for the step() member-function.
4+
5+
A more detailed multiline description...
6+
7+
@author Peter Drysdale, Felix Fung,
8+
*/
9+
10+
#include "dendrite_integral.h"
11+
12+
13+
void DendriteIntegral::init( Configf& configf ) {
14+
Dendrite::init(configf);
15+
16+
oldnp = v;
17+
18+
// Initialize constant factors to speed up computation.
19+
aminusb = alpha - beta;
20+
expa = exp(-alpha*deltat);
21+
expb = exp(-beta*deltat);
22+
factorab = 1./alpha + 1./beta;
23+
}
24+
25+
DendriteIntegral::DendriteIntegral( size_type nodes, double deltat, size_type index,
26+
const Propagator& prepropag, const Coupling& precouple )
27+
: Dendrite(nodes, deltat, index, prepropag, precouple), dvdt(nodes,0), oldnp(nodes) {
28+
}
29+
30+
DendriteIntegral::~DendriteIntegral() = default;
31+
32+
void DendriteIntegral::step() {
33+
// assume that alpha, beta are constant and nu*phi is linear for the time step
34+
if(alpha!=beta) {
35+
for(size_type i=0; i<nodes; i++) {
36+
dpdt = ( precouple[i] -oldnp[i] )/deltat;
37+
adjustednp = oldnp[i] -factorab*dpdt -v[i];
38+
C1 = ( adjustednp*beta -dvdt[i] +dpdt )/aminusb;
39+
C1expa = C1*expa;
40+
C2expb = expb*(-C1-adjustednp);
41+
v[i] = C1expa+C2expb+precouple[i] -factorab*dpdt;
42+
dvdt[i] = C1expa*(-alpha) +C2expb*(-beta)+dpdt;
43+
oldnp[i]=precouple[i]; //Save current pulse density for next step
44+
}
45+
} else { // alpha==beta
46+
for(size_type i=0; i<nodes; i++) {
47+
dpdt = ( precouple[i] -oldnp[i] )/deltat;
48+
adjustednp = oldnp[i] -factorab*dpdt -v[i];
49+
C1 = dvdt[i] -alpha*adjustednp -dpdt;
50+
C1dtplusC2 = C1*deltat -adjustednp;
51+
v[i] = C1dtplusC2*expa +precouple[i] -factorab*dpdt;
52+
dvdt[i] = (C1-alpha*C1dtplusC2)*expa +dpdt;
53+
oldnp[i]=precouple[i]; //Save current pulse density for next step
54+
}
55+
}
56+
}

src/dendrite_integral.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/** @file dendrite_integral.h
2+
@brief Defines the DendriteIntegral class, which handles the response of the
3+
postsynaptic population using the integral form for the step()
4+
member-function.
5+
6+
A more detailed multiline description...
7+
8+
@author Peter Drysdale, Felix Fung,
9+
*/
10+
11+
#ifndef NEUROFIELD_SRC_DENDRITE_INTEGRAL_H
12+
#define NEUROFIELD_SRC_DENDRITE_INTEGRAL_H
13+
14+
#include "dendrite.h"
15+
16+
class DendriteIntegral : public Dendrite {
17+
DendriteIntegral(void); // default constructor
18+
DendriteIntegral(DendriteIntegral& ); // no copy constructor
19+
20+
// variables that are intialized once to speed up computation
21+
double aminusb; ///< == alpha - beta
22+
double expa; ///< == exp(-alpha*deltat)
23+
double expb; ///< == exp(-beta*deltat)
24+
double factorab; ///< == 1./alpha + 1./beta;
25+
26+
// variables that are used every timestep
27+
double adjustednp;
28+
double deltaPdeltat; //NOTE: doesn't seem to be used anywhere (???maybe replaced by current dpdt???).
29+
double C1;
30+
double dpdt; // Temporal derivative of pulse density.
31+
double C1expa;
32+
double C2expb;
33+
double C1dtplusC2;
34+
35+
protected:
36+
vector<double> dvdt; ///< Temporal derivative of the membrane potential.
37+
//vector<double> np; ///< Pulse density (nu*phi).
38+
vector<double> oldnp; ///< Pulse density (nu*phi) of the previous time-step.
39+
40+
void init( Configf& configf ) override;
41+
42+
public:
43+
44+
DendriteIntegral( size_type nodes, double deltat, size_type index,
45+
const Propagator& prepropag, const Coupling& precouple );
46+
~DendriteIntegral(void) override;
47+
void step(void) override;
48+
};
49+
50+
#endif //NEUROFIELD_SRC_DENDRITE_INTEGRAL_H

0 commit comments

Comments
 (0)