psychopy.org | Reference | Downloads | Github

Key release as an answer- how to codify different timings


#1

Hi all,

I am trying to create an imitation-inhibition task in which the responses to the experimental conditions (congruent and incongruent stimuli)are done by releasing the pressed keys. The keys are “v” and “b”, and they have to response to a finger lifting image. I also have a control condition in which the hand appears static for 5 seconds. For the key release I have iohub codes.
The problem is that, for the control conditions, it needs a reply to go to the next image, but I don’t want participants to give a reply, I want the image to stay for 5 seconds and go away while they keep those keys pressed. How can I specify that the control condition does not need an answer?

I have this codes for the key release:

In the first routine of instructions (before any loop):
Begin experiment:
try:
from psychopy.iohub import EventConstants,KeyboardConstants,ioHubConnection,load,Loader
from psychopy.data import getDateStr
# Load the iohub device config, file converting it to a python dict.
io_config=load(file(‘iohub_config.yaml’,‘r’), Loader=Loader)

# Add / Update the session code to be unique. Here we use the psychopy getDateStr() function for session code generation
session_info=io_config.get('data_store').get('session_info')
session_info.update(code="S_%s"%(getDateStr()))

# Create an ioHubConnection instance, which starts the ioHubProcess, and informs it of the requested devices and their configurations.
io=ioHubConnection(io_config)
iokeyboard=io.devices.keyboard
iomouse=io.devices.mouse

except Exception, e:
import sys
print “!! Error starting ioHub: “,e,” Exiting…”
sys.exit(1)

trialn = 0
trial_start=0

End experiment: io.quit()

In the practice trial (the first loop), we have this code:
Begin experiment:
Countcorr = 0 #to reset the counter for corrrect responses to 0

Begin routine:

START get_vb_keys Begin Routine

vb_keys_released=False

END get_vb_keys Begin Routine

Each frame:
response_events = iokeyboard.getReleases(keys=[‘v’,‘b’])
if response_events:
response_event = response_events[0]
vb_keys_released=False

End routine:
if response_event is None:
response_events = iokeyboard.waitForReleases(maxWait=1000.0, keys=[‘v’,‘b’])
response_event = response_events[0]

trials.addData(“resp.time”, response_event.time)
trials.addData(“resp.rt”, response_event.time-trial_start)
trials.addData(‘resp.keys’,response_event.key)
trials.addData(‘resp.corr’, response_event.key==corrAns)

#check for consecutive correct responses
if response_event.key==corrAns: #if the keys are pressed for the correct answer
Countcorr = Countcorr + 1 #then variable updates by adding 1 to the counter
else:
Countcorr = 0 #if an incorrect response is made, then reset counter

print Countcorr

if Countcorr == 10:
trials.finished = True #finish the practice block after 10 consecutive correct responses

io.clearEvents()
iokeyboard.clearEvents()
response_event = None
vb_keys_released=False

FINISHED get_vb_release end routine

I am not sure if that is everything needed to explain my doubt.
Thanks for the information!