You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
4.2 KiB
Matlab
127 lines
4.2 KiB
Matlab
function [perceptabilityEdge,perceptabilityText]=v1_contour
|
|
crop=0;
|
|
iterations=30;
|
|
addpath('../Data/DakinContourStimulusCode/');
|
|
|
|
%DEFINE SYNAPTIC WEIGHTS
|
|
%phases=[0,180]; %even on and off
|
|
phases=[90,270];; %odd only
|
|
%phases=[0,180,90,270]; %even and odd
|
|
texture=1;
|
|
lateral=1;
|
|
[w,v,v1Masks,lgnMasks]=filter_definitions_V1_simple_diffGauss([],[],1, [0,0],phases);
|
|
if texture
|
|
[w,v,v1Masks]=filter_definitions_V1_simple_diffGauss(w,v,1, [v1Masks,0],phases);
|
|
phases=[phases;phases];
|
|
end
|
|
if lateral
|
|
[w,v]=filter_definitions_V1_recurrent(w,v,0.5, [0,lgnMasks],phases);
|
|
end
|
|
|
|
%DEFINE TEST IMAGES
|
|
% pathlength angle: smooth, non-smooth, non-smooth perpendicular
|
|
contourLengths=[2,3,4,6,8,10, 8, 8,8,8, 8,8,8,8,8, 8,8,8,8,8,8];
|
|
pathRotation= [0,0,0,0,0,0, 45, 0,0,0, 0,0,0,0,0, 90,90,90,90,90,90];
|
|
pathAngles= [0,0,0,0,0,0, 0, 15,30,40, 15,30,45,60,75, 0,15,30,45,60,75];
|
|
smoothPath= [1,1,1,1,1,1, 1, 1,1,1, 0,0,0,0,0, 0,0,0,0,0,0];
|
|
nExpts=length(contourLengths);
|
|
nTrials=25;
|
|
perceptabilityEdge=-ones(nTrials,nExpts);
|
|
perceptabilityText=-ones(nTrials,nExpts);
|
|
|
|
%nTrials=1;nExpts=1;contourLengths=8;pathAngles=0;smoothPath=0;pathRotation=0;
|
|
|
|
for expt=1:nExpts
|
|
figure(expt),clf
|
|
|
|
for trial=1:nTrials
|
|
%CREATE IMAGE
|
|
[I,coordsPath,coordsDist]=image_gabor_path(contourLengths(expt),pathAngles(expt),smoothPath(expt),pathRotation(expt),0);
|
|
|
|
%PERFORM EXPERIMENT AND PLOT RESULTS
|
|
[a,b,z]=size(I);
|
|
maxsubplot(2,2,3), plot_cropped_image(I,crop); title('I'), ylabel('I')
|
|
%maxsubplot(1,2,1),plot_cropped_image(I)
|
|
|
|
%LGN preprocessing of image
|
|
X=preprocess_V1_input(I);
|
|
|
|
%Simulate the PCBC model
|
|
[y,e]=dim_activation_conv_recurrent(w,X,[],iterations,v);
|
|
|
|
%plot response of prediction nodes (taking max across ALL filter types)
|
|
yedge=max(cat(3,y{1:length(y)/2}),[],3);
|
|
maxsubplot(2,2,1), plot_cropped_image(yedge,crop), title('Yedge'), ylabel('Yedge');
|
|
%maxsubplot(1,2,2),plot_cropped_image(yedge);
|
|
perceptabilityEdge(trial,expt)=relative_response_contour(yedge,coordsPath,coordsDist)
|
|
|
|
ytext=max(cat(3,y{1+length(y)/2:length(y)}),[],3);
|
|
maxsubplot(2,2,2), plot_cropped_image(ytext,crop), title('Ytext'), ylabel('Ytext');
|
|
perceptabilityText(trial,expt)=relative_response_contour(ytext,coordsPath,coordsDist)
|
|
|
|
|
|
%plot response of error nodes (taking max across INPUT channels)
|
|
etmp=max(cat(3,e{1:2}),[],3);
|
|
maxsubplot(2,2,4), plot_cropped_image(etmp,crop), title('E'), ylabel('E');
|
|
drawnow;
|
|
end
|
|
stim{expt}=I;
|
|
resp{expt}=y;
|
|
end
|
|
perc=max(perceptabilityEdge,perceptabilityText);
|
|
perc=mean(perc,1);
|
|
|
|
figure(nExpts+1),clf
|
|
for k=1:nExpts,
|
|
maxsubplot(2,nExpts,k),
|
|
ymax=max(cat(3,resp{k}{1:length(y)/2}),[],3);
|
|
plot_cropped_image(ymax,crop);
|
|
xlabel(num2str(perc(k)),'FontSize',20);
|
|
maxsubplot(2,nExpts,k+nExpts),
|
|
plot_cropped_image(stim{k},crop);
|
|
end
|
|
|
|
figure(nExpts+2),clf
|
|
subplot(1,2,1),
|
|
plot(contourLengths(1:6),perc(1:6),'b-','LineWidth',3)
|
|
axis([0,10,0,1]);
|
|
set(gca,'FontSize',8);
|
|
xlabel('Length');ylabel('Perceptability');
|
|
|
|
subplot(1,2,2),
|
|
plot(pathAngles([5,8:10]),perc([5,8:10]),'b--','LineWidth',3)
|
|
axis([0,80,0,1]);
|
|
set(gca,'FontSize',8);
|
|
hold on
|
|
plot(pathAngles([5,11:15]),perc([5,11:15]),'-','Color',[0,0.7,0],'LineWidth',3)
|
|
plot(pathAngles(16:21),perc(16:21),'r-.','LineWidth',3)
|
|
plot(pathAngles(7),perc(7),'mx','LineWidth',3,'MarkerSize',8)
|
|
xlabel('Angle');ylabel('Perceptability');
|
|
set(gcf,'PaperPosition',[0,0,11,5])
|
|
print -depsc2 contour_integration_results.eps
|
|
|
|
|
|
|
|
|
|
function rr=relative_response_contour(y,coordsPath,coordsDist)
|
|
%[mmresp,aa]=max(mresp); bb=bb(aa);
|
|
%rr=mean_response(y,coordsPath)/mean_response(y,coordsDist);
|
|
rr=(mean_response(y,coordsPath)-mean_response(y,coordsDist))/(mean_response(y,coordsPath)+mean_response(y,coordsDist));
|
|
|
|
|
|
|
|
function sumY=mean_response(y,coords)
|
|
[a,b]=size(y);
|
|
nCoords=size(coords,2);
|
|
|
|
%if nCoords<10, style='bo'; else, style='rx'; end
|
|
%hold on
|
|
|
|
sumY=0;
|
|
for c=1:nCoords
|
|
%plot(coords(1,c),coords(2,c),style);
|
|
sumY=sumY+sum(sum(y(coords(2,c)-2:coords(2,c)+2,coords(1,c)-2:coords(1,c)+2)));
|
|
%if nCoords<10, maxsubplot(20,3,2+(c-1)*3), plot_cropped_image(y(coords(2,c)-15:coords(2,c)+15,coords(1,c)-15:coords(1,c)+15)); end
|
|
end
|
|
sumY=sumY./nCoords;
|