Keyboard release event- no response as a correct response

Hi everyone,

I am working on a task, designed in Builder, in which on each trial participants are required to keep two keyboard keys pressed down (index finger on the ‘v’ and middle finger on the ‘b’), then they respond to a cue on the screen by releasing a key, i.e. lifting a finger and putting it back on the same key. To collect key responses, we use an iohub code. The task works fine but now I need to make a change to it and I am hoping someone here will be able to help.

I need to add a new null trial within the same block of experimental trials where no responses are recorded, i.e. we just present an image for a set period of time (5 seconds), then the next trial should begin. To do this I would like to add a code so that for every trial (experimental and null) there is a time out of 5 seconds if no response is made. This gives us plenty of time for a response in the experimental trials and just the time I need for my null event trials. At the moment, the code is set to require a key release response to move to the next trial. I would be very grateful for any help/ suggestions you can give me. Thank you!

In the routine to collect responses we have the following code:

Begin routine tab:

> #Start get_vb_keys Begin Routine
> 
> vb_keys_released=False
> 
> #End get_vb_keys Begin Routine
>  
>  
> Each Frame tab;
> response_events = iokeyboard.getReleases(keys=['v','b'])
> if response_events:
>    
> response_event = response_events[0]
>    
> vb_keys_released=False
>  
>  
> End routine tab:
> 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

Hi @MartaCasales, if you encase your code in backticks like this it is more readable.

Regarding your question, could you set a duration of 5 seconds for your stimuli in Builder, and at the end of those 5 seconds the trial would end?

Hi @dvbridges , many thanks for the recommendation, I will change that!

I did set a duration of 5 seconds in the Builder, but for some reason it ignores those specifications I made. So that is why I thought of adding a code, or remove the one is blocking the specifications made on the Builder.