psychopy 心理学stroop实验 开发难题求救。

Brink_Brink_ 2020-04-24 11:03:49

我想让justice里边被试反应阶段,被试按左键可以回到 preparation 再进行一次循环,被试按右键可以使程序进行到下一阶段trial1,应该怎样设置。麻烦大家了!
软件psychopy 生成的代码相关脚本如下(仅有justice部分,实在是传不上):
# -------Run Routine "justice"-------
while continueRoutine:
# get current time
t = justiceClock.getTime()
tThisFlip = win.getFutureFlipTime(clock=justiceClock)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame

# *choose* updates
if choose.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
choose.frameNStart = frameN # exact frame index
choose.tStart = t # local t and not account for scr refresh
choose.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(choose, 'tStartRefresh') # time at next scr refresh
choose.setAutoDraw(True)

# *key_resp_6* updates
waitOnFlip = False
if key_resp_6.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
key_resp_6.frameNStart = frameN # exact frame index
key_resp_6.tStart = t # local t and not account for scr refresh
key_resp_6.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(key_resp_6, 'tStartRefresh') # time at next scr refresh
key_resp_6.status = STARTED
# keyboard checking is just starting
waitOnFlip = True
win.callOnFlip(key_resp_6.clock.reset) # t=0 on next screen flip
win.callOnFlip(key_resp_6.clearEvents, eventType='keyboard') # clear events on next screen flip
if key_resp_6.status == STARTED and not waitOnFlip:
theseKeys = key_resp_6.getKeys(keyList=['left', 'right'], waitRelease=False)
_key_resp_6_allKeys.extend(theseKeys)
if len(_key_resp_6_allKeys):
key_resp_6.keys = _key_resp_6_allKeys[-1].name # just the last key pressed
key_resp_6.rt = _key_resp_6_allKeys[-1].rt
# a response ends the routine
continueRoutine = False

# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()

# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in justiceComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished

# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()

# -------Ending Routine "justice"-------
for thisComponent in justiceComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
thisExp.addData('choose.started', choose.tStartRefresh)
thisExp.addData('choose.stopped', choose.tStopRefresh)
# the Routine "justice" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()

# set up handler to look after randomisation of conditions etc
loop1 = data.TrialHandler(nReps=2, method='random',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('trial1.xlsx'),
seed=None, name='loop1')
thisExp.addLoop(loop1) # add the loop to the experiment
thisLoop1 = loop1.trialList[0] # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb = thisLoop1.rgb)
if thisLoop1 != None:
for paramName in thisLoop1:
exec('{} = thisLoop1[paramName]'.format(paramName))

for thisLoop1 in loop1:
currentLoop = loop1
# abbreviate parameter names if possible (e.g. rgb = thisLoop1.rgb)
if thisLoop1 != None:
for paramName in thisLoop1:
exec('{} = thisLoop1[paramName]'.format(paramName))

# ------Prepare to start Routine "trial1"-------
continueRoutine = True
# update component parameters for each repeat
character1.setColor(color, colorSpace='rgb')
character1.setText(characters)
key_resp.keys = []
key_resp.rt = []
_key_resp_allKeys = []
# keep track of which components have finished
trial1Components = [preparation1, character1, key_resp]
for thisComponent in trial1Components:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
trial1Clock.reset(-_timeToFirstFrame) # t0 is time of first possible flip
frameN = -1
...全文
429 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

37,744

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧