-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExcitableSystem.m
More file actions
185 lines (135 loc) · 4.87 KB
/
ExcitableSystem.m
File metadata and controls
185 lines (135 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% requena_carrion.m
%
% J Requena-Carrion, 2016
%
% 1. Simulates the stochastic model of excitable cell proposed in the manuscript:
%
% Requena-Carrion J & Requena-Carrion VJ, "Distribution of transition times
% in a stochastic model of excitable cell: Insights into the cell-intrinsic
% mechanisms of randomness in neuronal inter-spike intervals"
%
%
% 2. Provides the histograms for the state probability distributions,
% the distributions of transition times and the inter-spyke interval durations.
%
%
% 3. Plost the exact solutions of the distributions.
%
%
% 4. Can be extended to a 3-state model for reproducing subthreshold
% oscillations.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simulation parameters and initialization
N = 10000; % Population size, i.e. number of (uncoupled) systems
T = 4; % Simulation duration
Deltat = 10^(-4); % Time step
S = ones(1,N); % States vector, can take the values 1 (excited), 2 (rest) and 3 (rest)
nextS = zeros(size(S)); % Identifies which systems change state
Trest = zeros(size(S)); % Last time instant a system entered S1 from S2
Texc = zeros(size(S)); % Last time instant a system entered S2
Tsub = zeros(size(S)); % Last time instant a system entered S3
Tnu = zeros(size(S)); % Last time instant a system entered S1
nextTnu = zeros(size(S));% Identifies which systems need update Tnu
RT = []; % Collection of measured total resting times
APD = []; % Collection of measured action potential durations
ISI = []; % Collection of measured inter spyke intervals
P_exc = zeros(size(S));% Probability of exiting S1
P_reset = 0; % Probability of entering S3 after exiting S1. If 0,
% the two-state variant is simulated
kqDt = 10^2*Deltat; % Product kq
nextAPD = ones(size(S));% Next APD after excitation
lambda1 = 0.5; % Excitability recovery rate
lambda2 = 10; % APD recovery rate
for t=0:Deltat:T
S1 = S==1;
S2 = S==2;
S3 = S==3;
% Systems that will exit S1
P_exc(S1) = kqDt * (1-exp(-lambda1*(t-Tnu(S1))));
nextS(S1) = P_exc(S1)>rand(size(P_exc(S1)));
% If P_reset=0, a 2S model is implemented and Rest2Rest plays no role.
% Otherwise, Rest2rest is used to determine which systems exiting S1
% enter S2 and which enter S3
Rest2Rest = P_reset > rand(size(S1));
nextS12 = (nextS==1)&(S1)&(~Rest2Rest);
nextS13 = (nextS==1)&(S1)&Rest2Rest;
nextAPD(nextS12) = (1-exp(-lambda2*(t-Tnu(nextS12))));% 1; %
nextAPD(nextS13) = (1-exp(-lambda2*(t-Tnu(nextS13))));% 1; %
% Systems that will leave S2
nextS(S2) = (t-Texc(S2))>=nextAPD(S2);
nextS21 = (nextS==1)&(S2);
% Systems that will leave S3
nextS(S3) = (t-Tsub(S3))>=nextAPD(S3);
nextS31 = (nextS==1)&(S3);
% Measured events
ISI = [ISI (t-Texc(nextS12 & (Texc~=0)))];
RT = [RT (t-Trest(nextS12))];
APD = [APD nextAPD(nextS12)];
% Times update
Texc(nextS12) = t;
Tsub(nextS13) = t;
Trest(nextS21) = t;
Tnu(nextS21) = t;
Tnu(nextS31) = t;
% State update
S(nextS12) = 2;
S(nextS21) = 1;
S(nextS13) = 3;
S(nextS31) = 1;
nextS = zeros(size(S));
end
%%
Nbins=60;
% Data for the steady-state distributions rho and sigma
S1 = S==1;
taus1 = t-Trest(S1);
S2 = S==2;
taus2 = t-Texc(S2);
% Analytical solutions for rho, alpha and beta (No analytical solution is
% provided for sigma)
T=2;
Delta_tau=0.001;
q1=(kqDt/(Deltat*lambda1));
q2=(kqDt/(Deltat*lambda2));
tau1end=1-Delta_tau;
tau1=0:Delta_tau:tau1end;
tau2end=tau1end;
tau2=0:Delta_tau:tau2end;
tauISI=0:Delta_tau:tau1end+tau2end;
rho=exp(-(lambda1*tau1+exp(-lambda1*tau1))*q1);
rhon=rho/sum(rho*Delta_tau);
alpha=(kqDt/Deltat)*(1-exp(-lambda1*tau1)).*exp(-(lambda1*tau1+exp(-lambda1*tau1))*q1);
alphan=alpha/(sum(alpha)*Delta_tau);
beta=(kqDt/Deltat)*((1-(1-tau2).^(lambda1/lambda2))).*((1-tau2).^q2).*exp(-q1*((1-tau2).^(lambda1/lambda2)))./(lambda2*(1-tau2));
betan=beta/(sum(beta)*Delta_tau);
ISIexact=conv(alphan,betan);
ISIexactn=ISIexact/(sum(ISIexact)*Delta_tau);
%%
figure
subplot(411)
histogram(taus1,Nbins,'Normalization','pdf')
hold on
if P_reset==0, plot(tau1,rhon,'r'), end
axis([0 1 0 inf])
title('\rho(\tau_1,\infty)')
subplot(412)
histogram(RT,Nbins,'Normalization','pdf')
hold on
if P_reset==0, plot(tau1,alphan,'r'), end
axis([0 1 0 inf])
title('f_1(\tau_1,\infty)')
subplot(413)
histogram(APD,Nbins,'Normalization','pdf')
hold on
if P_reset==0, plot(tau2,betan,'r'), end
axis([0 1 0 inf])
title('f_2(\tau_2,\infty)')
subplot(414)
histogram(ISI,Nbins,'Normalization','pdf')
hold on
if P_reset==0, plot(tauISI,ISIexactn,'r'), end
axis([0 2 0 inf])
title('f_{ISI}(\tau_{ISI},\infty)')