Hi all,
We want to write a code that records the duration of infants looking behaviour when they look at a fixed image on the left or right of the screen.
A trial starts with an image on the left or right screen, and we play a continuous stream of auditory samples until the infant looks away 2s.
We want to record the infant attention to the stimulus; however, we want to move subsequent trial if the infant looked away more than 2s.
We use the ‘up’ key to record looking behaviour, but there is a problem between actual time because it does not look normal. Please see the message I got when I ran the study.
########### Running: C:\Users\Infant Lab\Desktop\HSs\HSsS_lastrun.py ###########
17014.4448 INFO Loaded monitor calibration from [‘2021_05_18 12:31’]
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
up 268626.6679573 0.7888032999471761
1623939166
up 268630.5078914 4.628737399994861
1623939170
up 268634.8439907 8.964836700004525
1623939174
up 268638.131816 12.252661999955308
1623939177
up 268641.507716 15.628561999998055
1623939181
up 268644.3395635 18.460409499995876
1623939183
0.8805
My supervisor has kindly helped me writing the code, but I assume there is a problem between actual time and recording time.
Please see the code below and help me to fix it.
Begin Experiment
from psychopy.hardware import keyboard
kb=keyboard.Keyboard()
Begin Routine
kb.clock.reset()
kb.getKeys(clear=True)
Each Frame
keys=kb.getKeys(['up'], waitRelease=False)
for thisKey in keys:
if thisKey.name=='up':
print(thisKey.name, thisKey.tDown, thisKey.rt)
print(clock.getAbsTime())
if thisKey.tDown - clock.getAbsTime() >2:
continueRoutine=False
Many thanks in advance.
Best,
Zehra