-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISI.m
More file actions
65 lines (55 loc) · 2.24 KB
/
Copy pathISI.m
File metadata and controls
65 lines (55 loc) · 2.24 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
%% Comparison of Steady Firing Rate and Inverse of Interspike Interval as a Function of Applied Current
tau_ref = 2.5e-3; % refractory period (ms)
tnext = tau_ref/dt; % time until next spike can be fired
tmax2 = 5; % simulation time (s)
tvec2 = 0:dt:tmax2; % time vector
Iapp1b = 250e-12:20e-12:650e-12;% applied current vector
V1b = zeros(size(tvec2)); % membrane potential vector
V1b(1) = El; % set initial voltage to resting potential
Grsa1b = zeros(size(tvec2)); % adaptive conductance vector
spiket1b = zeros(size(tvec2)); % spike time vector
steady1b = zeros(size(Iapp1b)); % steady-state firing rate vector
f_fr = zeros(size(Iapp1b)); % first ISI firing rate vector
%% Firing Simulations
% loop through applied currents
for k = 1:length(Iapp1b)
spiket1b = zeros(size(tvec2)); % reset spike times
% loop through time steps
for i = 2:length(tvec2)
% calculate membrane potential derivative
dVdt = 1/Cm*((El - V1b(i-1))/Rm + Grsa1b(i-1)*(Ek-V1b(i-1)) + Iapp1b(k));
% update membrane potential
V1b(i) = V1b(i-1) + dVdt*dt;
% update sra conductance
Grsa1b(i) = Grsa1b(i-1) - Grsa1b(i-1)/tausra*dt;
% after a spike, fix membrane potential to Vreset for tau_ref period
if spiket1b(i) == -1
V1b(i) = Vreset;
end
% if threshold is reached, generate a spike
if V1b(i) > Vth
% reset membrane potential and increase sra conductance
V1b(i) = Vreset;
Grsa1b(i) = Grsa1b(i) + deltaGsra;
% mark spike time and refractory period
spiket1b(i) = 1;
for j = 1:tnext
spiket1b(i+j) = -1;
end
end
end
% calculate firing rate and update firing rate vectors
peak_ind = find(spiket1b == 1);
if isempty(peak_ind)
f_fr(k) = 0;
else
f_fr(k) = 1/((peak_ind(2) - peak_ind(1))*(10^(-4))); % Calculate inverse of ISI
end
steady1b(k) = length(peak_ind)/tmax2;
end
%% Plot Figures
figure;
plot(Iapp1b, steady1b, Iapp1b, f_fr, 'ro')
title('Firing rate vs Applied Current')
xlabel('Applied current (A)'), ylabel('Firing rate (Hz)')
legend('steady state firing rate', 'inverse of first ISI', location='northwest')