Hi, I was attempting to obtain the coordinates of one of my stimuli in centimeters. I noticed that it was in units of height. When I changed the units of the window and stimulus to cm and ran the experiment, it would prematurely end between 2-4 trials instead of running through the 5 it was programmed to do.
Originally the code read:
win = visual.Window(
size=(Width, Height), fullscr=True, screen=0,
winType='pyglet', allowGUI=False, allowStencil=False,
monitor='testMonitor', color=backgroundColor, colorSpace='rgb',
blendMode='avg', useFBO=True,
units='height')
# set up handler to look after randomisation of conditions etc
trials_2 = data.TrialHandler(nReps=5, method='sequential',
extraInfo=expInfo, originPath=-1,
trialList=[None],
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:
exec('{} = thisTrial_2[paramName]'.format(paramName))
counter = 0
randInt = random.uniform(0.1, 0.3)
for thisTrial_2 in trials_2:
randInt = random.uniform(-0.2, 0.1)
polygon = visual.Rect(
win=win, name='polygon',
width=(0.02, 0.02)[0], height=(0.02, 0.02)[1],
ori=0, pos=(randInt, randInt),
lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
fillColor=stimuliColor, fillColorSpace='rgb',
opacity=1, depth=0.0, interpolate=True)
However, when I change the units of the window and stimuli like this:
# Create window
win = visual.Window(
size=[Width,Height], fullscr=True, screen=int(settingsGui.data[3]),
winType='pyglet', allowGUI=False, allowStencil=True,
monitor='testMonitor', color=backgroundColor, colorSpace='rgb',
blendMode='avg', useFBO=True, units='cm')
for thisTrial_2 in trials_2:
randInt = random.uniform(-0.2, 0.1)
polygon = visual.Rect(
win=win, name='polygon', units='cm',
width=0.4, height=0.4,
ori=0, pos=(randInt, randInt),
lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
fillColor=stimuliColor, fillColorSpace='rgb',
opacity=1, depth=0.0, interpolate=True)
It does not loop through all of the trials. Is there a way to fix this? Any help would be appreciated.