计算神经生物学作业

噪音通道模型_单个神经元的简单模型: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()


LIFmodel1.fig



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


matlab图
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我是黑夜里大雨纷飞的人啊 1 “又到一年六月,有人笑有人哭,有人欢乐有人忧愁,有人惊喜有人失落,有的觉得收获满满有...
    陌忘宇阅读 8,607评论 28 53
  • 信任包括信任自己和信任他人 很多时候,很多事情,失败、遗憾、错过,源于不自信,不信任他人 觉得自己做不成,别人做不...
    吴氵晃阅读 6,231评论 4 8
  • 步骤:发微博01-导航栏内容 -> 发微博02-自定义TextView -> 发微博03-完善TextView和...
    dibadalu阅读 3,189评论 1 3
  • 回这一趟老家,心里多了两个疙瘩。第一是堂姐现在谈了一个有妇之夫,在她的语言中感觉,她不打算跟他有太长远的计划,这让...
    安九阅读 3,545评论 2 4