我有一个关于洗牌的问题,但首先,这是我的代码:
from psychopy import visual, event, gui
import random, os
from random import shuffle
from PIL import Image
import glob
a = glob.glob("DDtest/targetimagelist1/*")
b = glob.glob("DDtest/distractorimagelist1/*")
target = a
distractor = b
pos1 = [-.05,-.05]
pos2 = [.05, .05]
shuffle(a)
shuffle(b)
def loop_function_bro():
win = visual.Window(size=(1280, 800), fullscr=True, screen=0, monitor='testMonitor', color=[-1,-1,-1], colorSpace='rgb')
distractorstim = visual.ImageStim(win=win,
image= distractor[i], mask=None,
ori=0, pos=pos1, size=[0.5,0.5],
color=[1,1,1], colorSpace='rgb', opacity=1,
flipHoriz=False, flipVert=False,
texRes=128, interpolate=True, depth=-1.0)
targetstim= visual.ImageStim(win=win,
image= target[i], mask=None,
ori=0, pos=pos2, size=[0.5,0.5],
color=[1,1,1], colorSpace='rgb', opacity=1,
flipHoriz=False, flipVert=False,
texRes=128, interpolate=True, depth=-2.0)
distractorstim.setAutoDraw(True)
targetstim.setAutoDraw(True)
win.flip()
event.waitKeys(keyList = ['space'])
for i in range (2):
loop_function_bro()
此代码随机打乱一堆图像并显示它们。但是,我希望它以相同的顺序随机播放图像,以便两个列表以相同的随机顺序显示。有没有办法做到这一点?
干杯,:)