对于我的实验,我正在创建一个简单的反应时测试。它将有4个区块,每个区块6次试验。我已经成功地在屏幕上呈现了第一次试块,尽管是为了一轮练习(刺激确实出现了)。然而,我不确定我是否应该创建一系列的列表(即,为不同的试验保留不同的刺激),或者我是否应该改变我现有的一个循环的特征。我的代码如下:
from psychopy import visual, core, event #import some libraries from PsychoPy
import psychopy.event
#Create the code for saving the data at some point
#create a window
mywin = visual.Window([1920,1080], monitor="testMonitor", units="deg")
mywin.update()
# create the six stimuli:
Target = visual.TextStim(mywin, text = "text default")
text_stim_list = [] # a list to hold them
Stim_text = ["Berlin", "Paris", "London", "Nice", "Vienna", "Charming"] #
their content
#the positions of the stimuli
positions = [
(-10, 10),
(10, 10),
(-10, -10),
(10, -10),
(-1, -10),
(1, 10),
]
#Initial message to participants about the study
message1 = visual.TextStim(mywin, text = "You have been captured by the
plotters. As a test to see if you have information regarding the event, an
on screen test will be adminstered. Press Spacebar when ready")
message1.draw()
mywin.update()
#this will wait for a button press confirmation from p's to continue
response = event.waitKeys(keyList = ['space',], timeStamped = True)
#Initial message to participants about the study
message1 = visual.TextStim(mywin, text = "On the next screen, you will be
presented with a practice round of stimuli. Press Q if any of the cities are
familiar, or press P if you do not recognise the cities")
message1.draw()
mywin.update()
#this will wait for a button press confirmation from p's to continue
response = event.waitKeys(keyList = ['space',], timeStamped = True)
#Loop for drawing the stimulus
#code for the keyboard response
keys = psychopy.event.waitKeys(keyList=["q", "p"])
#Practice round-should it be stopped by a button press?
for frameN in range(7*60):
# draw each stim *on each frame*
for i in range(len(Stim_text)):
Target.setPos(positions[i])
Target.setText(Stim_text[i])
Target.draw()
# now flip the window (after all stimuli drawn)
mywin.flip()
#Initial message to participants about the study
message1 = visual.TextStim(mywin, text = "On the next screen, the cities
which
our intelligence tells us are at risk will be presented. Press Q if any are
familiar, press P if not blah blah blah.. press space when ready")
message1.draw()
mywin.update()
response = event.waitKeys(keyList = ['space',], timeStamped = True)#wait for
subjects to state they are ready
#Cities block
#First trial
print Stim_text
del Stim_text[1,2]
print Stim_text
我很肯定这会涉及到改变循环的属性——否则,有这么多的列表是没有意义的。你知道吗
内森
一般来说,我会这样做:
正如Mike在一篇评论中指出的那样,看看
psychopy.data.TrialHandler
它可以为您做很多事情,包括保存数据。而且,不需要为每条消息生成一个新的visual.TextStim
。只需用所需的文本更新现有文本。你知道吗相关问题 更多 >
编程相关推荐