Permalink
Newer
Older
100644 245 lines (212 sloc) 9.67 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 *
24 * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
25 * to auditory stimulation.
26 * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
27 * JC Claussen.
Sep 13, 2016 @miscco Major cleanup and moderinization
28 * PLoS Computational Biology http://dx.doi.org/10.1371/journal.pcbi.1005022
Nov 9, 2015 @miscco Updated the code with correct license.
29 */
Apr 24, 2014 @miscco Cleanup. Made comments line save
30
Sep 13, 2016 @miscco Major cleanup and moderinization
31 /******************************************************************************/
32 /* Functions of the thalamic module */
33 /******************************************************************************/
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
34 #include "Thalamic_Column.h"
35
Sep 13, 2016 @miscco Major cleanup and moderinization
36 /******************************************************************************/
37 /* Initialization of RNG */
38 /******************************************************************************/
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
39 void Thalamic_Column::set_RNG(void) {
Sep 13, 2016 @miscco Major cleanup and moderinization
40 extern const double dt;
41 unsigned numRandomVariables = 1;
42
43 MTRands.reserve(2*numRandomVariables);
44 Rand_vars.reserve(2*numRandomVariables);
45 for (unsigned i=0; i < numRandomVariables; ++i){
46 /* Add the RNG for I_{l}*/
Sep 26, 2016 @miscco Fixed a minor casting bug in random stream implementation and renamed…
47 MTRands.push_back(randomStreamNormal(0.0, dphi*dt));
Sep 13, 2016 @miscco Major cleanup and moderinization
48
49 /* Add the RNG for I_{l,0} */
Sep 26, 2016 @miscco Fixed a minor casting bug in random stream implementation and renamed…
50 MTRands.push_back(randomStreamNormal(0.0, dt));
Sep 13, 2016 @miscco Major cleanup and moderinization
51
52 /* Get the random number for the first iteration */
53 Rand_vars.push_back(MTRands[2*i]());
54 Rand_vars.push_back(MTRands[2*i+1]());
55 }
56 }
57 /******************************************************************************/
58 /* RK noise scaling */
59 /******************************************************************************/
60 double Thalamic_Column::noise_xRK(int N, int M) const{
61 return gamma_e * gamma_e * (Rand_vars[2*M] + Rand_vars[2*M+1]/std::sqrt(3))*B[N];
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
62 }
63
Sep 13, 2016 @miscco Major cleanup and moderinization
64 double Thalamic_Column::noise_aRK(int M) const{
65 return gamma_e * gamma_e * (Rand_vars[2*M] - Rand_vars[2*M+1]*std::sqrt(3))/4;
66 }
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
67
Sep 13, 2016 @miscco Major cleanup and moderinization
68 /******************************************************************************/
69 /* Firing Rate functions */
70 /******************************************************************************/
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
71 double Thalamic_Column::get_Qt (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
72 return Qt_max/ (1 + exp(-C1 * (Vt[N] - theta_t) / sigma_t));
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
73 }
74
75 double Thalamic_Column::get_Qr (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
76 return Qr_max / (1 + exp(-C1 * (Vr[N]- theta_r) / sigma_r));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
77 }
78
Sep 13, 2016 @miscco Major cleanup and moderinization
79 /******************************************************************************/
80 /* Synaptic currents */
81 /******************************************************************************/
Apr 24, 2014 @miscco Cleanup. Made comments line save
82 /* Excitatory input to TC population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
83 double Thalamic_Column::I_et (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
84 return g_AMPA * s_et[N]* (Vt[N]- E_AMPA);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
85 }
86
Apr 24, 2014 @miscco Cleanup. Made comments line save
87 /* Inhibitory input to TC population */
Feb 1, 2016 @miscco Switched to the random_stream header for RNGs and updated the naming …
88 double Thalamic_Column::I_gt (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
89 return g_GABA * s_gt[N]* (Vt[N]- E_GABA);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
90 }
Apr 24, 2014 @miscco Cleanup. Made comments line save
91 /* Excitatory input to RE population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
92 double Thalamic_Column::I_er (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
93 return g_AMPA * s_er[N]* (Vr[N]- E_AMPA);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
94 }
95
Apr 24, 2014 @miscco Cleanup. Made comments line save
96 /* Inhibitory input to RE population */
Feb 1, 2016 @miscco Switched to the random_stream header for RNGs and updated the naming …
97 double Thalamic_Column::I_gr (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
98 return g_GABA * s_gr[N]* (Vr[N]- E_GABA);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
99 }
100
Sep 13, 2016 @miscco Major cleanup and moderinization
101 /******************************************************************************/
102 /* I_T gating functions */
103 /******************************************************************************/
Apr 24, 2014 @miscco Cleanup. Made comments line save
104 /* Activation in TC population after Destexhe 1996 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
105 double Thalamic_Column::m_inf_T_t (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
106 return 1/(1+exp(-(Vt[N]+59)/6.2));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
107 }
108
Apr 24, 2014 @miscco Cleanup. Made comments line save
109 /* Activation in RE population after Destexhe 1996 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
110 double Thalamic_Column::m_inf_T_r (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
111 return 1/(1+exp(-(Vr[N]+52)/7.4));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
112 }
113
Apr 24, 2014 @miscco Cleanup. Made comments line save
114 /* Deactivation in TC population after Destexhe 1996 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
115 double Thalamic_Column::h_inf_T_t (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
116 return 1/(1+exp( (Vt[N]+81)/4));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
117 }
118
Apr 24, 2014 @miscco Cleanup. Made comments line save
119 /* Deactivation in RE population after Destexhe 1996 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
120 double Thalamic_Column::h_inf_T_r (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
121 return 1/(1+exp( (Vr[N]+80)/5));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
122 }
123
Mar 24, 2016 @miscco Fixed wrong lebeling of connectivities
124 /* Deactivation time in RE population after Destexhe 1996 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
125 double Thalamic_Column::tau_h_T_t (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
126 return (30.8 + (211.4 + exp((Vt[N]+115.2)/5))/(1 + exp((Vt[N]+86)/3.2)))/3.7371928;
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
127 }
128
Apr 24, 2014 @miscco Cleanup. Made comments line save
129 /* Deactivation time in RE population after Destexhe 1996 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
130 double Thalamic_Column::tau_h_T_r (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
131 return (85 + 1/(exp((Vr[N]+48)/4) + exp(-(Vr[N]+407)/50)))/3.7371928;
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
132 }
133
Sep 13, 2016 @miscco Major cleanup and moderinization
134 /******************************************************************************/
135 /* I_h gating functions */
136 /******************************************************************************/
Apr 24, 2014 @miscco Cleanup. Made comments line save
137 /* Activation in TC population after Destexhe 1993 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
138 double Thalamic_Column::m_inf_h (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
139 return 1/(1+exp( (Vt[N]+75)/5.5));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
140 }
141
Nov 7, 2014 @miscco More tuning, changed Ca0 to 2.4. alpha_Ca to 51.8
142 /* Activation time for slow components in TC population after Chen2012 */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
143 double Thalamic_Column::tau_m_h (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
144 return (20 + 1000/(exp((Vt[N]+ 71.5)/14.2) + exp(-(Vt[N]+ 89)/11.6)));
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
145 }
Nov 7, 2014 @miscco More tuning, changed Ca0 to 2.4. alpha_Ca to 51.8
146
147 /* Instantaneous calcium binding onto messenger protein after Chen2012 */
Aug 7, 2015 @miscco Update of RK iteration
148 double Thalamic_Column::P_h (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
149 //return k1 * pow(Ca[N], n_P)/(k1*pow(Ca[N], n_P)+k2);
150 return k1 * Ca[N] * Ca[N] * Ca[N] * Ca[N]/(k1 * Ca[N] * Ca[N] * Ca[N] * Ca[N]+k2);
Nov 7, 2014 @miscco More tuning, changed Ca0 to 2.4. alpha_Ca to 51.8
151 }
Nov 13, 2014 @miscco Added a tracking function for I_h activation.
152
Aug 7, 2015 @miscco Update of RK iteration
153 /* Return I_h activation */
Nov 13, 2014 @miscco Added a tracking function for I_h activation.
154 double Thalamic_Column::act_h (void) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
155 return m_h[0] + g_inc * m_h2[0];
Nov 13, 2014 @miscco Added a tracking function for I_h activation.
156 }
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
157
Sep 13, 2016 @miscco Major cleanup and moderinization
158 /******************************************************************************/
159 /* Intrinsic currents */
160 /******************************************************************************/
Apr 24, 2014 @miscco Cleanup. Made comments line save
161 /* Leak current of TC population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
162 double Thalamic_Column::I_L_t (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
163 return g_L * (Vt[N]- E_L_t);
164
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
165 }
166
Apr 24, 2014 @miscco Cleanup. Made comments line save
167 /* Potassium leak current of TC population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
168 double Thalamic_Column::I_LK_t (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
169 return g_LK * (Vt[N]- E_K);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
170 }
171
Apr 24, 2014 @miscco Cleanup. Made comments line save
172 /* Leak current of RE population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
173 double Thalamic_Column::I_L_r (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
174 return g_L * (Vr[N]- E_L_r);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
175 }
176
Apr 24, 2014 @miscco Cleanup. Made comments line save
177 /* Potassium leak current of RE population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
178 double Thalamic_Column::I_LK_r (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
179 return g_LK * (Vr[N]- E_K);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
180 }
181
Apr 24, 2014 @miscco Cleanup. Made comments line save
182 /* T-type current of TC population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
183 double Thalamic_Column::I_T_t (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
184 return g_T_t * m_inf_T_t(N) * m_inf_T_t(N) * h_T_t[N] * (Vt[N]- E_Ca);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
185 }
186
Apr 24, 2014 @miscco Cleanup. Made comments line save
187 /* T-type current of RE population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
188 double Thalamic_Column::I_T_r (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
189 return g_T_r * m_inf_T_r(N) * m_inf_T_r(N) * h_T_r[N] * (Vr[N]- E_Ca);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
190 }
191
Apr 24, 2014 @miscco Cleanup. Made comments line save
192 /* h-type current of TC population */
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
193 double Thalamic_Column::I_h (int N) const{
Sep 13, 2016 @miscco Major cleanup and moderinization
194 return g_h * (m_h[N] + g_inc * m_h2[N]) * (Vt[N]- E_h);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
195 }
196
Sep 13, 2016 @miscco Major cleanup and moderinization
197 /******************************************************************************/
198 /* SRK iteration */
199 /******************************************************************************/
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
200 void Thalamic_Column::set_RK (int N) {
Sep 13, 2016 @miscco Major cleanup and moderinization
201 extern const double dt;
202 Vt [N+1] = Vt [0] + A[N]*dt*(-(I_L_t(N) + I_et(N) + I_gt(N))/tau_t - C_m * (I_LK_t(N) + I_T_t(N) + I_h(N)));
203 Vr [N+1] = Vr [0] + A[N]*dt*(-(I_L_r(N) + I_er(N) + I_gr(N))/tau_r - C_m * (I_LK_r(N) + I_T_r(N)));
204 Ca [N+1] = Ca [0] + A[N]*dt*(alpha_Ca * I_T_t(N) - (Ca[N] - Ca_0)/tau_Ca);
205 h_T_t [N+1] = h_T_t[0] + A[N]*dt*(h_inf_T_t(N) - h_T_t[N])/tau_h_T_t(N);
206 h_T_r [N+1] = h_T_r[0] + A[N]*dt*(h_inf_T_r(N) - h_T_r[N])/tau_h_T_r(N);
207 m_h [N+1] = m_h [0] + A[N]*dt*((m_inf_h(N) * (1 - m_h2[N]) - m_h[N])/tau_m_h(N) - k3 * P_h(N) * m_h[N] + k4 * m_h2[N]);
208 m_h2 [N+1] = m_h2 [0] + A[N]*dt*(k3 * P_h(N) * m_h[N] - k4 * m_h2[N]);
209 s_et [N+1] = s_et [0] + A[N]*dt*(x_et[N]);
210 s_er [N+1] = s_er [0] + A[N]*dt*(x_er[N]);
211 s_gt [N+1] = s_gt [0] + A[N]*dt*(x_gt[N]);
212 s_gr [N+1] = s_gr [0] + A[N]*dt*(x_gr[N]);
213 y [N+1] = y [0] + A[N]*dt*(x [N]);
214 x_et [N+1] = x_et [0] + A[N]*dt*(gamma_e*gamma_e * ( + N_tp * Cortex->y[N] - s_et[N]) - 2 * gamma_e * x_et[N]) + noise_xRK(N,0);
215 x_er [N+1] = x_er [0] + A[N]*dt*(gamma_e*gamma_e * (N_rt * get_Qt(N) + N_rp * Cortex->y[N] - s_er[N]) - 2 * gamma_e * x_er[N]);
216 x_gt [N+1] = x_gt [0] + A[N]*dt*(gamma_g*gamma_g * (N_tr * get_Qr(N) - s_gt[N]) - 2 * gamma_g * x_gt[N]);
217 x_gr [N+1] = x_gr [0] + A[N]*dt*(gamma_g*gamma_g * (N_rr * get_Qr(N) - s_gr[N]) - 2 * gamma_g * x_gr[N]);
218 x [N+1] = x [0] + A[N]*dt*(nu * nu * ( get_Qt(N) - y [N]) - 2 * nu * x [N]);
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
219 }
220
Mar 10, 2014 @miscco First modular implementation of the thalamo-cortical model.
221 void Thalamic_Column::add_RK(void) {
Sep 13, 2016 @miscco Major cleanup and moderinization
222 add_RK(Vt);
223 add_RK(Vr);
224 add_RK(Ca);
225 add_RK(s_et);
226 add_RK(s_er);
227 add_RK(s_gt);
228 add_RK(s_gr);
229 add_RK(y);
230 add_RK_noise(x_et, 0);
231 add_RK(x_er);
232 add_RK(x_gt);
233 add_RK(x_gr);
234 add_RK(x);
235 add_RK(h_T_t);
236 add_RK(h_T_r);
237 add_RK(m_h);
238 add_RK(m_h2);
239
240 /* Generate noise for the next iteration */
241 for (unsigned i=0; i<Rand_vars.size(); ++i) {
242 Rand_vars[i] = MTRands[i]() + input;
243 }
Mar 1, 2014 @miscco New implementation of the thalamo-cortical model
244 }