Chapter 5: measuring saccade latency

load saclatdat

figure(2); clf

figure(1); clf

dtdat=dt(1:130,:); col=[.55 .45];

flink=@(x) 1./x;

hzdat=flink(dtdat);

Tmin=1/500; Tmax=1/10; Smin=.001; Smax=.01; n=size(hzdat,1);

thetas=linspace(Tmin,Tmax,1501)'; sigs=linspace(Smin,Smax,501);

Ot=ones(size(thetas)); Os=ones(size(sigs));

Lnorm=@(dnow) -Ot*log(sigs)-.5*((dnow-thetas).^2)*(sigs.^-2);

for Nsub=1:size(dtdat,2),

%plot the data histogram

figure(1); subplot(2,1,Nsub); cla

[n,x]=hist(dtdat(:,Nsub),20); box off; hold on

bar(x,n./max(n),1,'FaceColor',col(Nsub)*[1 1 1]);

[n,x]=hist(dt(:,Nsub),140); subplot(2,1,Nsub);

plot(x,n./max(n),'k--','LineWidth',1.4); axis([0 500 0 1.05])

%compute the 2D (log) probability

L=zeros(size(Ot*Os)); n=size(hzdat,1);

for id=1:n, L=L+Lnorm(hzdat(id,Nsub)); end

figure(2+Nsub); clf; mesh(sigs,thetas,exp(L-max(max(L)))); colormap bone

%Compute and plot marginal posteriors

Ltheta=logsum(L,2); Ltheta=Ltheta-max(Ltheta);

thetahat=logpeakval([Ltheta thetas(:)]); dthat=1/thetahat;

figure(2); subplot(2,1,Nsub); cla; hold on

Ldt=LTX(thetas,Ltheta,flink);

plot(Ldt(:,2),exp(Ldt(:,1)-max(Ldt(:,1))),'--','LineWidth',1.5,'Color',col(Nsub)*[1 1 1]);

plot(dthat*[1 1],[0 1],'k--'); axis([100,300,0,1]); box off; end