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.

67 lines
2.3 KiB
Matlab

function [yTrace,rTrace]=control_eye_sequence(vistargetseq,eyepanseq,W,V,interconnects,y,r,flashlen,flashamp)
%Performs a given sequence of eye movements while presenting a sequence of stimuli to the eyes.
nSteps=2;
if nargin<1
vistargetseq=[NaN,0,-30];
end
if nargin<2 || isempty(eyepanseq)
eyepanseq=[0,0,30];
end
if nargin<3 || isempty(W)
%define network for performing sensory-sensory and sensory-motor mappings
[W,V,interconnects]=define_network(1);
end
numSaccades=length(eyepanseq);
display=0;
figoff=0;
%define inputs to perform task
[angles,ranges,partitions,values,stdx]=simulate_agent();
nullR=zeros(1,length(values{1,1}));
nullE=zeros(1,length(values{1,2}));
nullH=zeros(1,length(values{1,3}));
if nargin<6
y=[];
end
if nargin<7 || isempty(r)
headrep=nullH;
else
headrep=r{1}(partitions{1,3})';
end
yTrace=[];
rTrace=[];
%present test cases to network and record results
for saccade=1:numSaccades
%step 3) remapping, calculate the visual input expected after upcoming saccade
%input head-centred representation and planned eye position (E+H->R)
x{1}=[nullR,code(eyepanseq(saccade),values{1,2},stdx),headrep]';
[y,e,r,ytrace,rtrace]=dim_activation_hierarchical(W,x,V,interconnects,y);
yTrace=[yTrace,ytrace{1}];
rTrace=[rTrace,rtrace{1}];
if display, figured(figoff+(saccade-1)*nSteps+1),clf,plot_network(x,r,y,partitions,values); end
%step 1) post-saccade, calculate the head-centred representation of the new visual input(s)
%input eye position and retinal input (R+E->H):
if nargin<8 || isnan(flashlen)
%visual stimulus on for all iterations
x{1}=[code(vistargetseq(saccade),values{1,1},stdx),code(eyepanseq(saccade),values{1,2},stdx),nullH]';
else
%stimulus only present for first few iterations
for t=1:flashlen
x{1}(:,t)=[flashamp.*code(vistargetseq(saccade),values{1,1},stdx),code(eyepanseq(saccade),values{1,2},stdx),nullH]';
end
x{1}(:,t+1)=[nullR,code(eyepanseq(saccade),values{1,2},stdx),nullH]'; %no visual input
end
[y,e,r,ytrace,rtrace]=dim_activation_hierarchical(W,x,V,interconnects,y);
yTrace=[yTrace,ytrace{1}];
rTrace=[rTrace,rtrace{1}];
if display, figured(figoff+(saccade-1)*nSteps+2),clf,plot_network(x,r,y,partitions,values); end
headtarget=decode(r{1}(partitions{1,3})',values{1,3});
headrep=r{1}(partitions{1,3})';
end