I'm trying to use a loop to show flashing images on the left and right sides of the screen. It's working at the moment, but showing images in the order that they appear in my folder, which is not idea as I would love them to be randomly presented. And ideas would be appreciated.
I am using the psychtoolbox in MATLAB on windows, here's my code:
%reading in all images
baseDir=pwd;
cd([baseDir,'\Images']) %change directory to images folder
jpegFiles = dir('*.jpg'); % create a cell array of all jpeg images
for k=1:size(jpegFiles,1)
images{k}=imread(jpegFiles(k).name);
end
cd(baseDir) %change directory back to the base directory
%using a loop to show images
for k=1:290
texture1(k)=Screen('MakeTexture',w,images{k});
end
for k=1:145
Screen('DrawTexture',w,(texture1(k)), [], leftposition);
Screen('DrawTexture',w,(texture1(k+145)), [], rightposition);
Screen('DrawLines', w, allCoords,...
lineWidthPix, black, [xCenter yCenter], 2);
Screen(w,'Flip');
pause(0.2);
end