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.

173 lines
4.4 KiB
Matlab

%direction of motion (ab vs ba)
clear
m=2;
n=4;
W=zeros(n,m+n);
%define feedforward connections
W(1,1)=1;
W(2,2)=1;
W(3,[2,3])=1;
W(4,[1,4])=1;
W(:,1:2)= W(:,1:2).*2;
%define recurrent connections
W=bsxfun(@rdivide,W,(1e-9+sum(W,2)));
V=bsxfun(@rdivide,W,(1e-9+max(W,[],2)));
iterations=20;
ntrials=2;
X{1}=zeros(m,iterations);
X{1}(1,1:10)=1;
X{1}(2,11:20)=1;
X{2}=zeros(m,iterations);
X{2}(2,1:10)=1;
X{2}(1,11:20)=1;
figure(1), clf
for k=1:ntrials
%define input sequence
x=X{k};
[y,e,ytrace]=dim_activation_recurrent(W,x,zeros(n,1),iterations,V);
subplot(1,ntrials,k); plot_network([x(:,iterations);y],W,y,0,1,[],[],1,-1);
plot([-0.35,0.35,0.35,-0.35,-0.35],[-m-0.5,-m-0.5,-0.5,-0.5,-m-0.5],'k-','LineWidth',2)
text(0,-0.5,'x','FontWeight','b','HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',32)
%plot(1+[-0.3,0.3,0.3,-0.3,-0.3],[-3.5,-3.5,-0,-0,-3.5],'k-','LineWidth',2)
text(1,-0.5,'y','FontWeight','b','HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',32)
drawnow;
end
set(gcf,'PaperPosition',[0 0 4*k-1 6.25].*3);
print -depsc2 rec_motion.eps
%aba, abb, baa, bab,
clear
m=2;
n=8;
W=zeros(n,m+n);
%define feedforward connections
W(1,1)=1;
W(2,2)=1;
W(3,[2,3])=1;
W(4,[1,4])=1;
W(5,[1,5])=1;
W(6,[2,5])=1;
W(7,[1,6])=1;
W(8,[2,6])=1;
W(:,1:2)= W(:,1:2).*2;
%define recurrent connections
W=bsxfun(@rdivide,W,(1e-9+sum(W,2)));
V=bsxfun(@rdivide,W,(1e-9+max(W,[],2)));
iterations=30;
ntrials=4;
X{1}=zeros(m,iterations);
X{1}(1,1:10)=1;
X{1}(2,11:20)=1;
X{1}(1,21:30)=1;
X{2}=zeros(m,iterations);
X{2}(1,1:10)=1;
X{2}(2,11:20)=1;
X{2}(2,21:30)=1;
X{3}=zeros(m,iterations);
X{3}(2,1:10)=1;
X{3}(1,11:20)=1;
X{3}(1,21:30)=1;
X{4}=zeros(m,iterations);
X{4}(2,1:10)=1;
X{4}(1,11:20)=1;
X{4}(2,21:30)=1;
figure(2), clf
for k=1:ntrials
%define input sequence
x=X{k};
[y,e,ytrace]=dim_activation_recurrent(W,x,zeros(n,1),iterations,V);
subplot(1,ntrials,k); plot_network([x(:,iterations);y],W,y,0,1,[],[],1,-1);
plot([-0.35,0.35,0.35,-0.35,-0.35],[-m-0.5,-m-0.5,-0.5,-0.5,-m-0.5],'k-','LineWidth',2)
text(0,-0.5,'x','FontWeight','b','HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',32)
%plot(1+[-0.3,0.3,0.3,-0.3,-0.3],[-3.5,-3.5,-0,-0,-3.5],'k-','LineWidth',2)
text(1,-0.5,'y','FontWeight','b','HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',32)
drawnow;
end
set(gcf,'PaperPosition',[0 0 4*k-1 max(size(W))+0.25].*3);
print -depsc2 rec_sequence.eps
%priming
clear
m=2;
n=20;
W=zeros(n,m+n);
W(1,1)=1;
W(2,2)=1;
W(2,3)=1;
for j=3:n
W(j,3)=1;
W(j,j+2)=1;
end
W=bsxfun(@rdivide,W,(1e-9+sum(W,2)));
V=bsxfun(@rdivide,W,(1e-9+max(W,[],2)));
iterations=14;
ntrials=3;
X{1}=zeros(m,iterations);
X{1}(1,1:7)=1;
X{2}=zeros(m,iterations);
X{2}(2,8:14)=1;
X{3}=zeros(m,iterations);
X{3}(1,1:7)=1;
X{3}(2,8:14)=1;
figure(3),clf
for k=1:ntrials
%define input sequence
x=X{k};
[y,e,ytrace]=dim_activation_recurrent(W,x,[],25,V);
x=x(:,iterations);
[y(1),y(2),max(y(3:n))]
subplot(1,ntrials,k); plot_network([x;y(1)],W(1:3,1:3),y(1:3),0,1,[],[],1,0.5);
plot([0,1],[-3,-4.25],'b--','LineWidth',3.5)
plot([0,1],[-3,-5.25],'b--','LineWidth',3.5)
plot([-0.35,0.35,0.35,-0.35,-0.35],[-m-0.5,-m-0.5,-0.5,-0.5,-m-0.5],'k-','LineWidth',2)
text(0,-0.5,'x','FontWeight','b','HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',32)
%plot(1+[-0.3,0.3,0.3,-0.3,-0.3],[-3.5,-3.5,-0,-0,-3.5],'k-','LineWidth',2)
text(1,-0.5,'y','FontWeight','b','HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',32)
axis([-0.5,1.5,-4,-0.5])
for j=1:3
axes('Position',[0.27+(k-1)*0.28,0.6175-(j-1)*0.233,0.1,0.15]),
plot(ytrace(j,:),'r-','LineWidth',2), axis([1,iterations,0,1.05]);
set(gca,'XTick',[iterations/2],'XTickLabel',[],'YTick',[],'TickDir','out','TickLength',[0.06,5]);
if j==2 && k==2
hold on, plot(9,0.7.5,'k*','MarkerSize',14,'LineWidth',2);
ycompare(1,:)=ytrace(j,:);
end
if j==2 && k==3
hold on, plot(9,0.7.5,'kd','MarkerSize',14,'LineWidth',2);
ycompare(2,:)=ytrace(j,:);
end
end
drawnow;
end
set(gcf,'PaperPosition',[0 0 4*k+1 4].*3);
print -depsc2 rec_priming.eps
figure(4),clf
plot(ycompare','LineWidth',4)
axis([1,iterations,0,1.05]);
ylabel('Response')
xlabel('Time (iterations)')
set(gcf,'PaperPosition',[0 0 10 5]);
hold on, plot(9.2,0.25,'k*','MarkerSize',10,'LineWidth',2);
hold on, plot(7,0.25,'kd','MarkerSize',10,'LineWidth',2);
print -depsc2 rec_priming_enlarged.eps