Help developing targets/dots with which a participant will follow with their eyes

조회 수: 3 (최근 30일)
I am currently designing an experiment using an gaze/eye tracking device where I will be tracking participants eyes as they look at targets (as mentioned below). I am currently working on designing these targets but have limited experience working with code and I was wondering if anyone has any experience programming the following actions:
  1. Pro-Saccade: Central fixation point will be a 1 degree smiley face that will last for 1 second. Target will be fixed 10 degrees left or right, horizontally and will appear for 300 ms.
  2. Express Saccade: Central fixation point will be a 1 degree smiley face then disappear before target appearance which will be fixed 10 left or right, horizontally or vertically for 1 second. The delay in fixation point disappearance and target appearance will be 0.2 seconds.
  3. Smooth pursuit - Participant will follow moving point target (1 degree smiley face) sinusoidally ±10° along the horizontal meridian at peak velocities of 10°/s, 20°/s, and 30°/s. Will run three trials with 3 different velocities.
If anyone has any insights into this at all, our team would greatly appreciate any help.

답변 (1개)

Simar
Simar 2024년 1월 31일
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:
% Example MATLAB code for the Pro-Saccade Task using Psychtoolbox
% Setup Psychtoolbox
Screen('Preference', 'SkipSyncTests', 1);
PsychDefaultSetup(2);
% Open a graphics window
screenNumber = max(Screen('Screens'));
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, 0);
% Get the size of the onscreen window and center
[screenXpixels, screenYpixels] = Screen('WindowSize', window);
[xCenter, yCenter] = RectCenter(windowRect);
% Define the smiley face image file
smileyImage = imread('smiley_face.png'); % Replace with the path to your image
% Make the image into a texture
smileyTexture = Screen('MakeTexture', window, smileyImage);
% Define fixation duration and target display duration
fixationDuration = 1; % seconds
targetDuration = 0.3; % seconds
% Define degrees to pixels conversion (assuming you know the ppd)
ppd = 50; % pixels per degree, this is an example value and will vary
% Define the fixation point size and target offset
fixationSize = ppd * 1; % 1 degree of visual angle
targetOffset = ppd * 10; % 10 degrees of visual angle
% Draw the fixation point (smiley face) on the center
Screen('DrawTexture', window, smileyTexture, [], CenterRectOnPointd([0 0 fixationSize fixationSize], xCenter, yCenter));
Screen('Flip', window);
% Wait for 1 second
WaitSecs(fixationDuration);
% Randomly choose a direction for the target (left or right)
direction = randsample([-1, 1], 1);
% Calculate the target position based on direction
targetXpos = xCenter + (direction * targetOffset);
% Draw the target (smiley face) on the screen at the offset position
Screen('DrawTexture', window, smileyTexture, [], CenterRectOnPointd([0 0 fixationSize fixationSize], targetXpos, yCenter));
Screen('Flip', window);
% Wait for 300 ms
WaitSecs(targetDuration);
% Close the window and textures
Screen('Close', smileyTexture);
Screen('CloseAll');
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

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by