psychopy.org | Reference | Downloads | Github

Multiple feedback components in one routine

So, I posted this in a different topic (I hope that’s allowed? If not, I’ll edit the other one). But as I proposed two different solutions, I thought this simpler one might be better. Some of this is copy-pasted from the other topic, but I added some more detail.

Here is my other topic: Multiple keyboard components in one routine without using a loop

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 3
Standard Standalone? (y/n): yes
What are you trying to achieve?:

I am creating an experiment where participants have to listen to sequences of (two types of) words, ranging from 2 w/seq to 6 w/seq. I have managed to build and code the sounds, but after each sequence, participants need to press f or j for the sounds they just listened to. So not one key per sequence, but one key per word.
I also need to know if the sequence of keys is correct, e.g. if a participant listens to a two-word sequence with the correct key ‘f, j’ then my data will only return 1 if those keys in that order are correct.

What did you try to make it work?:

So, for this one, I have one keyboard component per word: two for a two-word sequence, three for a three-word sequence, and so on. In the builder, it looks like this:

The specs of the key component look like this:


(For the last keyboard component in the routine, I would tick ‘Force end of routine’)

I even added a code component (in Each Frame), hoping it would do something (it didn’t)

# get one response per keyboard component
if keySeq2_1.keys in ['', [], None]:  # All possible none responses
   keySeq2_1.keys = None
   if keySeq2_1.keys != None: # A response is made
    thisExp.nextEntry()

What specifically went wrong when you tried that?:

My experiment runs, and I get no error code in my runner, but there is no rhyme or reason as to when my routine ends. Or, maybe better put, when PsychoPy goes from one keyboard component to the next. I changed Store from “first key” to “all keys” just to see what happened and my csv file showed me some very interesting things I have no idea what to do with.

I’m not going to upload all of my trial runs, but they all look different: some long, some short, some don’t even have a response in keySeq2_1.keys.

So my actual question is: is there some code that will tell PsychoPy to go from one component to the next as soon as a response has been given?

You could start with a condition.

Try key_resp_1.keys as the start condition for key_resp_2 etc.

Thank you for your reply! Unfortunately, this didn’t do anything. It did make me wonder if it is possible to instead add a stop condition in my first component?

Edit: I think that that is the core of the main issue: when keySeq2_1 ends rather then when keySeq2_2 starts.

So could you put keySeq2_1.keys as the end condition of keySeq2_1?

N.B. I haven’t tested this myself. I tend to deal with multiple response keys in code.

YES! This worked!!! Thank you so much! You are a lifesaver!

In case anyone stumbles upon this topic:

I removed the code that I mentioned in my post: it doesn’t do anything.
Don’t forget to change Stop to ‘condition’!
See the pics below for specific details:

1 Like

That’s great. I need to explore further the power of using conditions for start and stop conditions.

I have used them a lot in this experiment. When coding the strings of sounds participants listen to, I had the problem that my sounds weren’t equally long, but I did need them to be spaced apart exactly 0.08 seconds. So instead of concatenating them in Praat or something, I made “[name previous sound].getDuration() + 0.08” my start time, and added a second string to each subsequent sound.
For my six-word sequences, my start time was “soundSeq6_1.getDuration() + 0.08 + soundSeq6_2.getDuration() + 0.08 + soundSeq6_3.getDuration() + 0.08 + soundSeq6_4.getDuration() + 0.08 + soundSeq6_5.getDuration() + 0.08”, which is incredibly long, but does get the job done.

If you want to do this online, add a start condition to every keyboard component that consists of the previous keyboard component. Otherwise Pavlovia will only register one key.