Hi everyone,
I have 10 trials and 2 conditions (neutral and condition). I have to random draw 10 images from a folder of 100 images without replacement for each trial and for each condition and to display it. I created a function, but images are sometimes repeating.
function print_random_images(w, type, deviceIndex, path, img,folder, N, text, …
backgroundColor, textColor, dispW, dispH, slack)*
images = dir(fullfile(path, '.jpg’));
files = fullfile({images.folder}, {images.name});*
index = 1:numel(files);*
-
if type == 0* -
displayTextCentered(w, text, backgroundColor,textColor, 1.5,50, 'center', 'center');* -
waitTTL(deviceIndex)* -
* -
for i = 1:numel(files) / 2* -
selected = randperm(numel(index),N);* -
file = img{selected};* -
image = imread(fullfile(folder,file));* -
imageDisplay = Screen('MakeTexture',w,image);* -
showImagesAndFixationCross(w,backgroundColor,dispW,dispH,slack, imageDisplay)* -
end* -
elseif type == 1* -
displayTextCentered(w, text, backgroundColor,textColor, 1.5,50, 'center', 'center');* -
waitForSpaceKeyPress()* -
* -
for i= 1:numel(files)/ 2* -
selected = randsample(numel(index),N);* -
file = img{selected};* -
image = imread(fullfile(folder, file));* -
imageDisplay = Screen('MakeTexture', w, image);* -
showImagesAndFixationCross(w,backgroundColor,dispW,dispH,slack, imageDisplay)* -
end* -
end*
end
Can someone help me, please ??
Thanks a lot