Conditional stimuli presentation based on the subject input

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
PsychoPy version (e.g. 3.1.5.x):

What are you trying to achieve?:
Our experiment presents a word stimuli for 2000ms followed by a fixation cross for 2000ms. The subjects are required to make 2 kinds of responses within this total span of 4000ms- make the 1st response and further make a 2nd one depending on their first input. The problem is that the cue for both response should appear only within that 4000ms and 2nd cue must be presented only after the condition for the 1st input has been met with, else move to the next trial, the tricky part being the subjects have the liberty to make the responses(1st and 2nd) anytime within that 4000ms.

What did you try to make it work?:
I’ve tried the dummy loop method as mentioned in https://www.youtube.com/watch?v=kwbHGnJPEHM

What specifically went wrong when you tried that?:
The above Youtube link had untimed subject response, I was hoping someone could help me with my timed restrictions.
Also it would be great if someone could explain how to use the “condition” parameter in the durations.
I apologize if I did not address my issue clearly, would be happy to explain if necessary and thanks for the help in advance !

Hi,

You could split the trial across two routines. The first is set to last for a total of 4000 ms, but has a keyboard component set to detect just one response, and set to “force end of routine”. The second routine then immediately begins, with the second cue set to show at time 0 ms. Again, it contains a keyboard component set to detect just one response and (presumably) to end the routine with that.

The tricky thing here is that the durations for any stimuli in the second routine will have to take account of the time at which the response was made in the first routine.

e.g. let’s say a response is made at 1000 ms in the first routine. Then the second routine needs to start by displaying the text stimulus at time 0, for a further 1000 ms, and then the fixation stimulus from time 1000 ms, for a duration of 2000 ms.

If the response occurred at 3000 ms in the first routine, then the text stimulus wouldn’t be shown at all, and the fixation target would be shown immediately, and for a duration of 1000 ms.

A check would also need to be inserted so that if the first routine ran to completion (i.e. for the full 4000 ms), then the second routine wouldn’t run at all.

This can all be done, but it would probably be easiest if you showed us a screenshot of the timeline of the components in your current trial routine.

EDIT Actually I can see an easier way to do this:

  • Insert a code component on your current routine (from the “custom” component panel).

  • Lay out the routine with the stimuli as you described, but with the second cue set to display at time 0 and end at time 4.0 s.

  • Put a variable name like cue_visibility in the “Opacity” field of that cue, and set it to update as “set every repeat”. That is, we are going to set this cue to be invisible initially, and only display it after the first response has been made.

  • Put this code in the “begin routine” tab:

      cue_visibility = 0
    
  • Put this code in the “each frame” tab, so it will run on every screen refresh:

      if len(your_keyboard_component_name.keys) == 1:
          # the first key has been pressed, so:
          cue_visibility = 1
      elif len(your_keyboard_component_name.keys) == 2:
          continueRoutine = False
          # am assuming you want to end after the second key press
    
  • Make sure the code component is above the cue component so that it does its work before the cue needs to get the answer (you can change the order by right clicking on the component icon).