psychopy.org | Reference | Downloads | Github

Multiple component start/stop conditions

OS (e.g. Win10): macOS Mojave
PsychoPy version (e.g. 1.84.x): 1.90.3
Standard Standalone? (y/n) If not then what?:

I am trying to set the duration of an image component to range between 5 seconds and 10 seconds. If the participant responds in under 5, the image should remain on the screen for 5 seconds before a fixation cross appears. However, if the participant takes longer than 5 seconds to respond, their key response will trigger the fixation cross to appear. Finally, if they take 10 seconds and have not responded, the fixation cross will appear after those 10 seconds. This is part of a loop where 30 images will be shown to the participant with a fixation cross appearing between each image after they’ve given a response.

I used the code $key_resp_5.status==FINISHED as the start condition for my text component and this made the fixation cross appear after the 5 second duration of the image component. I have not been able to figure out how to create an “or” command where the text component (fixation cross) begins after a key press.

I am not getting any error message, but instead my fixation cross is not appearing if a response is made during the image component and instead the next image in the loop is appearing.

So my two questions would be: How do I create a component duration range between 5-10 seconds? And how do I code my task to move to the fixation cross text in response to a key press?

Any guidance on this would be appreciated!

Hi @nels6774, I think the easiest option would be to have several routines to satisfy these requirements, as below:

image

Trial routine

Here you will have a 10 second presentation of your stim, and a keyboard for ending the trial on a keypress.

earlyResponseRoutine

This routine will be presented conditionally. If the response is early (< 5 seconds) the same image from the trial routine will be presented with a duration of 5 seconds - key_resp RT and then the routine will end. Otherwise, a code component will end the routine without being presented (i.e., for non responses, or response RTs >= 5 seconds:

# Begin routine
if key_resp.rt is None or key_resp.rt >= 5:  # note, key_resp is the keyboard
    continueRoutine = False

Fix

Your fixation presentation.

Here is the psyexp example.
variableOnset.psyexp (10.9 KB)

@dvbridges I just tried to run the experiment you posted as a solution to this problem, and I got an error when I made no response for 10 seconds. Instead of the experiment continuing to the fixation cross automatically, the experiment ended and this was the error message:

if key_resp.rt is None or key_resp.rt >= 5:
TypeError: ‘>=’ not supported between instances of ‘list’ and ‘int’

Experiment ended.

I’m thinking that this code will be a solution to my experiment’s problem as well, but I don’t know how to fix it (I’m definitely not a coder)!

Thank you!