Crash after creating a loop with condition files

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Mac Catalina
PsychoPy version (e.g. 1.84.x): v2020.2.5

I am trying to construct a loop of the trial with question on Psychopy, but every time I try to run the experiment, it keeps crashing.

Everything worked fine before I created a loop. However, once I made a loop with a condition file, it stopped working. I am not sure what the problem is.

This are the codes:

win = visual.Window(
    size=(1024, 768), fullscr=True, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True, 
    units='height')
### store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

### create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard()

### Initialize components for Routine "trial"
trialClock = core.Clock()
tr_white = visual.ShapeStim(
    win=win, name='tr_white',units='deg', 
    vertices=[[-(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [+(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [0,(1.5, 1.5)    [1]/2.0]],
    ori=1.0, pos=[0,0],
    lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
    fillColor=[1,1,1], fillColorSpace='rgb',
    opacity=1, depth=0.0, interpolate=True)
tr_black = visual.ShapeStim(
    win=win, name='tr_black',units='deg', 
    vertices=[[-(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [+(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [0,(1.5, 1.5)    [1]/2.0]],
   ori=1.0, pos=[0,0],
    lineWidth=1, lineColor=[-1,-1,-1], lineColorSpace='rgb',
    fillColor=[-1,-1,-1], fillColorSpace='rgb',
    opacity=1, depth=-1.0, interpolate=True)
tr_red = visual.ShapeStim(
    win=win, name='tr_red',units='deg', 
    vertices=[[-(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [+(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [0,(1.5, 1.5)[1]/2.0]],
    ori=1.0, pos=[0,0],
    lineWidth=1, lineColor=[1,-1,-1], lineColorSpace='rgb',
    fillColor=[1,-1,-1], fillColorSpace='rgb',
    opacity=1, depth=-2.0, interpolate=True)
tr_green = visual.ShapeStim(
    win=win, name='tr_green',units='deg', 
    vertices=[[-(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [+(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [0,(1.5, 1.5)[1]/2.0]],
    ori=1.0, pos=[0,0],
    lineWidth=1, lineColor=[-1,1,-1], lineColorSpace='rgb',
    fillColor=[-1,1,-1], fillColorSpace='rgb',
    opacity=1, depth=-3.0, interpolate=True)
tr_blue = visual.ShapeStim(
    win=win, name='tr_blue',units='deg', 
    vertices=[[-(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [+(1.5, 1.5)[0]/2.0,-(1.5, 1.5)[1]/2.0], [0,(1.5, 1.5)[1]/2.0]],
    ori=1.0, pos=[0,0],
    lineWidth=1, lineColor=[-1,0,1], lineColorSpace='rgb',
    fillColor=[-1,0,1], fillColorSpace='rgb',
    opacity=1, depth=-4.0, interpolate=True)

### Create some handy timers
globalClock = core.Clock()  # to track the time since experiment started
routineTimer = core.CountdownTimer()  # to track time remaining of each (non-slip) routine 

### set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=2, method='random', 
    extraInfo=expInfo, originPath=-1,
    trialList=data.importConditions('5tr_condition.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:
        exec('{} = thisTrial[paramName]'.format(paramName))

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

### ------Prepare to start Routine "trial"-------
continueRoutine = True
routineTimer.add(1.000000)
# update component parameters for each repeat
tr_white.setPos(tr_positiion)
tr_white.setOri(direction)
tr_black.setPos(tr_position)
tr_black.setOri(direction)
tr_red.setPos(tr_position)
tr_red.setOri(direction)
tr_green.setPos(tr_position)
tr_green.setOri(direction)
tr_blue.setPos(tr_position)
tr_blue.setOri(direction)
### keep track of which components have finished
trialComponents = [tr_white, tr_black, tr_red, tr_green, tr_blue]
for thisComponent in trialComponents:
    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")
trialClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
frameN = -1

Hi there,

Firstly, please can I confirm that this is an experiment you are coding from scratch, rather than a builder experiment? If so, please may you recatagorise this topic under “coder” rather than “builder”.

Second, please could you provide an error message to help pinpoint the issue below?

Thanks,
Becca