image thumbnail
from Excitatory and inhibitory post-synaptic potentials by Massimiliano Versace
This code demonstrates Excitatory and Inhibitory Postsynaptic Potentials on a neuron.

epsp_ipsp(eVal,iVal)
%%% eVal = [number of inputs, rise_time, fall_time] (epsp)
%%% iVal = [number of inputs, rise_time, fall_time] (ipsp)
function [tv,epsp_data, ipsp_data, spike_data] = epsp_ipsp(eVal,iVal)

%%% Create Inputs %%%%%
span=50; %msec
e_input=zeros(1,span+1);
i_input=e_input;

%%% set epsp input; spreads input evenly over 50 msec
e_taur=eVal(2);
e_tauf=eVal(3);
if (eVal(1))
  gap1=span/(eVal(1)+1);
  p1=floor(1:gap1:span);
  e_input(p1)=1;
  e_input=e_input(2:span+1);
end

%%% set ipsp input; spreads input evenly over 50 msec
i_taur=iVal(2);
i_tauf=iVal(3);
if (iVal(1))
  gap2=span/(iVal(1)+1);
  p2=floor(1:gap2:span);
  i_input(p2)=1;
  i_input=i_input(2:span+1);
end

%General parameters
dt = 0.005;          %Integration step (ms) Note that dt=0.05 leads to errors
dt_len=round(1/dt);
len=span*dt_len;

g_E = zeros(1,len);          %Conductance for epsp to post
g_I = g_E;          %Conductance for ipsp to post
w_E=eVal(4)*0.001;%0.005;          %strength of epsp (based on distance from soma 0=far
w_I=iVal(4)*0.001;%0.015;          %strength of ipsp (based on distance from soma 0=far

E_12 =  20;  %AMPA channel (epsp)
E_22 =  -120; %GABA channel (ipsp)

%Izhikevich neuron parameters
a = 0.02;
b = 0.2;
c = -65;
d = 2;
vPost=-65*ones(1,len);
uPost=zeros(1,len);
sPost=uPost;

%EPSP parameters
g_e=0;
C_e=0;
%IPSP parameters
g_i=0;
C_i=0;


% Iterations parameters
dur=10;
e_=0;
i_=0;

for i=2:span*dt_len
  p=(ceil(i*dt));

  %% set epsp and ipsp conductances %%  
  [g_e, C_e] = epsp(e_taur,e_tauf,dt,w_E,e_input(p), g_e, C_e);
  [g_i, C_i] = epsp(i_taur,i_tauf,dt,w_I,i_input(p), g_i, C_i);
  %% store to graph data %%
  g_E(i)=g_e(1);
  g_I(i)=g_i(1);

  cur=g_E(i)*(E_12 - vPost(i-1))+g_I(i)*(E_22 - vPost(i-1));
  [vPost(i), uPost(i), sPost(i) ] = izhikevich2(vPost(i-1),uPost(i-1),a,b,c,d,cur,dt);
  %% set spikes %%
  if (vPost(i)>=20)
    vPost(i)=100;
  end

  %%%%%% for display purposes only %%%%%%%%%%%%%%%
  %% to display points of EPSP spikes
  if(e_input(p) && e_<dur)
    g_E(i)=4;
    e_=e_+1;
  elseif(~e_input(p))
    e_=0;
  end
  %% to display points of IPSP spikes
  if(i_input(p) && i_<dur)
    g_I(i)=4;
    i_=i_+1;
  elseif(~i_input(p))
    i_=0;
  end
end

%%% for plotting %%%%%%%%
tv = [dt:dt:span];   %Time vector
spike_data = vPost(1:len);
epsp_data = g_E(1:len);
ipsp_data = -g_I(1:len);
%h=plot(tv,vPost(3:len)); 
%figure(2)
%plot(tv,cur_12(3:len));%+cur_22(3:len));
%figure(3)
%plot(tv,cur_22(3:len));

Contact us at files@mathworks.com