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.

85 lines
3.4 KiB
Matlab

function [eyeamp,eyeposn,vistarget,y,r]=control_eye_multitarget(vistarget,eyepaninit,W,V,interconnects,y,display,numSaccades)
%Performs eye movements to foveate a visual target.
%This is achieved in 3 steps:
% 1) calculates H given R+E (the sensory-sensory transformation)
% 2) calculates E given H calculated in (1) and R centred at zero (the sensory-motor transformation)
% 3) estimates R given H calculated in (1) and E calculated in (2)
% (the "RF remapping step - this does not contribute to the performace of the movement)
%These steps may be repeated to perform corrective saccades
nSteps=3;
if nargin<1
vistarget=[-30,40];
end
if nargin<2 || isempty(eyepaninit)
eyepaninit=0;
end
if nargin<3 || isempty(W)
%define network for performing sensory-sensory and sensory-motor mappings
[W,V,interconnects]=define_network(1);
end
if nargin<6
y=[];
end
if nargin<7 || isempty(display)
display=1;
end
figoff=0;
if nargin<8 || isempty(numSaccades)
numSaccades=2;
end
%define inputs to perform task
[angles,ranges,partitions,values,stdx,stdw,partitionLabels]=simulate_agent();
nullR=zeros(1,length(values{1,1}));
nullE=zeros(1,length(values{1,2}));
nullH=zeros(1,length(values{1,3}));
eyeposn(1)=decode(code(eyepaninit,values{1,2},stdx),values{1,2}); %eyepaninit;
for i=1:length(vistarget)
trueworldtarget(i)=simulate_agent_retina_to_world(vistarget(i),eyepaninit,0,0);
end
%present test cases to network and record results
for saccade=1:numSaccades
%step 1) calculate the head-centred representation of the visual target
%input eye position and retinal input (R+E->H)
x{1}=[code(vistarget(1),values{1,1},stdx)+0.5*code(vistarget(2),values{1,1},stdx),code(eyeposn(saccade),values{1,2},stdx),nullH]';
[y,e,r]=dim_activation_hierarchical(W,x,V,interconnects,y);
if display,
figured(figoff+(saccade-1)*nSteps+1),clf,plot_network(x,r,y,partitions,values,partitionLabels);
if saccade==1, print -dpdf control_eye_multitarget1.pdf; end
end
headtarget=-30 %decode(r{1}(partitions{1,3})',values{1,3});
headrep=r{1}(partitions{1,3})';
%step 2) calculate the eye position required to foveate the target
%input the head-centred position and foveal retinal input (R+H->E)
x{1}=[code(0,values{1,1},stdx),nullE,code(headtarget,values{1,3},stdx)]';
[y,e,r]=dim_activation_hierarchical(W,x,V,interconnects,[]);%<-reset network activity
if display,
figured(figoff+(saccade-1)*nSteps+2),clf,plot_network(x,r,y,partitions,values,partitionLabels);
if saccade==1, print -dpdf control_eye_multitarget2.pdf; end
end
eyetarget=decode(r{1}(partitions{1,2})',values{1,2});
%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(eyetarget,values{1,2},stdx),headrep]';
[y,e,r]=dim_activation_hierarchical(W,x,V,interconnects,y);
if display,
figured(figoff+(saccade-1)*nSteps+3),clf,plot_network(x,r,y,partitions,values,partitionLabels);
if saccade==1, print -dpdf control_eye_multitarget3.pdf; end
end
%perform movement (update visual input after saccade)
for i=1:length(vistarget)
vistarget(i)=simulate_agent_world_to_retina(trueworldtarget(i),eyetarget,0,0);
end
%record movements made over time
eyeposn(saccade+1)=eyetarget;
end
[eyeamp,ind]=max(abs(eyeposn-eyeposn(1))); %see McCluskey Cullen p.2979 (Freedman Sparks use eye amp, don't seem to define it!)