SlideShare a Scribd company logo
1 of 8
Integrate-and-Fire Model
Talal Tahir
Integrate-and-Fire Model
To estimate the parameters inthisproject,we know the statisticsof the systemmustbe
preserved. Thus,we aimtoestimate the parameterssuchthatthe numerical resultsusingthe specified
parameters outputssimilarstatisticstothatof the data set.
PARAMETER ESTIMATES:
El= -65; vTH=-50; vSpike=60; vRst=-60; gl=0.03148;
C=1; D=0.022
(1) Iapp = 0.375
DATA NUMERICAL ERROR (%)
No. of ISI’s 8 3 55.5556
Mean Frequency 0.0824 0.0995 20.7414
Mean time for ISI’s 1.2140e+04 1.0054e+04 17.1784
0 0.5 1 1.5 2 2.5 3 3.5 4
x 10
4
0
0.5
1
1.5
2
2.5
3
Occurences
Length of Each ISI
Iapp = 0.375 ; D = 0.022 ;gl = 0.03148; #ISIs:3
Mean:12139.825
Mean:10054.4
DATA
NUMERICAL
(2) Iapp = 0.450
DATA NUMERICAL ERROR (%)
No. of ISI’s 674 677 0.4444
Mean Frequency 6.7567 6.7870 0.4479
Mean time for ISI’s 148.0006 147.3406 0.4459
Notice howthe error significantlydecreaseswiththe same parametervalueswithanincrease inIapp
fromgraph (1) to (2). This can be explainedbythe factthat, firstly,ingraph(1) the sample size of the
ISI’sismuch smaller. There are only8 ISI’sin(1) as opposedto674 in (2).Thus,(2) providesuswitha
greatersample size of ISI’s,andhence,abettermeasure forthe parametervalues.
Furthermore,the randomfactor,D, playsa more significantrole asIapp isdecreased. Thisiswhat
accounts fora highererrorwitha smallerIapp. There ismore randomnessprevalentinasystemwith
lowerIapp as comparedto a systemwithgreaterIapp. Observe thatas we increase Iapp,we see that our
parametervaluesdoinfact fitthe data quite well asexhibitedbythe table andhistogramin(2).
Finally,we note the ISI’smeanisinverselyproportional toIapp. This isintuitive since ahigherIapp allows
for more spikingwithinthe same interval of time,namely t€[0,10000]. More spikeswithinthe same
interval of time implyahigherfrequency,whichinturnimpliesasmallerISI. Thisintuitionisexemplified
by (1) and (2) where the meanof the ISIsdecreasesalmost100-fold.
0 100 200 300 400 500 600 700 800
0
50
100
150
200
250
300Occurences
Length of Each ISI
Iapp = 0.45 ; D = 0.022 ;gl = 0.03148; #ISIs:677
Mean:148.0006
Mean:147.3406
DATA
NUMERICAL
NUMERICAL MATLAB CODE:
clc
clear all
close all
A=importdata('C:/IF4.txt');
BINS=20;
str1='Iapp = ';
str2='D = ';
str3='gl = ';
%Integrate-and-Fire Neuron Model
...Iapp=1.50 ; D=0.0 - no spking
...Iapp=1.51 ; D=0.0 - spiking
...Iapp=1.50 ; D=0.1 - spiking
...Iapp=0.375; D=0.0110 ; gl=0.02906 -IF1.dat
...Iapp=0.400; D=0.0120 ; gl=0.03000 -IF2.txt
...Iapp=0.425; D=0.0100 ; gl=0.03029 -IF3.txt
...Iapp=0.450; D=0.0220 ; gl=0.03148 -IF4.txt
...Iapp=0.525; D=0.0200 ; gl=0.03035 -IF7.txt
%I: INITIALIZATION:
Iapp=0.45; gl=0.03148;
C=1;
D=0.022 ; ...Noise
El= -65; vTH=-50; vSpike=60; vRst=-60; R=1/gl; tau=C/gl;
SpikeTime=0;
% II: NUMERICAL SCHEME: Runga-Kutta order 2
%Discretize Grid
T = 100000; %#grid pts = T/dt
dt = 0.05; %time-step
t = 0:dt:T; %discretizing Grid
V = zeros(1,length(t)); %initalizing vector
V(1) = -65; %inital condition
i=0; %index for Spike Time
SpikeSwitch=0; %indicates Spiking
for j=1:length(t)-1
%Iapp=1.4+sin(2*pi*dt*j/1000);
kv1 = ((-V(j)+El+Iapp*R)/tau)+(sqrt(dt*2*D)*randn);
av = V(j)+kv1*dt;
kv2 = ((-av+El+Iapp*R)/tau)+(sqrt(dt*2*D)*randn);
V(j+1) = V(j) + ((kv1+kv2)*dt/2)+ (sqrt(dt*2*D)*randn);
%Condtion for spiking
if V(j+1)>=vTH
SpikeSwitch=1;
i=i+1;
SpikeTime(i)=dt*(j-1); %Store spike time
x=[dt*(j-1),dt*(j-1)]; %draw vertical
y=[V(j), vSpike]; ...lines
hold on
plot(x,y,'LineWidth',1)
V(j+1)=vRst;
end
end
%Calculate ISI's ONLY IF Conditon Satisified:
if numel(SpikeTime)>1
for i=1:numel(SpikeTime)-1
ISI(i)=SpikeTime(i+1)-SpikeTime(i);
end
else ISI=0;
end
% III. STATISTICS:
%MEAN of ISI's
sum=0;
for i=1:numel(ISI)
sum=sum+ISI(i);
end
meanISI=sum/numel(ISI);
%VARIANCE
for i=1:numel(ISI)
var(i)=abs(ISI(i)-meanISI);
end
%MEAN of VARIANCE
sum=0;
for i=1:numel(ISI)
sum=sum+var(i);
end
meanVar=sum/numel(var);
%COEFFICENT OF VARIATION
for i=1:numel(ISI)
COV(i)=var(i)/meanISI;
end
%MEAN of COEFFICENT OF VARIATION
sum=0;
for i=1:numel(ISI)
sum=sum+COV(i);
end
meanCOV=sum/numel(COV);
%FREQUENCY
for i=1:numel(ISI)
freq(i)=1/ISI(i);
end
meanFreq=1000/meanISI; %avg Spikes/sec
title([str1 num2str(Iapp) ' ; ' str2 num2str(D) ' ;' str3
num2str(gl) '; #ISIs:' num2str(numel(ISI))])
plot(t,V,'b','linewidth',1); %Numerical Solution
%axis([0 T -80 80])
%set(gca,'fontsize',15)
xlabel('t');
ylabel('V');
%data
figure (4)
plot(A(:, 1), A(:,2));
dataSpike=0;
i=0;
for j=1:numel(A(:,2))
if A(j,2)==vSpike
i=i+1;
dataSpike=dataSpike+1;
dataspikeTime(i)=A(j,1);
end
end
dataSpike;
dataspikeTime;
for i=1:numel(dataspikeTime)-1
dataISI(i)=dataspikeTime(i+1)-dataspikeTime(i);
end
%MEAN of data ISI's
sum=0;
for i=1:numel(dataISI)
sum=sum+dataISI(i);
end
%FREQUENCY for DATA
meandataISI=sum/numel(dataISI);
meandataFreq=1000/meandataISI; %avg Spikes/sec
%Error
ErrorISI=100*(abs(meanISI-meandataISI)/meandataISI);
ErrorFreq=100*(abs(meanFreq-meandataFreq)/meandataFreq);
ErrorSpik=100*(abs(numel(SpikeTime)-dataSpike)/dataSpike);
%DISPLAY RESULTS
disp('======ERROR========= ')
disp('ERROR ISIs (%): ');disp(ErrorISI)
disp('ERROR FREQ (%): ');disp(ErrorFreq)
disp('ERROR # Spikes (%): ');disp(ErrorSpik)
disp('======DATA========== ')
disp('Number of ISIs: ');disp(numel(dataISI))
disp('Mean Frequency: ');disp(meandataFreq)
disp('Mean of ISI: ');disp(meandataISI)
disp('=====Numerical====== ')
if numel(SpikeTime)>1
disp('Number of ISIs:');disp(numel(ISI))
disp('Mean Frequency:');disp(meanFreq)
disp('Mean ISI:');disp(meanISI)
%disp('Mean Variance:');disp(meanVar)
%disp('Mean Coefficent of Variation:');disp(meanCOV)
else if numel(SpikeTime)==1 && SpikeTime(1)>0
disp('1 spike')
SpikeTime
else
disp('no spiking')
end
end
figure (2)
hist(dataISI,BINS)
h = findobj(gca, 'Type','patch');
set(h,'FaceColor','r','EdgeColor','w','facealpha',0.75)
hold on
if numel(ISI)>1
%HISTOGRAM
figure(2)
hold on
hist(ISI,BINS) %ISI histogram
h = findobj(gca,'Type','patch');
set(h,'facealpha' ,0.75);
ylabel('Occurences ')
xlabel('Length of Each ISI')
legend('DATA', 'NUMERICAL')
ExX=[meandataISI,meandataISI]; %Mean
WhY=[0,max(hist(dataISI))];
text(meandataISI,max(hist(dataISI)),['
Mean:',num2str(meandataISI)],'fontsize',12, 'color', 'black')
plot(ExX,WhY,'--red', 'linewidth',2,'MarkerSize',8,
'MarkerEdgeColor','red')
X=[meanISI,meanISI]; %Mean
Y=[0,max(hist(ISI))];
text(meanISI,max(hist(ISI))-.2,['
Mean:',num2str(meanISI)],'fontsize',12, 'color', 'black')
plot(X,Y,'--blue', 'linewidth',2,'MarkerSize',8,
'MarkerEdgeColor','blue')
X=[meanCOV*100, meanCOV*100]; %COV
Y=[0,max(hist(ISI))];
%text(meanCOV*100,numel(SpikeTime)/7.5,['
COV:',num2str(meanCOV*100), '%'],'fontsize',12, 'color', 'g')
%plot(X,Y,'--gs', 'linewidth',2,'MarkerSize',8,
'MarkerEdgeColor','green')
X=[meanVar, meanVar]; %Variance
Y=[0,max(hist(ISI))];
%text(meanVar,numel(SpikeTime)/14,['
Var:',num2str(meanVar)],'fontsize',12, 'color', 'r')
%plot(X,Y,'--rs', 'linewidth',2,'MarkerSize',8,
'MarkerEdgeColor','r')
title([str1 num2str(Iapp) ' ; ' str2 num2str(D) ' ;' str3
num2str(gl) '; #ISIs:' num2str(numel(ISI))])
end

More Related Content

Similar to capstone project II part B

The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
Positive Hack Days
 
Intro matlab-nn
Intro matlab-nnIntro matlab-nn
Intro matlab-nn
soldier78
 

Similar to capstone project II part B (20)

The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
The System of Automatic Searching for Vulnerabilities or how to use Taint Ana...
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
Data Science Workflow
Data Science WorkflowData Science Workflow
Data Science Workflow
 
Reporte vhd10
Reporte vhd10Reporte vhd10
Reporte vhd10
 
Temperature sensor with buzzer and led
Temperature sensor with buzzer and ledTemperature sensor with buzzer and led
Temperature sensor with buzzer and led
 
Intro matlab-nn
Intro matlab-nnIntro matlab-nn
Intro matlab-nn
 
S3L60 PSpice Model (Free SPICE Model)
S3L60  PSpice Model (Free SPICE Model)S3L60  PSpice Model (Free SPICE Model)
S3L60 PSpice Model (Free SPICE Model)
 
S3L60 LTspice Model (Free SPICE Model)
S3L60  LTspice Model (Free SPICE Model)S3L60  LTspice Model (Free SPICE Model)
S3L60 LTspice Model (Free SPICE Model)
 
New SPL Features in PHP 5.3 (TEK-X)
New SPL Features in PHP 5.3 (TEK-X)New SPL Features in PHP 5.3 (TEK-X)
New SPL Features in PHP 5.3 (TEK-X)
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
Device Modeling of Delay using PSpice
Device Modeling of Delay using PSpiceDevice Modeling of Delay using PSpice
Device Modeling of Delay using PSpice
 
BALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptxBALLANDBEAM_GROUP7.pptx
BALLANDBEAM_GROUP7.pptx
 
1SS400 LTspice Model (Free SPICE Model)
1SS400 LTspice Model (Free SPICE Model)1SS400 LTspice Model (Free SPICE Model)
1SS400 LTspice Model (Free SPICE Model)
 
1SS400 PSpice Model (Free SPICE Model)
1SS400 PSpice Model (Free SPICE Model)1SS400 PSpice Model (Free SPICE Model)
1SS400 PSpice Model (Free SPICE Model)
 
Fandamental Statistics and Data Science Stock_price_analysis_OESON_P1.pptx
Fandamental Statistics and Data Science Stock_price_analysis_OESON_P1.pptxFandamental Statistics and Data Science Stock_price_analysis_OESON_P1.pptx
Fandamental Statistics and Data Science Stock_price_analysis_OESON_P1.pptx
 
Free SPICE Model of 1S1887A in SPICE PARK
Free SPICE Model of 1S1887A in SPICE PARKFree SPICE Model of 1S1887A in SPICE PARK
Free SPICE Model of 1S1887A in SPICE PARK
 
Efficient Programs
Efficient ProgramsEfficient Programs
Efficient Programs
 
8051 -5
8051 -58051 -5
8051 -5
 
Reporte vhdl9
Reporte vhdl9Reporte vhdl9
Reporte vhdl9
 
1SS250 LTspice Model (Free SPICE Model)
1SS250 LTspice Model (Free SPICE Model)1SS250 LTspice Model (Free SPICE Model)
1SS250 LTspice Model (Free SPICE Model)
 

capstone project II part B

  • 2. Integrate-and-Fire Model To estimate the parameters inthisproject,we know the statisticsof the systemmustbe preserved. Thus,we aimtoestimate the parameterssuchthatthe numerical resultsusingthe specified parameters outputssimilarstatisticstothatof the data set. PARAMETER ESTIMATES: El= -65; vTH=-50; vSpike=60; vRst=-60; gl=0.03148; C=1; D=0.022 (1) Iapp = 0.375 DATA NUMERICAL ERROR (%) No. of ISI’s 8 3 55.5556 Mean Frequency 0.0824 0.0995 20.7414 Mean time for ISI’s 1.2140e+04 1.0054e+04 17.1784 0 0.5 1 1.5 2 2.5 3 3.5 4 x 10 4 0 0.5 1 1.5 2 2.5 3 Occurences Length of Each ISI Iapp = 0.375 ; D = 0.022 ;gl = 0.03148; #ISIs:3 Mean:12139.825 Mean:10054.4 DATA NUMERICAL
  • 3. (2) Iapp = 0.450 DATA NUMERICAL ERROR (%) No. of ISI’s 674 677 0.4444 Mean Frequency 6.7567 6.7870 0.4479 Mean time for ISI’s 148.0006 147.3406 0.4459 Notice howthe error significantlydecreaseswiththe same parametervalueswithanincrease inIapp fromgraph (1) to (2). This can be explainedbythe factthat, firstly,ingraph(1) the sample size of the ISI’sismuch smaller. There are only8 ISI’sin(1) as opposedto674 in (2).Thus,(2) providesuswitha greatersample size of ISI’s,andhence,abettermeasure forthe parametervalues. Furthermore,the randomfactor,D, playsa more significantrole asIapp isdecreased. Thisiswhat accounts fora highererrorwitha smallerIapp. There ismore randomnessprevalentinasystemwith lowerIapp as comparedto a systemwithgreaterIapp. Observe thatas we increase Iapp,we see that our parametervaluesdoinfact fitthe data quite well asexhibitedbythe table andhistogramin(2). Finally,we note the ISI’smeanisinverselyproportional toIapp. This isintuitive since ahigherIapp allows for more spikingwithinthe same interval of time,namely t€[0,10000]. More spikeswithinthe same interval of time implyahigherfrequency,whichinturnimpliesasmallerISI. Thisintuitionisexemplified by (1) and (2) where the meanof the ISIsdecreasesalmost100-fold. 0 100 200 300 400 500 600 700 800 0 50 100 150 200 250 300Occurences Length of Each ISI Iapp = 0.45 ; D = 0.022 ;gl = 0.03148; #ISIs:677 Mean:148.0006 Mean:147.3406 DATA NUMERICAL
  • 4. NUMERICAL MATLAB CODE: clc clear all close all A=importdata('C:/IF4.txt'); BINS=20; str1='Iapp = '; str2='D = '; str3='gl = '; %Integrate-and-Fire Neuron Model ...Iapp=1.50 ; D=0.0 - no spking ...Iapp=1.51 ; D=0.0 - spiking ...Iapp=1.50 ; D=0.1 - spiking ...Iapp=0.375; D=0.0110 ; gl=0.02906 -IF1.dat ...Iapp=0.400; D=0.0120 ; gl=0.03000 -IF2.txt ...Iapp=0.425; D=0.0100 ; gl=0.03029 -IF3.txt ...Iapp=0.450; D=0.0220 ; gl=0.03148 -IF4.txt ...Iapp=0.525; D=0.0200 ; gl=0.03035 -IF7.txt %I: INITIALIZATION: Iapp=0.45; gl=0.03148; C=1; D=0.022 ; ...Noise El= -65; vTH=-50; vSpike=60; vRst=-60; R=1/gl; tau=C/gl; SpikeTime=0; % II: NUMERICAL SCHEME: Runga-Kutta order 2 %Discretize Grid T = 100000; %#grid pts = T/dt dt = 0.05; %time-step t = 0:dt:T; %discretizing Grid V = zeros(1,length(t)); %initalizing vector V(1) = -65; %inital condition i=0; %index for Spike Time SpikeSwitch=0; %indicates Spiking for j=1:length(t)-1 %Iapp=1.4+sin(2*pi*dt*j/1000); kv1 = ((-V(j)+El+Iapp*R)/tau)+(sqrt(dt*2*D)*randn); av = V(j)+kv1*dt; kv2 = ((-av+El+Iapp*R)/tau)+(sqrt(dt*2*D)*randn); V(j+1) = V(j) + ((kv1+kv2)*dt/2)+ (sqrt(dt*2*D)*randn); %Condtion for spiking if V(j+1)>=vTH SpikeSwitch=1;
  • 5. i=i+1; SpikeTime(i)=dt*(j-1); %Store spike time x=[dt*(j-1),dt*(j-1)]; %draw vertical y=[V(j), vSpike]; ...lines hold on plot(x,y,'LineWidth',1) V(j+1)=vRst; end end %Calculate ISI's ONLY IF Conditon Satisified: if numel(SpikeTime)>1 for i=1:numel(SpikeTime)-1 ISI(i)=SpikeTime(i+1)-SpikeTime(i); end else ISI=0; end % III. STATISTICS: %MEAN of ISI's sum=0; for i=1:numel(ISI) sum=sum+ISI(i); end meanISI=sum/numel(ISI); %VARIANCE for i=1:numel(ISI) var(i)=abs(ISI(i)-meanISI); end %MEAN of VARIANCE sum=0; for i=1:numel(ISI) sum=sum+var(i); end meanVar=sum/numel(var); %COEFFICENT OF VARIATION for i=1:numel(ISI) COV(i)=var(i)/meanISI; end %MEAN of COEFFICENT OF VARIATION sum=0; for i=1:numel(ISI) sum=sum+COV(i);
  • 6. end meanCOV=sum/numel(COV); %FREQUENCY for i=1:numel(ISI) freq(i)=1/ISI(i); end meanFreq=1000/meanISI; %avg Spikes/sec title([str1 num2str(Iapp) ' ; ' str2 num2str(D) ' ;' str3 num2str(gl) '; #ISIs:' num2str(numel(ISI))]) plot(t,V,'b','linewidth',1); %Numerical Solution %axis([0 T -80 80]) %set(gca,'fontsize',15) xlabel('t'); ylabel('V'); %data figure (4) plot(A(:, 1), A(:,2)); dataSpike=0; i=0; for j=1:numel(A(:,2)) if A(j,2)==vSpike i=i+1; dataSpike=dataSpike+1; dataspikeTime(i)=A(j,1); end end dataSpike; dataspikeTime; for i=1:numel(dataspikeTime)-1 dataISI(i)=dataspikeTime(i+1)-dataspikeTime(i); end %MEAN of data ISI's sum=0; for i=1:numel(dataISI) sum=sum+dataISI(i); end
  • 7. %FREQUENCY for DATA meandataISI=sum/numel(dataISI); meandataFreq=1000/meandataISI; %avg Spikes/sec %Error ErrorISI=100*(abs(meanISI-meandataISI)/meandataISI); ErrorFreq=100*(abs(meanFreq-meandataFreq)/meandataFreq); ErrorSpik=100*(abs(numel(SpikeTime)-dataSpike)/dataSpike); %DISPLAY RESULTS disp('======ERROR========= ') disp('ERROR ISIs (%): ');disp(ErrorISI) disp('ERROR FREQ (%): ');disp(ErrorFreq) disp('ERROR # Spikes (%): ');disp(ErrorSpik) disp('======DATA========== ') disp('Number of ISIs: ');disp(numel(dataISI)) disp('Mean Frequency: ');disp(meandataFreq) disp('Mean of ISI: ');disp(meandataISI) disp('=====Numerical====== ') if numel(SpikeTime)>1 disp('Number of ISIs:');disp(numel(ISI)) disp('Mean Frequency:');disp(meanFreq) disp('Mean ISI:');disp(meanISI) %disp('Mean Variance:');disp(meanVar) %disp('Mean Coefficent of Variation:');disp(meanCOV) else if numel(SpikeTime)==1 && SpikeTime(1)>0 disp('1 spike') SpikeTime else disp('no spiking') end end figure (2) hist(dataISI,BINS) h = findobj(gca, 'Type','patch'); set(h,'FaceColor','r','EdgeColor','w','facealpha',0.75) hold on if numel(ISI)>1
  • 8. %HISTOGRAM figure(2) hold on hist(ISI,BINS) %ISI histogram h = findobj(gca,'Type','patch'); set(h,'facealpha' ,0.75); ylabel('Occurences ') xlabel('Length of Each ISI') legend('DATA', 'NUMERICAL') ExX=[meandataISI,meandataISI]; %Mean WhY=[0,max(hist(dataISI))]; text(meandataISI,max(hist(dataISI)),[' Mean:',num2str(meandataISI)],'fontsize',12, 'color', 'black') plot(ExX,WhY,'--red', 'linewidth',2,'MarkerSize',8, 'MarkerEdgeColor','red') X=[meanISI,meanISI]; %Mean Y=[0,max(hist(ISI))]; text(meanISI,max(hist(ISI))-.2,[' Mean:',num2str(meanISI)],'fontsize',12, 'color', 'black') plot(X,Y,'--blue', 'linewidth',2,'MarkerSize',8, 'MarkerEdgeColor','blue') X=[meanCOV*100, meanCOV*100]; %COV Y=[0,max(hist(ISI))]; %text(meanCOV*100,numel(SpikeTime)/7.5,[' COV:',num2str(meanCOV*100), '%'],'fontsize',12, 'color', 'g') %plot(X,Y,'--gs', 'linewidth',2,'MarkerSize',8, 'MarkerEdgeColor','green') X=[meanVar, meanVar]; %Variance Y=[0,max(hist(ISI))]; %text(meanVar,numel(SpikeTime)/14,[' Var:',num2str(meanVar)],'fontsize',12, 'color', 'r') %plot(X,Y,'--rs', 'linewidth',2,'MarkerSize',8, 'MarkerEdgeColor','r') title([str1 num2str(Iapp) ' ; ' str2 num2str(D) ' ;' str3 num2str(gl) '; #ISIs:' num2str(numel(ISI))]) end