% This file is licensed under the Allen Institute Terms of Use, which can be found at:
%http://www.alleninstitute.org/Media/policies/terms_of_use_content.html

%------------------------------------------------------------------------------------

%Script to generate data for Fig.1g (LIF with conductance-based synapses)
%-----------------------------------------------------------------------------

clear variables;

%Initializing parameters
lk=1/(20*10^-3);% (s^-1) leak constant 1/RC
dt0=0.1*10^-3;% (s) time step
tf=200*10^-3; % (s) final time
dv0=0.5*10^-3;% (V) defines max step in potential
th=22*10^-3;% (V) Threshold
v_low = 0*10^-3;% (V) Resting potential
v0=(v_low:dv0:th);% (V) defines the grid for the membrane potential 
tvec=0:dt0:tf;% (s) defines grid for time

%Initial probability density

%delta function probability starting at 0 mV
p0=zeros(size(v0));
p0(v0==0)=1;

synwts='One';%distribution of synaptic weights

flag_poisson=1; %use Poisson input train 
fr = 100;       %Input frequency

fnt = 36;
xtc = [0;50;100;150;200]*10^-3;  %x-axis ticks for time in (ms)
xtl = [0;50;100;150;200]; %x-axis labels for time in (ms)
ytc = [0;1;2;3]; 
ytl = ytc;

set(0,'DefaultFigureWindowStyle','docked');
set(0,'defaultAxesFontName', 'Arial');

load 'SuppFigS3.mat';

figure;

%%%%FIRING RATE PLOTS

plot(tplot, simfrate_cond(1:end-1),'b','LineWidth',4);
set(gca,'XTick',xtc);
set(gca,'XTickLabel',xtl);
set(gca,'YTick',ytc);
set(gca,'YTickLabel',ytl);
hold on;
plot(t_cond_dipde,fout_cond_dipde, '--r', 'LineWidth',4);
legend('Sim','DiPDE','Location','SouthEast');
set(gca, 'FontSize',fnt);
set(gca,'FontSize',fnt);
ylabel('Firing rate (Hz)');xlabel('time (ms)');
axis square tight;

print2eps Fig1g_Cond.eps
