噪音通道模型_单个神经元的简单模型:Leaky integrate and fire (LIF) model
https://blog.csdn.net/weixin_42613773/article/details/112374981
LIFmodel.py
import numpy as np
import matplotlib.pyplot as plt
def calc_next_step(Vm, I, step_t, remaining_refrac_time):
Vl = -70
Gl = 0.025
C = 0.5
if Vm > -50 and Vm < 0: #threshold
Vm = 30 #spike potential
elif Vm > 0:
Vm = -60 #reset potential
remaining_refrac_time = remaining_refrac_time*0 + 2 #reset everything to 2
elif remaining_refrac_time>0:
Vm = -60 #reset potential
remaining_refrac_time -= step_t
else:
Vm = Vm + step_t*(-Gl*(Vm-Vl) + I)/C
if remaining_refrac_time<0:
remaining_refrac_time = remaining_refrac_time*0
return Vm,remaining_refrac_time
step_t = 0.001
t = np.arange(0,500+step_t,step_t)
Vm_out = np.zeros(np.shape(t)[0])
I = 0.9
ind = 0
Vm_out[0]=-70 #init state
remaining_refrac_time = 0
for tt in t[0:-1]:
Vm_out[ind+1],remaining_refrac_time = calc_next_step(Vm_out[ind],I,step_t,remaining_refrac_time)
ind += 1
plt.plot(t,Vm_out)
plt.xlabel("time /ms")
plt.ylabel("Memberance Potential /mV")
plt.show()
clear
close all
C = 0.2; % capacitance in nF
R = 100; % resitance in megaohm
dt = 0.01; % integration time step in milliseconds
dur = 0.3; % simulation duration in sec
Vthresh = -60; % threshold in mV
EL = -70; % leakage reversal potential in mV
Vreset = -70; % reset voltage in mV
V0 = -70; % initial condition in mV
tref = 3; % refractory period in msec
Ij = 0.15; % injected current in nA
dur = dur*1000; % simulation duration in msec
niter = floor(dur/dt)+1; % number of iterations
V = EL; % initial condition
spikes = zeros(1,niter); % vector for storing binary spike train
Vm = zeros(1,niter); % vector for storing Vm
Vm(1) = V0; % assign initial condition to first element of Vm
t_vector = 0:dt:(length(Vm)-1)*dt; % vector of time values
tcounter = tref; % counter for how long we have been refracted,
% it is not refracted when we start
taum = R*C; % time constant in msec
for idx = 2 : niter % loop for number of iterations
% check if we are refracted
if tcounter < tref
V = Vreset;
tcounter = tcounter + dt; % update refractory counter
else % we integrate as before
dVdt =(1/taum) .* ((EL - V) + R * Ij);
V = V + dt .* dVdt;
end
% check if spiking
if V > Vthresh
spikes(idx) = 1;
V = Vreset;
tcounter = 0; % reset refractory counter
end
Vm(idx) = V;
end
plot(t_vector,Vm);
xlabel('time (ms)');
ylabel('V_m (mV)');
————————————————
版权声明:本文为CSDN博主「Gu Elizabeth」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_34970603/article/details/106377701