Permalink
Newer
Older
100644 200 lines (162 sloc) 6.96 KB
Apr 24, 2014 @miscco Cleanup. Made comments line save
1 /*
Nov 9, 2015 @miscco Updated the code with correct license.
2 * Copyright (c) 2015 University of Lübeck
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 *
22 * AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
23 *
Mar 21, 2016 @miscco Corrected typo in the reference
24 * Based on: Characterization of K-Complexes and Slow Wave Activity in a Neural Mass Model
25 * A Weigenand, M Schellenberger Costa, H-VV Ngo, JC Claussen, T Martinetz
26 * PLoS Computational Biology. 2014;10:e1003923
27 *
28 * A thalamocortical neural mass model of the EEG during NREM sleep and its response
Nov 9, 2015 @miscco Updated the code with correct license.
29 * to auditory stimulation.
30 * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
31 * JC Claussen.
Sep 13, 2016 @miscco Major cleanup and moderinization
32 * PLoS Computational Biology http://dx.doi.org/10.1371/journal.pcbi.1005022
Nov 9, 2015 @miscco Updated the code with correct license.
33 */
Apr 24, 2014 @miscco Cleanup. Made comments line save
34
Sep 13, 2016 @miscco Major cleanup and moderinization
35 /******************************************************************************/
36 /* Implementation of a cortical module */
37 /******************************************************************************/
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
38 #pragma once
39 #include <cmath>
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
40 #include <vector>
Sep 13, 2016 @miscco Major cleanup and moderinization
41
Dec 29, 2015 @miscco General code cleanup.
42 #include "Random_Stream.h"
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
43 #include "Thalamic_Column.h"
May 28, 2014 @miscco Updated the parameters to show better behavior.
44 class Thalamic_Column;
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
45
46 class Cortical_Column {
47 public:
Sep 13, 2016 @miscco Major cleanup and moderinization
48 Cortical_Column(double* Param, double* Con)
49 :sigma_p (Param[0]), g_KNa (Param[1]), dphi (Param[2]),
50 N_pt (Con[2]), N_it (Con[3])
51 {set_RNG();}
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
52
Sep 13, 2016 @miscco Major cleanup and moderinization
53 /* Connect to the thalamic module */
54 void get_Thalamus(Thalamic_Column& T) {Thalamus = &T;}
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
55
Sep 13, 2016 @miscco Major cleanup and moderinization
56 /* ODE functions */
57 void set_RK (int);
58 void add_RK (void);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
59
Jan 9, 2015 @miscco Fixed some of the parameters to get a better SO_Average for N2. However,
60 private:
Sep 13, 2016 @miscco Major cleanup and moderinization
61 /* Declaration of private functions */
62 /* Initialize the RNGs */
63 void set_RNG (void);
64
65 /* Firing rates */
66 double get_Qp (int) const;
67 double get_Qi (int) const;
68
69 /* Currents */
70 double I_ep (int) const;
71 double I_ei (int) const;
72 double I_gp (int) const;
73 double I_gi (int) const;
74 double I_L_p (int) const;
75 double I_L_i (int) const;
76 double I_KNa (int) const;
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
77
Sep 13, 2016 @miscco Major cleanup and moderinization
78 /* Potassium pump */
79 double Na_pump (int) const;
80
81 /* Noise functions */
82 double noise_xRK (int,int) const;
83 double noise_aRK (int) const;
84
85 /* Helper functions */
86 inline std::vector<double> init (double value)
87 {return {value, 0.0, 0.0, 0.0, 0.0};}
88
89 inline void add_RK (std::vector<double>& var)
90 {var[0] = (-3*var[0] + 2*var[1] + 4*var[2] + 2*var[3] + var[4])/6;}
91
92 inline void add_RK_noise (std::vector<double>& var, unsigned noise)
93 {var[0] = (-3*var[0] + 2*var[1] + 4*var[2] + 2*var[3] + var[4])/6 + noise_aRK(noise);}
94
95 /* Declaration and Initialization of parameters */
96 /* Membrane time in ms */
97 const double tau_p = 30;
98 const double tau_i = 30;
99
100 /* Maximum firing rate in ms^-1 */
101 const double Qp_max = 30.E-3;
102 const double Qi_max = 60.E-3;
103
104 /* Sigmoid threshold in mV */
105 const double theta_p = -58.5;
106 const double theta_i = -58.5;
107
108 /* Sigmoid gain in mV */
109 const double sigma_p = 4;
110 const double sigma_i = 6;
111
112 /* Scaling parameter for sigmoidal mapping (dimensionless) */
113 const double C1 = (M_PI/sqrt(3));
114
115 /* parameters of the firing adaption */
116 const double alpha_Na = 2; /* Sodium influx per spike in mM ms */
117 const double tau_Na = 1.7; /* Sodium time constant in ms */
118
119 const double R_pump = 0.09; /* Na-K pump constant in mM/ms */
120 const double Na_eq = 9.5; /* Na-eq concentration in mM */
121
122 /* PSP rise time in ms^-1 */
123 const double gamma_e = 70E-3;
124 const double gamma_g = 58.6E-3;
125
126 /* Axonal flux time constant */
127 const double nu = 120E-3;
128
129 /* Leak weight in aU*/
130 const double g_L = 1.;
131
132 /* Synaptic weight in ms */
133 const double g_AMPA = 1.;
134 const double g_GABA = 1.;
135
136 /* Conductivity */
137 /* KNa in mS/cm^2 */
138 const double g_KNa = 1.33;
139
140 /* Reversal potentials in mV */
141 /* Synaptic */
142 const double E_AMPA = 0;
143 const double E_GABA = -70;
144
145 /* Leak */
146 const double E_L_p = -64;
147 const double E_L_i = -64;
148
149 /* Potassium */
150 const double E_K = -100;
151
152 /* Noise parameters in ms^-1 */
153 const double mphi = 0E-3;
154 const double dphi = 20E-1;
155 double input = 0.0;
156
157 /* Connectivities (dimensionless) */
158 const double N_pp = 115;
159 const double N_ip = 72;
160 const double N_pi = 90;
161 const double N_ii = 90;
162 const double N_pt = 2.5;
163 const double N_it = 2.5;
164
165 /* Pointer to thalamic column */
166 Thalamic_Column* Thalamus;
167
168 /* Parameters for SRK4 iteration */
169 const std::vector<double> A = {0.5, 0.5, 1.0, 1.0};
170 const std::vector<double> B = {0.75, 0.75, 0.0, 0.0};
171
172 /* Random number generators */
Sep 26, 2016 @miscco Fixed a minor casting bug in random stream implementation and renamed…
173 std::vector<randomStreamNormal> MTRands;
Sep 13, 2016 @miscco Major cleanup and moderinization
174
175 /* Container for noise */
176 std::vector<double> Rand_vars;
177
178 /* Population variables */
179 std::vector<double> Vp = init(E_L_p), /* excitatory membrane voltage */
180 Vi = init(E_L_i), /* inhibitory membrane voltage */
181 Na = init(Na_eq), /* Na concentration */
182 s_ep= init(0.0), /* PostSP from excitatory to excitatory population */
183 s_ei= init(0.0), /* PostSP from excitatory to inhibitory population */
184 s_gp= init(0.0), /* PostSP from inhibitory to excitatory population */
185 s_gi= init(0.0), /* PostSP from inhibitory to inhibitory population */
186 y = init(0.0), /* axonal flux */
187 x_ep= init(0.0), /* derivative of s_ep */
188 x_ei= init(0.0), /* derivative of s_ei */
189 x_gp= init(0.0), /* derivative of s_gp */
190 x_gi= init(0.0), /* derivative of s_gi */
191 x = init(0.0); /* derivative of y */
192
193 /* Data storage access */
Apr 12, 2017 @miscco Update get_data signature in Cortical_Column.h
194 friend void get_data (int, Cortical_Column&, Thalamic_Column&, std::vector<double*>&);
Sep 13, 2016 @miscco Major cleanup and moderinization
195
196 /* Stimulation protocol access */
197 friend class Stim;
198 friend class Thalamic_Column;
199 };