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.
GazeSimulation/control_head_eye_fixed_body.m

112 lines
5.5 KiB
Matlab

function [eyeamp,headcontrib,headamp,eyeposn,neckposn,y,r]=control_head_eye_fixed_body(vistarget,eyepaninit,neckpaninit,W,V,interconnects,y,display)
%Performs coordinated head and eye movements to foveate a visual target. T is fixed at zero.
%This is achieved in 5 steps:
% 1) calculates W given R+E+N+T.
% 2) calculates E given W calculated in (1) and R centred at zero.
% 3) calculates N given W calculated in (1) E calculated in (2) fixed T and R centred at zero.
% 4) calculates T given W calculated in (1) E calculated in (2) N calculated in (3) and R centred at zero (ignored - as T fixed).
% 5) estimates R given W calculated in (1) E calculated in (2) N calculated in (3) and fixed T
% (the "RF remapping step - this does not contribute to the performace of the movement)
%These steps may be repeated to perform corrective saccades
nSteps=4;
numSaccades=2;
figoff=0;
inertiaNeck=0.05;
if nargin<1 || isempty(vistarget)
vistarget=60;
end
if nargin<2 || isempty(eyepaninit)
eyepaninit=-20;
end
if nargin<3 || isempty(neckpaninit)
neckpaninit=-10;
end
if nargin<4 || isempty(W)
%define network for performing sensory-sensory and sensory-motor mappings
[W,V,interconnects]=define_network(3);
end
if nargin<7
y=[];
end
if nargin<8 || isempty(display)
display=1;
end
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}));
nullN=zeros(1,length(values{2,2}));
nullB=zeros(1,length(values{2,3}));
nullT=zeros(1,length(values{3,2}));
nullW=zeros(1,length(values{3,3}));
eyeposn(1)=decode(code(eyepaninit,values{1,2},stdx),values{1,2}); %eyepaninit;
neckposn(1)=decode(code(neckpaninit,values{2,2},stdx),values{2,2}); %neckpaninit;
torsofixedposn=0;
trueworldtarget=simulate_agent_retina_to_world(vistarget,eyepaninit,neckpaninit,torsofixedposn);
%present test cases to network and record results
for saccade=1:numSaccades
%step 1) calculate the world-centred representation of the visual target
%input eye position, neck position, torso position, and retinal input (R+E+N+T->W)
x{1}=[code(vistarget,values{1,1},stdx),code(eyeposn(saccade),values{1,2},stdx),nullH]';
x{2}=[nullH,code(neckposn(saccade),values{2,2},stdx),nullB]';
x{3}=[nullB,code(torsofixedposn,values{3,2},stdx),nullW]';
[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); end
worldtarget=decode(r{3}(partitions{3,3})',values{3,3});
worldrep=r{3}(partitions{3,3})';
%step 2) calculate the eye position required to foveate the target
%input the world-centred position (weakened current neck position) fixed torso
%position and foveal retinal input (R+W+(N)+T->E)
x{1}=[code(0,values{1,1},stdx),nullE,nullH]';
x{2}=[nullH,code(neckposn(saccade),values{2,2},stdx).*inertiaNeck,nullB]';
x{3}=[nullB,code(torsofixedposn,values{3,2},stdx),code(worldtarget,values{3,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); end
eyetarget=decode(r{1}(partitions{1,2})',values{1,2});
%step 3) calculate the neck position required to foveate the target
%input world-centred position, new eye position, fixed torso position, and
%foveal retinal input (R+W+E+T->N)
x{1}=[code(0,values{1,1},stdx),code(eyetarget,values{1,2},stdx),nullH]';
x{2}=[nullH,nullN,nullB]';
x{3}=[nullB,code(torsofixedposn,values{3,2},stdx),code(worldtarget,values{3,3},stdx)]';
[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); end
necktarget=decode(r{2}(partitions{2,2})',values{2,2});
%step 4) calculate the torso position required to foveate the target
%input world-centred position, new eye and neck positions and foveal retinal input (R+W+E+N->T)
x{1}=[code(0,values{1,1},stdx),code(eyetarget,values{1,2},stdx),nullH]';
x{2}=[nullH,code(necktarget,values{2,2},stdx),nullB]';
%x{3}=[nullB,nullT,code(worldtarget,values{3,3},stdx)]';
x{3}=[nullB,code(torsofixedposn,values{3,2},stdx),code(worldtarget,values{3,3},stdx)]';
[y,e,r]=dim_activation_hierarchical(W,x,V,interconnects,y);
if display, figured(figoff+(saccade-1)*nSteps+4),clf,plot_network(x,r,y,partitions,values); end
%step 5) remapping, calculate the visual input expected after upcoming saccade
%input body-centred representation and planned eye, neck and torso positions (E+N+T+W->R)
x{1}=[nullR,code(eyetarget,values{1,2},stdx),nullH]';
x{2}=[nullH,code(necktarget,values{2,2},stdx),nullB]';
x{3}=[nullB,code(torsofixedposn,values{3,2},stdx),worldrep]';
[y,e,r]=dim_activation_hierarchical(W,x,V,interconnects,y);
if display, figured(figoff+(saccade-1)*nSteps+5),clf,plot_network(x,r,y,partitions,values); end
%perform movement (update visual input after saccade)
vistarget=simulate_agent_world_to_retina(trueworldtarget,eyetarget,necktarget,torsofixedposn);
%record movements made over time
eyeposn(saccade+1)=eyetarget;
neckposn(saccade+1)=necktarget;
end
[eyeamp,ind]=max(abs(eyeposn-eyeposn(1))); %see McCluskey Cullen p.2979 (Freedman Sparks use eye amp, don't seem to define it!)
headcontrib=abs(neckposn(ind)-neckposn(1)); %see Freedman Sparks Fig 1
headamp=max(abs(neckposn-neckposn(1))); %see Freedman Sparks Fig 1 & McCluskey Cullen p.2979