You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my experiment subjects are asked to press certain keys during one trial, hold them down, and release them in one of the following trials. I need to store their reaction times and the duration of every key press.
If the key is pressed and released within trial n, all good.
When the key is released during trial n+1 , the key event is logged in the row corresponding to trial n+1 but the reaction time refers to trial n
Expected Behaviour
Positive reaction times when the key is pressed and released within trial n, negative reaction times when the key is pressed in trial n but released in trial n+1.
NOTE: this was working as expected in version 2022.2.1 (I am upgrading to exploit new features!)
Steps to Reproduce
Create a code component with these snippets. Press (one of) the specified key(s) during one trial, release during the next.
The expected reaction times are stored in CustomKeyboard.rt_corr (and correspond to CustomKeyboard.rt.rt when keys are pressed and released within the same trial).
# ** BEGIN EXPERIMENT tab ** #CustomKeyboard=keyboard.Keyboard()
# ** BEGIN ROUTINE tab ** ### create starting attributes for CustomKeyboardCustomKeyboard.keys= []
CustomKeyboard.rt= []
CustomKeyboard.tDown= []
CustomKeyboard.rt_corr= []
CustomKeyboard.duration= []
_CustomKeyboard_allKeys= []
CustomKeyboard.tStart=NoneCustomKeyboard.tStartRefresh=NoneCustomKeyboard.status=NOT_STARTED# ** EACH FRAME tab ** ### *CustomKeyboard* updateswaitOnFlip=False# if CustomKeyboard is starting this frame...ifCustomKeyboard.status==NOT_STARTEDandtThisFlip>=0.0-frameTolerance:
# keep track of start time/frame for laterCustomKeyboard.frameNStart=frameN# exact frame indexCustomKeyboard.tStart=t# local t and not account for scr refreshCustomKeyboard.tStartRefresh=tThisFlipGlobal# on global timewin.timeOnFlip(CustomKeyboard, 'tStartRefresh') # time at next scr refresh# add timestamp to datafilethisExp.timestampOnFlip(win, 'CustomKeyboard.started')
# update statusCustomKeyboard.status=STARTED# keyboard checking is just startingwaitOnFlip=Truewin.callOnFlip(CustomKeyboard.clock.reset) # t=0 on next screen flip# skipping the line below doesn't change the issuewin.callOnFlip(CustomKeyboard.clearEvents, eventType='keyboard')
ifCustomKeyboard.status==STARTEDandnotwaitOnFlip:
theseKeys=CustomKeyboard.getKeys(keyList=['capslock','a','return','pound'], waitRelease=True)
_CustomKeyboard_allKeys.extend(theseKeys)
iflen(_CustomKeyboard_allKeys):
CustomKeyboard.keys= [key.nameforkeyin_CustomKeyboard_allKeys] # storing all keysCustomKeyboard.rt= [key.rtforkeyin_CustomKeyboard_allKeys]
CustomKeyboard.tDown= [key.tDownforkeyin_CustomKeyboard_allKeys]
CustomKeyboard.rt_corr= [ key.tDown-CustomKeyboard.tStartRefreshforkeyin_CustomKeyboard_allKeys]
CustomKeyboard.duration= [key.durationforkeyin_CustomKeyboard_allKeys]
# ** END ROUTINE tab ** ### check for responsesifCustomKeyboard.keysin ['', [], None]: # No response was madeCustomKeyboard.keys=NonethisExp.addData('CustomKeyboard.keys',CustomKeyboard.keys)
ifCustomKeyboard.keys!=None: # we had a responsethisExp.addData('CustomKeyboard.rt', CustomKeyboard.rt)
thisExp.addData('CustomKeyboard.tDown', CustomKeyboard.tDown)
thisExp.addData('CustomKeyboard.rt_corr', CustomKeyboard.rt_corr)
thisExp.addData('CustomKeyboard.duration', CustomKeyboard.duration)
```python### Additional context_Noresponse_
The text was updated successfully, but these errors were encountered:
PsychoPy Version
2024.2.1
What OS are your PsychoPy running on?
Windows 11
Bug Description
In my experiment subjects are asked to press certain keys during one trial, hold them down, and release them in one of the following trials. I need to store their reaction times and the duration of every key press.
If the key is pressed and released within trial n, all good.
When the key is released during trial n+1 , the key event is logged in the row corresponding to trial n+1 but the reaction time refers to trial n
Expected Behaviour
Positive reaction times when the key is pressed and released within trial n, negative reaction times when the key is pressed in trial n but released in trial n+1.
NOTE: this was working as expected in version 2022.2.1 (I am upgrading to exploit new features!)
Steps to Reproduce
Create a code component with these snippets. Press (one of) the specified key(s) during one trial, release during the next.
The expected reaction times are stored in CustomKeyboard.rt_corr (and correspond to CustomKeyboard.rt.rt when keys are pressed and released within the same trial).
The text was updated successfully, but these errors were encountered: