How do I make my instructions that I'm presenting on screen, not alter the timing of stimulus presentation?

5 views (last 30 days)
Hello,
I'm using the psychtoolbox plugin to present images and instructions on the screen. I have four groups - two receive instructions with the image and two that don't receive instructions with the image. The groups that don't receive instructions, do not have any problems with the image timing (they're all four seconds long). Although, the groups that receive the instructions (PI and NI) have issues with timing. When the image is presented on the screen somtimes it will last five seconds and sometimes it will be four seconds. I have tried using DrawFormatted Text and Draw Text. I have also tried creating a new for loop for the instructions and placing the instructions outside the loop. Unfortunetly, no luck.
Here is a snippet of my code " image_duration = 4; % in seconds. Duration of picture
% Before the loop:
for frame1 = 1:image_duration*desired_framerate-1 % loops 360 times - 1 for calibration. 6 seconds x 60 fps = 360 frames.
Screen('DrawTexture', win, image_texture, [], [dstRect1], 0); % Draw the image
% Inside the loop:
if strcmpi(group, 'PI') || strcmpi(group, 'NI')
Screen('DrawText',win,'This person wants to show you the following picture',x,ycenter+450)
end
Screen('Flip', win); % Display the image
if frame1 == 1
io64(ioObj, address, image_pin); %send the TTL pulse
elseif frame1 == image_duration*desired_framerate-1
io64(ioObj, address, 0); %send the TTL pulse
end
end"
Any help would be greatly appreciated!
Kara

Answers (1)

Anurag
Anurag on 4 Sep 2023
Hi Kara,
As per my understanding of the question, you seem to be having issues with the time taken for presenting the instructions with images.
Please see the following pointers that may be helpful to you for regulating the amount of time the instructions with images are displayed on the screen:
  • Frame Rate Synchronization: Ensure that your monitor's refresh rate (frame rate) matches the desired frame rate for your experiment. In your code, you've used “desired_framerate”, which should match your monitor's capabilities. Check your monitor settings and adjust as needed.
  • Preloading Textures: Load and preprocess all images and textures before the experiment begins. This prevents potential delays when textures are loaded during the experiment. Use the Screen('MakeTexture') function to create textures from your images.
  • Timing Precision: Psychtoolbox provides a more accurate method for timing called ‘WaitSecs’ to achieve precise timing control. Instead of relying solely on Screen('Flip', win), use WaitSecs to control the duration of each frame explicitly.
Hope this helped.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!