我想改变试验中的图像数量,例如试验包含3或4或5 ... n个图像。
我的Excel表格包含两个标题:" Span"和"面对"。 Span定义了我想要的试验次数(例如,3,4 ...),Face包含图像文件名(例如,如果Span为3,则为[F001.png,F002.png,F003.png]或实例)。
我创建了两个循环,内循环(称为试验)应该控制试验中的图像数量,因此选项是“试验”。未选中,nReps选项链接到Span,如$ Span。外循环(试验_2)应该控制试验的数量,因此,试验'选择并且nReps设置为1.
但是,我不确定如何链接Image Properties,Image选项中的实际文件名。
我尝试添加$ Face,但它不起作用。
如果我使用eval(Face)[trials.thisN],它会向我提供以下错误消息:无法找到图像文件' [&#39 ;;。因此它尝试在标题Face下搜索该行的第一个字符。
我还尝试将我的列表定义为unicode" [F001.png,F002.png]"或者' [F001.png,F002.png]'在Excel文件中,但没有一个选项工作。
有人有什么建议吗?
# set up handler to look after randomisation of conditions etc
trials_2 = data.TrialHandler(nReps=1, method='sequential',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('Test001.xlsx'),
seed=None, name='trials_2')
thisExp.addLoop(trials_2) # add the loop to the experiment
thisTrial_2 = trials_2.trialList[0] # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb=thisTrial_2.rgb)
if thisTrial_2 != None:
for paramName in thisTrial_2.keys():
exec(paramName + '= thisTrial_2.' + paramName)
for thisTrial_2 in trials_2:
currentLoop = trials_2
# abbreviate parameter names if possible (e.g. rgb = thisTrial_2.rgb)
if thisTrial_2 != None:
for paramName in thisTrial_2.keys():
exec(paramName + '= thisTrial_2.' + paramName)
# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=Span, method='sequential',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions('Test001.xlsx'),
seed=None, name='trials')
thisExp.addLoop(trials) # add the loop to the experiment
thisTrial = trials.trialList[0] # so we can initialise stimuli with some values
# abbreviate parameter names if possible (e.g. rgb=thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '= thisTrial.' + paramName)
for thisTrial in trials:
currentLoop = trials
# abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
if thisTrial != None:
for paramName in thisTrial.keys():
exec(paramName + '= thisTrial.' + paramName)
#------Prepare to start Routine "trial"-------
t = 0
trialClock.reset() # clock
frameN = -1
routineTimer.add(2.500000)
# update component parameters for each repeat
image.setImage(eval(Face)[trials.thisN])
# keep track of which components have finished
trialComponents = []
trialComponents.append(image)
trialComponents.append(text_2)
for thisComponent in trialComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#-------Start Routine "trial"-------
continueRoutine = True
while continueRoutine and routineTimer.getTime() > 0:
# get current time
t = trialClock.getTime()
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *image* updates
if t >= 0.0 and image.status == NOT_STARTED:
# keep track of start time/frame for later
image.tStart = t # underestimates by a little under one frame
image.frameNStart = frameN # exact frame index
image.setAutoDraw(True)
if image.status == STARTED and t >= (0.0 + (2.0-win.monitorFramePeriod*0.75)): #most of one frame period left
image.setAutoDraw(False)
# *text_2* updates
if t >= 2.0 and text_2.status == NOT_STARTED:
# keep track of start time/frame for later
text_2.tStart = t # underestimates by a little under one frame
text_2.frameNStart = frameN # exact frame index
text_2.setAutoDraw(True)
if text_2.status == STARTED and t >= (2.0 + (0.5-win.monitorFramePeriod*0.75)): #most of one frame period left
text_2.setAutoDraw(False)
# 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 trialComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# check for quit (the Esc key)
if endExpNow or event.getKeys(keyList=["escape"]):
core.quit()
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
#-------Ending Routine "trial"-------
for thisComponent in trialComponents:
if hasattr(thisComponent, "setAutoDraw"):
thisComponent.setAutoDraw(False)
# completed Span repeats of 'trials'
thisExp.nextEntry()
# completed 1 repeats of 'trials_2'
win.close()
core.quit()