| Reference | Downloads | Github

Key release as an answer- how to codify different timings


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:
from psychopy.iohub import EventConstants,KeyboardConstants,ioHubConnection,load,Loader
from 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

# Create an ioHubConnection instance, which starts the ioHubProcess, and informs it of the requested devices and their configurations.

except Exception, e:
import sys
print “!! Error starting ioHub: “,e,” Exiting…”

trialn = 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


END get_vb_keys Begin Routine

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

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.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
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

response_event = None

FINISHED get_vb_release end routine

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