% revision 1.00.1 beta, 07/01/04
function response = localizer_detect
global def
global work
global simwork
% we select only the left channels, the model is monaural
simwork.tmpSig = work.signal;
simwork.DOA = [];
% for each interval, run doa=localizer_preproc(interval sound),
% so that we have an estimate of the DOA for each presented interval
% NOTE!!! the target interval of the current trial is always in the
% first two columns of work.signal (so also of simwork.tmpSig), no matter
% in which order it was presented to the subject!
for i=1:def.intervalnum
simwork.DOA(i) = eval([work.vpname '_preproc(simwork.tmpSig(:,2*i-1:2*i))']); % actual sig processing
end
% Create the reasoning-scheme of the machine:
% The task for the subject is always: press the interval, which you think
% was different from two other intervals, so response is always 1,2 or 3.
% How will the machine respond if the DOA estimated for all intervals is
% the same? How would it be if they are all different?
if length(unique(simwork.DOA))==1
response=randi(3);
else
where=simwork.DOA(1)-simwork.DOA(2:3);
if where(1)==where(2)
response=1;
elseif where(1)==0
response=3;
elseif where(2)==0
response=2;
elseif where(1)~=where(2)
response=randi(3);
end
end
% NOTE!!! the target interval of the current trial is always in the
% first two columns of work.signal (so also of simwork.tmpSig), no matter
% in which order it was presented to the subject! Therefore the right anwer
% is always response=1. If it is 2 or 3, we set it here to 0 (wrong):
if response ~= 1
response = 0;
end
end
% eof