Giving Participants Feedback Inside Multiple Loops with Auditory Stimuli

Hello!

It has not been too long since I started using this fabulous software to design cool psychology experiments, and I have been running into some issues whilst trying to offer feedback to a participant inside my experiment.
I would be so grateful if someone could offer a word of advice on how to approach fixing this problem!

The situation is as follows:

The objective of my experiment here is to train the participants on memorizing a series of musical notes in order.

  1. Inside my ‘trial’ routine, the participant hears a sound (let’s say sound A).

  2. Then, the ‘evaluation’ routine would randomly draw a sound (let’s say sound 1) out of the pool of sound stimuli that I have, and ask if the participant if this sound matches what they heard in the ‘trial’ routine (i.e., “does sound 1 match sound A?”)
    This routine includes a keyboard component where the participant can press ‘y’ or ‘n’ as their response.

  3. I have been trying to use both builder and coder component in a way where this keyboard input is saved (let’s say evalkey) and verified to offer feedback on whether sound 1 indeed matches sound A from the ‘trial’ routine.
    This was done by using some boolean logic such as :
    “if soundA == sound1:
    if evalkey == ‘y’:
    ‘correct!’”

(Pardon the brevity, but the coding aspect does fall accordingly with declared variables).

The main issue I have been running into whilst doing so, is that, based on my observation,
the line of code : “if soundA == sound1”
is NEVER true, although I am using the same set of stimuli/data files listed as a variable inside an excel.
I was thinking this was mainly due to the fact that the loops “trialsNotes” and “evalTrials” run differently, but I was not sure.

So, I guess a more condense way to address my problem is:
Is there a way to match stimulus from ‘sequential’ and ‘randomized’ loop?

Is there a solution on how to resolve this issue?
If not, would there be an alternative method at which this task can be completed?

Thank you so much in advance, world!

The reason “if soundA == sound1” never works is most likely because they are two different sound.Sound objects and I’m not sure what property logical comparisons would even look at in that case. What you want to do is compare a specific property of each object.

I think this will work:

if soundA.sound == sound1.sound

If that fails, I would create a separate pair of variables in one of your code components that just stores the string from the excel file and compares those (i.e., does not create a sound object, just the name of the file).

I see, thank you so much!

I have tried using the “.sound” function as you’ve mentioned, but I do not think it is working :^(

I have never considered using the latter method, so thank you so much for the idea :slight_smile: !

Is there a specific way/function where I can store the specific string variable from my excel, and compare them?
Since they are from the same excel, they should be of the same string value!

So the way loops work is that they are trialHandler objects, which have properties that are filled in by the columns in the excel file that you specify, and you should be able to reference those variables directly. I think with your code you should be able to do something like this:

if thisEvalTrials.columnName == thisTrialsNotes.columnName:

where “columnName” is the name of the column in each excel file that has the relevant sound file name in it. Since the evalTrials loop is contained in the trialsNotes loop, it shouldn’t have any trouble checking both in the evalFeedback routine.

What are the columns called in your spreadsheet?

In general, if you want to check why “if A == B:” is never true then write print('Does',A,'equal',B,'?') on the previous line and check the console.

You shouldn’t need to specify the loop name (I’ve never seen it done that way). It should just be if columnName1 == columnName2:

I’ve found that a little unreliable in some nested loop situations, especially if it’s referring to the same column from two different loops (which seems like it might be in this case here).

I’ve never tried having duplicate column names in concentric loops. I just assumed it wouldn’t work.

As far as I know, the inner loop just uses the same variable name, thereby overwriting the value of that variable set by outer loop. It can lead to weird behavior if you refer to the column expecting to get the value from the outer loop instead of the inner one. However, in a case like this where the outer loop value is used in a routine that only appears before the inner loop starts, it won’t cause any issues with the stimuli parameters themselves, you just have to be very specific in how you refer to the inner loop vs. outer loop value if you want to compare them.

1 Like

Thank you for your input!
Running print('Does',A,'equal',B,'?') resulted in printing
“Does A equal A ?” so I would THINK it was indicating they were the same.

Using the .sound function to compare between trial and evaluation seemed to always print that they were equal, so I might have to abandon using such a comparison.

Now, I’ve tried applying this line of

if thisEvalTrials.columnName == thisTrialsNotes.columnName:

but it seems like it could not recognize what exactly thisEvalTrials or thisTrialsNotes were, as it printed:

if thisEvalTrials.routeA_notes == thisTrialsNotes.routeA_notes:
NameError: name 'thisEvalTrials' is not defined. Did you mean: 'thisEvalTrial'?

Here is an image from the only excel sheet that I am using to draw both stimuli.
Both sound stimuli draw their sounds from the same “routeA_notes” column.

What could be going wrong here?

Please could you show the actual result of that print statement when the sounds are the same and also when they aren’t.

Perhaps you should also print('yes!') inside the if clause just in case the error isn’t about that comparison at all.

Personally I would use a different spreadsheet for the inner loop with different column names.

1 Like

Ah, I just guessed the name of the loop instance wrong. PsychoPy does some automatic renaming that isn’t always intuitive. I think you’ll need to use thisEvalTrial and thisTrialNote (singular, not plural).