Hi Dax Cvancara,
As per my understanding you are working on setting up an eye-tracking experiment and planning to program it in MATLAB. Designing an eye-tracking experiment with saccadic and smooth pursuit tasks can be implemented in MATLAB using the Psychtoolbox.
1.Before you start:
- Install “Psychtoolbox”
- Familiarize with basic “Psychtoolbox” functions such as “Screen”, “DrawFormattedText”, “GetSecs”, “WaitSecs”, “KbCheck”, etc.
- Determine the pixel per degree (ppd) ratio for the display to accurately present stimuli at the desired visual angles.
2.Pro-Saccade Task:
- Create a window using “Screen('OpenWindow', ...)”.
- Load or create a smiley face image of the appropriate size (1 degree of visual angle).
- Display the central fixation point for 1 second.
- Randomly select a direction (left or right) and calculate the target's position (10 degrees from the center).
- Display the target for 300 ms.
3. Express Saccade Task:
- Follow initial steps for the Pro-Saccade task to display the central fixation point.
- Remove the fixation point and wait for 0.2 seconds.
- Display the target 10 degrees left, right, up, or down from the center for 1 second.
4. Smooth Pursuit Task:
- Calculate the sinusoidal trajectory for the moving target based on the desired velocities and amplitudes (±10 degrees).
- On each frame, update the position of the smiley face along the calculated path.
- Present the moving target for the duration of the trial.
Here is a basic code template to get started with the Pro-Saccade task:
Screen('Preference', 'SkipSyncTests', 1);
screenNumber = max(Screen('Screens'));
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, 0);
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
[xCenter, yCenter] = RectCenter(windowRect);
smileyImage = imread('smiley_face.png');
smileyTexture = Screen('MakeTexture', window, smileyImage);
Screen('DrawTexture', window, smileyTexture, [], CenterRectOnPointd([0 0 fixationSize fixationSize], xCenter, yCenter));
WaitSecs(fixationDuration);
direction = randsample([-1, 1], 1);
targetXpos = xCenter + (direction * targetOffset);
Screen('DrawTexture', window, smileyTexture, [], CenterRectOnPointd([0 0 fixationSize fixationSize], targetXpos, yCenter));
WaitSecs(targetDuration);
Screen('Close', smileyTexture);
This sample code provides a basic framework for the Pro-Saccade task and requires modifications for Express Saccade and Smooth Pursuit tasks, including accurate timing and event management. For the Smooth Pursuit, implement a loop to move the smiley face texture frame-by-frame following a sinusoidal trajectory. Keep in mind that further customization may be necessary to align with experimental details like smiley face dimensions, pixel density, and specific timing constraints.
Please refer to the following links-
- Psychtoolbox Installation - https://www.mathworks.com/matlabcentral/fileexchange/76411-psychtoolbox-3?s_tid=srchtitle_support_results_1_Psychtoolbox
- DrawFormattedText - https://www.mathworks.com/support/search.html/answers/608126-drawformattedtext-error-using-psychtoolbox.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:support/installat5630&page=1
- WaitSecs- https://www.mathworks.com/support/search.html/answers/620253-how-to-set-waitsecs-for-several-durations.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:support/multidime381&page=1
- KbCheck- https://www.mathworks.com/support/search.html/answers/1963879-using-psychtoolbox-kbcheck-functions-how-can-i-test-for-a-renewed-keypress.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:support/timing-an5627&page=1
Hope it helps!
Best Regards,
Simar