clear all close all load('TrainedBeast') nruns = 500; noiseSD = 0.2; Objects.Distance = [4 10]; Objects.Elevation = [0 0];% Beast.RetinalElevations([21 21]); f=figure('pos',[629 324 492 625]); nexpt=3; for jexpt = 1:nexpt switch jexpt case 1 Objects.Azimuth = [-15 15]; Objects.Diameter = [ 1.1 1.1] ; Objects.AngularSizeDeg = 2*atand(0.5*Objects.Diameter ./Objects.Distance); exptlab = sprintf('Both diameters %3.1f cm (%2.0f^o, %2.0f^o)',Objects.Diameter(1),Objects.AngularSizeDeg(1),Objects.AngularSizeDeg(2)) case 2 Objects.Azimuth = [-15 15]; Objects.AngularSizeDeg = [15 15]; Objects.Diameter = 2* Objects.Distance .* tand(Objects.AngularSizeDeg /2) ; exptlab = sprintf('Both diameters %2.0f^o (%3.1f, %3.1fcm)',Objects.AngularSizeDeg(1),Objects.Diameter(1),Objects.Diameter(2)) case 3 Objects.Azimuth = [-15 15]; Objects.AngularSizeDeg = [10 15]; Objects.Diameter = 2* Objects.Distance .* tand(Objects.AngularSizeDeg /2) ; exptlab = sprintf('Diameters %2.0f^o, %2.0f^o (%3.1f, %3.1fcm)',Objects.AngularSizeDeg(1),Objects.AngularSizeDeg(2),Objects.Diameter(1),Objects.Diameter(2)) end Objects.Position = Beast.GetXYZ(Objects.Azimuth,Objects.Elevation,Objects.Distance); [RetinalImages,newAz,newEl,jcorrect] = Beast.ProjectScene(Objects); correctclass = Beast.DirClassLabels(jcorrect); [trueAz,trueEl,truejclass] = GetDirectionsFromClass(Beast,correctclass); clear predAz predEl predjclass for jnoise=1:1e3 % Correlated noise: noise = noiseSD*randn(Beast.nEl,Beast.nAz); NoisyImages = RetinalImages + repmat(noise,1,1,2); predictedclass = classify(Beast.Brain,NoisyImages ); [predAz(jnoise),predEl(jnoise),predjclass(jnoise)] = GetDirectionsFromClass(Beast,predictedclass); end figure(f) subplot(nexpt,2,(jexpt-1)*2+1) histogram(predAz,Beast.RetinalAzimuths) hold on xlim([-30 30]) plot(Objects.Azimuth(1)*[1 1],ylim,'k--') plot(Objects.Azimuth(2)*[1 1],ylim,'k--') plot(trueAz*[1 1],ylim,'r') xlabel('azimuth of head saccade(deg)') title(exptlab) subplot(nexpt,2,(jexpt-1)*2+2) imagesc(Beast.RetinalAzimuths,Beast.RetinalElevations,NoisyImages(:,:,1)); hold on plot(xlim,ylim*0,'r') plot(xlim*0,ylim,'r') xlabel('retinal azimuth (deg)') ylabel('retinal elevation (deg)') title('left-eye image') colormap gray end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# % Vertical disparity %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Objects.Distance = 4; Objects.Elevation = 15 ; Objects.Azimuth = 0; Objects.AngularSizeDeg = 10; Objects.Diameter = 2* Objects.Distance .* tand(Objects.AngularSizeDeg /2) ; Objects.Position = Beast.GetXYZ(Objects.Azimuth,Objects.Elevation,Objects.Distance); [RetinalImages1,newAz,newEl,jcorrect] = Beast.ProjectScene(Objects); Objects.Elevation = -Objects.Elevation; Objects.Position = Beast.GetXYZ(Objects.Azimuth,Objects.Elevation,Objects.Distance); [RetinalImages2,newAz,newEl,jcorrect] = Beast.ProjectScene(Objects); % Take left image from one elevation and right image from the other, to get % image with vertical disparity RetinalImages(:,:,1) = RetinalImages1(:,:,1); RetinalImages(:,:,2) = RetinalImages2(:,:,2); % see where beast looks clear predAz predEl predjclass for jnoise=1:nruns % Correlated noise: noise = noiseSD*randn(Beast.nEl,Beast.nAz); NoisyImages = RetinalImages + repmat(noise,1,1,2); predictedclass = classify(Beast.Brain,NoisyImages ); [predAz(jnoise),predEl(jnoise),predjclass(jnoise)] = GetDirectionsFromClass(Beast,predictedclass); end figure subplot(1,2,1) imagesc(Beast.RetinalAzimuths,Beast.RetinalElevations,NoisyImages(:,:,1)); hold on plot(xlim,ylim*0,'r') plot(xlim*0,ylim,'r') xlabel('retinal azimuth (deg)') ylabel('retinal elevation (deg)') title('left-eye image') subplot(1,2,2) imagesc(Beast.RetinalAzimuths,Beast.RetinalElevations,NoisyImages(:,:,2)); hold on plot(xlim,ylim*0,'r') plot(xlim*0,ylim,'r') xlabel('retinal azimuth (deg)') ylabel('retinal elevation (deg)') title('right-eye image') figure histogram(predEl,Beast.RetinalElevations) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# % Examine performance as a function of distances of the two objects, % if angular size is constant at 10deg %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nObjects = 2; Objects.Elevation = [0 0];% Beast.RetinalElevations([21 21]); Objects.Azimuth = [-15 15]; Objects.AngularSizeDeg = [10 10]; distance_cm = [ 2: 0.5 : 10]; clear pcorr pzero for jL=1:length(distance_cm) for jR=1:length(distance_cm) Objects.Distance = [distance_cm(jL) distance_cm(jR)]; Objects.Diameter = 2* Objects.Distance .* tand(Objects.AngularSizeDeg /2) ; Objects.Position = Beast.GetXYZ(Objects.Azimuth,Objects.Elevation,Objects.Distance); [RetinalImages,newAz,newEl,jcorrect] = Beast.ProjectScene(Objects); correctclass = Beast.DirClassLabels(jcorrect); [trueAz,trueEl,truejclass] = GetDirectionsFromClass(Beast,correctclass); clear predAz predEl predjclass for jnoise=1:nruns predictedclass = classify(Beast.Brain,RetinalImages + noiseSD*randn(size(RetinalImages)) ); [predAz(jnoise),predEl(jnoise),predjclass(jnoise)] = GetDirectionsFromClass(Beast,predictedclass); end % Find proportion of head turns in right direction: pcorr(jR,jL) = sum( sign(predAz) == sign(trueAz) ) /length(predAz); % Find proportion where head doesn't turn: pzero(jR,jL) = sum( predAz == 0 ) /length(predAz); end end figure imagesc(distance_cm,distance_cm,pcorr) colorbar caxis([0 1]) set(gca,'ydir','norm') xlabel('Distance of left-hand target (cm)') ylabel('Distance of right-hand target (cm)') title(sprintf('Proportion of correct choices for two %3.1f^o targets',mean(Objects.AngularSizeDeg))) axis equal tight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# % Examine performance as a function of angular size % if distances are fixed %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nObjects = 2; Objects.Distance = [8 4]; Objects.Elevation = [0 0];% Beast.RetinalElevations([21 21]); Objects.Azimuth = [-15 15]; angsize_deg = [ 5: 2: 25]; clear pcorr pzero for jL=1:length(angsize_deg) for jR=1:length(angsize_deg) Objects.AngularSizeDeg = [angsize_deg(jL) angsize_deg(jR)]; Objects.Diameter = 2* Objects.Distance .* tand(Objects.AngularSizeDeg /2) ; Objects.Position = Beast.GetXYZ(Objects.Azimuth,Objects.Elevation,Objects.Distance); [RetinalImages,newAz,newEl,jcorrect] = Beast.ProjectScene(Objects); correctclass = Beast.DirClassLabels(jcorrect); [trueAz,trueEl,truejclass] = GetDirectionsFromClass(Beast,correctclass); clear predAz predEl predjclass for jnoise=1:nruns % Correlated noise: noise = noiseSD*randn(Beast.nEl,Beast.nAz); NoisyImages = RetinalImages + repmat(noise,1,1,2); predictedclass = classify(Beast.Brain,NoisyImages ); [predAz(jnoise),predEl(jnoise),predjclass(jnoise)] = GetDirectionsFromClass(Beast,predictedclass); end % Find proportion of head turns in right direction: pcorr(jR,jL) = sum( sign(predAz) == sign(trueAz) ) /length(predAz); % Find proportion where head doesn't turn: pzero(jR,jL) = sum( predAz == 0 ) /length(predAz); end end figure %subplot(1,2,1) imagesc(angsize_deg,angsize_deg,pcorr) axis equal tight colorbar caxis([0 1]) set(gca,'ydir','norm') xlabel('Angular diameter of left-hand (further) target (deg)') ylabel('Angular diameter of right-hand (nearer) target (deg)') title(sprintf('Proportion of correct choices for targets %3.1f cm and %3.1f cm distant',Objects.Distance(1),Objects.Distance(2))) % subplot(1,2,2) % imagesc(angsize_deg,angsize_deg,1-pzero) % colorbar % caxis([0 1]) % set(gca,'ydir','norm') % xlabel('Angular size of nearer target') % ylabel('Angular size of further target') % title(sprintf('Proportion of head movements for targets %3.1f cm and %3.1f cm distant',Objects.Distance(1),Objects.Distance(2))) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%# % Examine performance as a function of eccentricity and separation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nObjects = 2; Objects.Distance = [4 8]; Objects.AngularSizeDeg = [10 10]; Objects.Diameter = 2* Objects.Distance .* tand(Objects.AngularSizeDeg /2) ; Objects.Elevation = [-10 10]; ecc = [ 0: 2 : 25 ]; sep = [ 0: 2 : 50 ]; clear pcorr pzero for jecc=1:length(ecc) for jsep=1:length(sep) Objects.Azimuth = [-0.5 0.5] * sep(jsep) + ecc(jecc); Objects.Position = Beast.GetXYZ(Objects.Azimuth,Objects.Elevation,Objects.Distance); [RetinalImages,newAz,newEl,jcorrect] = Beast.ProjectScene(Objects); correctclass = Beast.DirClassLabels(jcorrect); [trueAz,trueEl,truejclass] = GetDirectionsFromClass(Beast,correctclass); clear predAz predEl predjclass for jnoise=1:nruns % Correlated noise: noise = noiseSD*randn(Beast.nEl,Beast.nAz); NoisyImages = RetinalImages + repmat(noise,1,1,2); predictedclass = classify(Beast.Brain,NoisyImages ); [predAz(jnoise),predEl(jnoise),predjclass(jnoise)] = GetDirectionsFromClass(Beast,predictedclass); end % Find proportion of head turns in right direction. NB with sep=0, % both will have the same azimuth, so look to elevation pcorr(jsep,jecc) = sum( sign(predEl) == sign(trueEl) ) /length(predEl); % Find proportion where head doesn't turn: pzero(jsep,jecc) = sum( predAz == 0 ) /length(predAz); end end figure %subplot(1,2,1) imagesc(ecc,sep,pcorr) colorbar caxis([0 1]) set(gca,'ydir','norm') xlabel('Mean eccentricity of targets (deg)') ylabel('Azimuthal separation between targets (deg)') title(sprintf('Proportion of correct choices for %2.0f^o-targets %3.1f cm and %3.1f cm distant',mean(Objects.AngularSizeDeg),Objects.Distance(1),Objects.Distance(2))) % subplot(1,2,2) % imagesc(ecc,sep,1-pzero) % colorbar % caxis([0 1]) % set(gca,'ydir','norm') % xlabel('Angular size of nearer target') % ylabel('Angular size of further target') % title(sprintf('Proportion of head movements for targets %3.1f cm and %3.1f cm distant',Objects.Distance(1),Objects.Distance(2)))