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.
156 lines
4.8 KiB
Matlab
156 lines
4.8 KiB
Matlab
function [resp1,orientTuning]=v1_spatio_temporal_prediction(figoffset)
|
|
if nargin<1 || isempty(figoffset), figoffset=0; end
|
|
|
|
%DEFINE IMAGE SEQUENCES
|
|
|
|
crop=19;
|
|
orient=0;
|
|
speed=20;
|
|
nPositions=5;
|
|
plotTime=nPositions*speed-(speed-1)
|
|
|
|
backgnd=0.5;
|
|
contrast=0.6;
|
|
barlen=15;
|
|
bar=define_bar(barlen,1);
|
|
blank=zeros(2*crop+1,2*crop+nPositions*barlen)+backgnd;
|
|
rowcoord=crop+1;
|
|
|
|
nodePosn=fix([rowcoord,crop+odd(barlen/2)+(nPositions-1)*barlen])
|
|
plotNode1=9;
|
|
plotNode2=13;
|
|
nConditions=4;
|
|
t=0;
|
|
for barPosn=1:nPositions
|
|
for t2=1:speed
|
|
t=t+1;
|
|
colcoord=crop+odd(barlen/2)+(barPosn-1)*barlen;
|
|
%congruent condition
|
|
%movie of bar translating across image
|
|
I{1}(:,:,t)=draw_bar(blank,rowcoord,colcoord,bar,orient,contrast,backgnd);
|
|
|
|
%incongruent condition
|
|
%movie of bar translating across image, but orientation of bar changes when it reaches RF of recorded neuron
|
|
I{2}(:,:,t)=I{1}(:,:,t);
|
|
if barPosn>=nPositions, I{2}(:,:,t)=draw_bar(blank,rowcoord,colcoord,bar,orient+90,contrast,backgnd); end
|
|
|
|
%missing RF condition
|
|
%movie in which bar disappears when it reaches RF of recorded neuron
|
|
I{3}(:,:,t)=I{1}(:,:,t);
|
|
if barPosn>=nPositions, I{3}(:,:,t)=blank; end
|
|
|
|
%RF only condition
|
|
%movie in which bar first appears when it reaches RF of recorded neuron
|
|
I{4}(:,:,t)=I{1}(:,:,t);
|
|
if barPosn<nPositions, I{4}(:,:,t)=blank; end
|
|
|
|
%last predictor only condition
|
|
%movie in which bar only appears at the position adjacent to the RF of recorded neuron,
|
|
%I{5}(:,:,t)=I{1}(:,:,t);
|
|
%if barPosn<nPositions-1 || barPosn>=nPositions, I{5}(:,:,t)=blank; end
|
|
end
|
|
end
|
|
%add some time after the stimulus disappears
|
|
for t2=1:2*speed
|
|
t=t+1;
|
|
for trial=1:nConditions
|
|
I{trial}(:,:,t)=blank;
|
|
end
|
|
end
|
|
iterations=t;
|
|
|
|
%DEFINE V1 PREDICTION NEURON RECEPTIVE FIELDS
|
|
|
|
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
|
|
|
|
downsample=1;
|
|
%PERFORM EXPERIMENT
|
|
figure(figoffset+1), clf
|
|
for trial=1:nConditions
|
|
[X]=preprocess_V1_input(I{trial});
|
|
[Y,E,R,Ytrace]=dim_activation_conv_recurrent(w,X,[],iterations,v,downsample);
|
|
%figure(figoffset+trial),clf,plot_responses(I{trial},Ytrace,plotNode1,crop)
|
|
resp1(trial,1:iterations)=Ytrace{plotNode1}(nodePosn(1),nodePosn(2),:);
|
|
resp2(trial,1:iterations)=Ytrace{plotNode2}(nodePosn(1),nodePosn(2),:);
|
|
k=0;
|
|
for n=plotNode1:plotNode1+7
|
|
k=k+1;
|
|
orientTuning(trial,k)=mean(Ytrace{n}(nodePosn(1),nodePosn(2),plotTime-speed:plotTime+speed-1));
|
|
end
|
|
|
|
%plot response at the end of each stage in the bars movement
|
|
plotTimes=speed:speed:iterations
|
|
k=0;
|
|
for t=plotTimes
|
|
k=k+1;
|
|
maxsubplot(nConditions,length(plotTimes),k+length(plotTimes)*(trial-1))
|
|
plot_cropped_image(Ytrace{plotNode1}(:,:,t)+Ytrace{plotNode2}(:,:,t),10,[0,0.2]);
|
|
end
|
|
end
|
|
|
|
%PLOT RESULTS
|
|
|
|
%plot response over time of node tuned to orientation of RF stimulus
|
|
figure(figoffset+2),clf
|
|
resp1(2,:)=resp2(2,:);
|
|
plot(resp1(1,:)','r-','LineWidth',6),hold on
|
|
plot(resp1(2,:)','-','Color',[0,0.7,0],'LineWidth',3),
|
|
plot(resp1(4,:)','b--','LineWidth',3),
|
|
plot(resp1(3,:)','r-.','LineWidth',3),
|
|
set(gca,'FontSize',16);
|
|
ylabel('Response'),xlabel('Time')
|
|
ax=axis;
|
|
axis([plotTime-1*speed,plotTime+1.5*speed,0,ax(4)])
|
|
%set(gca,'XTick',[plotTime-1*speed:0.5*speed:plotTime+2*speed],'XTickLabel',[-1:0.5:2]);
|
|
set(gca,'YTick',[],'XTick',[]);
|
|
set(gcf,'PaperPosition',[0,0,12,10])
|
|
h=legend(['congruent ';'incongruent .';'RF only ';'missing '],'Location','NorthWest');%;'random '])
|
|
h1 = findobj(get(h,'Children'),'String','incongruent .');set(h1,'String','incongruent ')
|
|
|
|
%plot orientation tuning for each condition
|
|
figure(figoffset+3),clf
|
|
%plot(orientTuning([1,3,4],:)','LineWidth',4)
|
|
plot(orientTuning(1,[5:8,1:5])','r-','LineWidth',6),hold on
|
|
plot(orientTuning(4,[5:8,1:5])','b--','LineWidth',3)
|
|
plot(orientTuning(3,[5:8,1:5])','r-.','LineWidth',3)
|
|
set(gca,'FontSize',16);
|
|
ylabel('Response'),xlabel('Orientation (degrees)')
|
|
set(gca,'XTick',[1:2:9],'XTickLabel',[-90:45:90]);
|
|
set(gcf,'PaperPosition',[0,0,12,10])
|
|
h=legend(['congruent ';'RF only ';'missing '])
|
|
h1 = findobj(get(h,'Children'),'String','congruent ');set(h1,'String','congruent ')
|
|
|
|
|
|
|
|
|
|
function plot_responses(I,Ytrace,plotNode,crop)
|
|
top=0;
|
|
maxTime=size(Ytrace{1},3);
|
|
nMasks=length(Ytrace);
|
|
|
|
for n=1:nMasks
|
|
resp=max(Ytrace{n},[],3);
|
|
top=max(top,max(max(resp)));
|
|
end
|
|
top=top*0.85
|
|
|
|
crop=0;
|
|
for t=1:maxTime
|
|
maxsubplot(maxTime,2,t*2-1),
|
|
plot_cropped_image(I(:,:,t),crop,[0,1]);
|
|
maxsubplot(maxTime,2,t*2),
|
|
plot_cropped_image(Ytrace{plotNode}(:,:,t),crop,[0,top]);
|
|
end
|