-
Notifications
You must be signed in to change notification settings - Fork 2
/
dog.m
154 lines (124 loc) · 3.74 KB
/
dog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
function dog(action)
global dogdata
if nargin<1,
action='Initialize';
end
%%%%%%%%%%%%%%See what dog needs to do%%%%%%%%%%%%%
switch(action)
case 'Initialize'
dogfig
version = 'Difference of Gaussian Modeller V1.3';
set(gh('dgUITitle'),'String', version);
dog('Plot')
%rotate3d
case 'Plot'
a1=str2num(get(gh('dgcampedit'),'String'));
a2=str2num(get(gh('dgsampedit'),'String'));
sd1=str2num(get(gh('dgcsizeedit'),'String'));
sd2=str2num(get(gh('dgssizeedit'),'String'));
dclevel=str2num(get(gh('dgdcedit'),'String'));
shiftp=str2num(get(gh('dgshiftedit'),'String'));
xD=str2num(get(gh('dgxspaceedit'),'String'));
yD=str2num(get(gh('dgyspaceedit'),'String'));
offset = str2num(get(gh('dgoffset'),'String'));
res = str2num(get(gh('dgResolution'),'String'));
stepx=xD/res;
stepy=yD/res;
mu=1;
x=-xD:stepx:xD;
y=-yD:stepy:yD;
xTmp=-xD:stepx:xD;
x=x-offset;
% f=(a1*exp(-x.^2/sd1^2))-(a2*exp(-x.^2/sd2^2)); %dog equation
c=(a1*exp(-(x.*2/sd1).^2));
s=(a2*exp(-(x.*2/sd2).^2));
[yy,ff,xx]=dogsummate([a1 sd1 a2 sd2 dclevel 0],xTmp);
f=dclevel+(c-s);
s=-s;
if get(gh('dgRectifyBox'),'Value')==1
f(f<0)=0;
end
axes(gh('dg2daxis'));
plot(xTmp,c,'r--',xTmp,s,'g--',xTmp,f,'k-')
hold on
plot(xx,ff,'b:')
hold off
set(gca,'XMinorTick','on');
legend('Centre','Surround','DOG','Summate function')
title('1D Difference of Gaussians')
axis tight
set(gca,'FontSize',10)
xlabel('Visual Space (deg)')
ylabel('Visual sensitivity')
set(gca,'Tag','dg2daxis')
for a=1:length(x);
% This is Allito and Usrey's equation...
% for b=1:length(y);
% f(a,b)=(a1*exp(-(x(a)^2)/(2*sd1^2))*exp(-(y(b)^2)/(2*sd1^2)))-(a2*exp(-(x(a)^2)/(2*sd2^2))*exp(-(y(b)^2)/(2*sd2^2)));
% end
f(a,:)=dclevel+((a1*exp(-((x(a)^2)+(y.^2))/sd1^2))-(a2*exp(-((x(a)^2)+(y.^2))/sd2^2))); %halfmatrixhalfloop
%f(a,:)=(a1*exp(-((x(a)+y)/sd1).^2))-(a2*exp(-((x(a)+y)/sd2).^2)); %halfmatrixhalfloop
end
if get(gh('RectifyBox'),'Value')==1
f(f<0)=0;
end
axes(gh('dg3daxis'))
[xx,yy]=meshgrid(xTmp,y);
pcolor(xx,yy,f');
set(gca,'XMinorTick','on');
shading interp
lighting phong
camlight left
axis tight
axis square
axis vis3d
title('2D Difference of Gaussians')
set(gca,'FontSize',10)
xlabel('X Space (deg)')
ylabel('Y Space (deg)')
set(gca,'Tag','dg3daxis')
case 'Summate'
a1=str2num(get(gh('dgcampedit'),'String'));
a2=str2num(get(gh('dgsampedit'),'String'));
sd1=str2num(get(gh('dgcsizeedit'),'String'));
sd2=str2num(get(gh('dgssizeedit'),'String'));
dclevel=str2num(get(gh('dgdcedit'),'String'));
shiftp=str2num(get(gh('dgshiftedit'),'String'));
offset = str2num(get(gh('dgoffset'),'String'));
x(1)=a1;
x(2)=sd1;
x(3)=a2;
x(4)=sd2;
x(5)=dclevel;
x(6)=shiftp;
x(7)=offset;
SI=(a2*sd2)/(a1*sd1);
s=0:0.1:9;
if get(gh('dgcampedit'),'Value') == 1
ROG = 1;
else
ROG = 0;
end
if get(gh('dgRectifyBox'),'Value') == 1
rectify = 1;
else
rectify = 0;
end
sc=dogsummate(x,s,[],ROG,rectify);
% for i=1:length(s)
% x=-s(i)/2:0.1:s(i)/2;
% f=(a1*exp(-((2*x)/sd1).^2))-(a2*exp(-((2*x)/sd2).^2));
% sc(i)=trapz(x,f);
% %f=(a1*exp(-x.^2/sd1^2))-(a2*exp(-x.^2/sd2^2));
% %sc(i)=trapz(x,f);
% end
mn = sc(1);
mx = max(sc);
plateau = sc(end);
psup = (1-((plateau-mn)/(mx-mn)))*100;
figure
plot(s,sc,'k-o')
title([['Summation Curve | SI = ' num2str(SI)] ' | % Sup = ' num2str(psup)])
xlabel('Stimulus Size (degrees)')
ylabel('Model Response')
end