Hello,
I have a question concerning a Matlab code for a gaze dependent
display. I adapted some code which was in the forum, but mine does not
seem to work properly. The display just switches to another screen
after sometime. I pasted the code beneath. Could anyone help me with
this!
Thanks a lot.
Michael
function breaktrial = gazedependentdisplay(calltime, begintime,
endtime, xpos, ypos, reqFixTime, maxFCDur, fixTolerance)
global VSGET_eye_used;
global VSGET_ts;
global VSGET_mx;
global VSGET_my;
breaktrial = 0;
% verify fixation stability for a particular amount of time
% Eyelink('message', 'Check Fixation Start' );
% disp('Check Fixation Start');
[h]=crsGetScreenHeight();
fixTolerancePix=round(fixTolerance/100*h);
%movThresholdPix=round((par.stimRadius(trial)/100)*h/2);
tfcEnd=GetSecs+maxFCDur; %max time fixation check may take before we
enforce driftcorrection
errorp=Eyelink('CheckRecording');
if(errorp~=0)
error('Eyelink CheckRecording returned %d', errorp);
end
if Eyelink('NewFloatSampleAvailable') > 0
% get the sample in the form of an event structure
evt = Eyelink('NewestFloatSample');
if VSGET_eye_used ~= -1 % do we know which eye to use yet?
% if we do, get current gaze position from sample
x = evt.gx(VSGET_eye_used+1); % +1 as we're accessing MATLAB array
y = evt.gy(VSGET_eye_used+1);
% do we have valid data and is the pupil visible?
if x~=el.MISSING_DATA && y~=el.MISSING_DATA &&
evt.pa(VSGET_eye_used+1)>0
VSGET_mx=x;
VSGET_my=y;
end
end
end
d=sqrt((VSGET_mx-xpos)^2+(VSGET_my-ypos)^2);
if d<fixTolerancePix
if VSGET_ts<0
VSGET_ts=GetSecs;
elseif (GetSecs-VSGET_ts) > reqFixTime
fprintf('fixation point fixated long enough\n');
Eyelink('message', 'Check Fixation End' );
breaktrial = 1;
end
else
VSGET_ts=-1;
end
if GetSecs > tfcEnd
Eyelink('message', 'Enforcing driftcorrection: no accurate
fixation after %f secs', maxFCDur );
EyelinkDoDriftCorrection(el);
end
I have a question concerning a Matlab code for a gaze dependent
display. I adapted some code which was in the forum, but mine does not
seem to work properly. The display just switches to another screen
after sometime. I pasted the code beneath. Could anyone help me with
this!
Thanks a lot.
Michael
function breaktrial = gazedependentdisplay(calltime, begintime,
endtime, xpos, ypos, reqFixTime, maxFCDur, fixTolerance)
global VSGET_eye_used;
global VSGET_ts;
global VSGET_mx;
global VSGET_my;
breaktrial = 0;
% verify fixation stability for a particular amount of time
% Eyelink('message', 'Check Fixation Start' );
% disp('Check Fixation Start');
[h]=crsGetScreenHeight();
fixTolerancePix=round(fixTolerance/100*h);
%movThresholdPix=round((par.stimRadius(trial)/100)*h/2);
tfcEnd=GetSecs+maxFCDur; %max time fixation check may take before we
enforce driftcorrection
errorp=Eyelink('CheckRecording');
if(errorp~=0)
error('Eyelink CheckRecording returned %d', errorp);
end
if Eyelink('NewFloatSampleAvailable') > 0
% get the sample in the form of an event structure
evt = Eyelink('NewestFloatSample');
if VSGET_eye_used ~= -1 % do we know which eye to use yet?
% if we do, get current gaze position from sample
x = evt.gx(VSGET_eye_used+1); % +1 as we're accessing MATLAB array
y = evt.gy(VSGET_eye_used+1);
% do we have valid data and is the pupil visible?
if x~=el.MISSING_DATA && y~=el.MISSING_DATA &&
evt.pa(VSGET_eye_used+1)>0
VSGET_mx=x;
VSGET_my=y;
end
end
end
d=sqrt((VSGET_mx-xpos)^2+(VSGET_my-ypos)^2);
if d<fixTolerancePix
if VSGET_ts<0
VSGET_ts=GetSecs;
elseif (GetSecs-VSGET_ts) > reqFixTime
fprintf('fixation point fixated long enough\n');
Eyelink('message', 'Check Fixation End' );
breaktrial = 1;
end
else
VSGET_ts=-1;
end
if GetSecs > tfcEnd
Eyelink('message', 'Enforcing driftcorrection: no accurate
fixation after %f secs', maxFCDur );
EyelinkDoDriftCorrection(el);
end