Hi, The below is my code.
I would like to draw white dots for 60 frames and black dots for 120 frames (this is intertrial intervals) on the black screen. I could get exact number of 60 frames for the first white dots periods but getting extra frames for the black dots. I cannot troubleshoot it. Please advise.
Screen('Preference', 'SkipSyncTests',2);
PsychDefaultSetup(2);
scrsize = [0 0 1920 1080];
[win,rect] = Screen('OpenWindow',0, 0);
Screen('BlendFunction', win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
flipt= Screen('Flip', win);
Screen('FillRect', win, [1 1 1], [1450 1050 1500 1080])
for ii = 1:24
dotwhite=[255 255 255]*1; dotblack=[1 1 1]*1;
dotsarray = createdots (2000, coherence (ii), 450, 7.5, direction (ii), 25); %2.5 for 1s; 7.3 for 3s; 1300 frames for 1s; 3300 frames for 3s
flipt= Screen('Flip', win);
for frameIdx = 1:dotsarray{2}
if frameIdx <= 60 **%% draw white dots**
Screen('DrawDots', win, dotsarray{1}(:, :, frameIdx)', dotsarray{3}, dotwhite, [1920 1080]*.5, 2);
Screen('FillRect', win, [255 255 255], [1450 1050 1500 1080])
Screen('Flip', win, flipt+((1/60)*.7));
else **%% draw black dots**
Screen('DrawDots', win, dotsarray{1}(:, :, frameIdx)', dotsarray{3}, dotblack, [1920 1080]*.5, 2);
Screen('FillRect', win, [1 1 1], [1450 1050 1500 1080])
Screen('Flip', win, flipt+((1/60)*.7));
end
end