| Reference | Downloads | Github

Two-back test with audio stimuli

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2021.1.4
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?:

I’m trying to implement a passive listening task in which participants will listen to 400 auditory stimuli in a randomized order. I want that every 50 trials a two-back test is presented to the participants with a text component displaying "Was this word presented two trials ago? Press “M” if yes or press “Z” if not. The stimulus presented in this case should be either the actual two-back trial stimulus or a stimulus presented way earlier (say 25 trials earlier). If this could be randomized, it would be great but it wouldn’t be a great issue if this was fixed (i.e., if at trial 50, there would be the correct two-back stimulus, at trial 100 it presents a 25-back stimulus, etc.).

I don’t need any feedback or any break in between, I just want that every 50 trials the two-back test occurs.

What did you try to make it work?:
Since I’m inexperienced with Psychopy, I looked for related threads in here but no one seemed to be looking for the same things as I am.

I created a loop called “pas_list” with three routines inside: one with a fixation cross (i.e., a polygon component), the next routine with the sound component and the last routine one with a code component with the following scripts:

(Begin experiment tab) # Set a junk value for the first trial, as by definition we can't have a one-back value there:
two_back = 'Not applicable'
(Begin routine tab)# set whatever keypress values are appropriate for this trial:
if stims_famaud == two_back: #stims_famaud is the name of the variable in the .csv sheet whcih reports all the relative directory to the folder with the audio stimuli
    correct_response = 'm'
    correct_response = 'z' 
(End routine tab) # update the one-back value for the *next* trial:
two_back = stims_famaud 

in this last routine I put a text component with the question, a sound component with the $stims_famaud variable and a keyboard response component to which I linked the variable correctAns of the condition .csv sheet.

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

The n-back test is presented at every trial with the stimulus that was presented right before (i.e., one-back instead of two-back). I reckon that I’m missing in the code component of the last routine something that counts the trials and specifies that every 50 trials the two-back test should occur but I don’t know how to program it :frowning:

Thanks in advance!

Try having 2 routines, one to show the stimulus and one with the Nback question then put a loop around the question routine like this:

Screenshot 2021-05-12 155552

Then in the trial routine add a code component, in the Begin Experiment tab add:

trialCount = 0

In the Begin Routine tab type:

trialCount += 1

thisShow = 0
if trialCount == 50:
    thisShow = 1

then in your inner loop use thisShow as the value for nReps

This will show that routine only on trial 50

Thank you very much Becca for your time!

I have followed your suggestion and it does show the n-back question (actually it’s a one-back and not a two-back as I’d like) after the first 50 trials but then it doesn’t show it any more. Could it be related to

if trialCount == 50
    thisShow = 1


Plus, I was wondering whether it was possible to make the code take an earlier trial in the n-back test. I’d like to do this to avoid that the participants have always to answer “yes” to the question.

Thank you a lot again!

if you want to present the question on a set number of trials, rather than just the 50th, use:

trialCount += 1

thisShow = 0
trialList = [50, 20, 80]
if trialCount in trialList:
    thisShow = 1

This example would show the question on trial 50, 20 and 80

Is that what you are trying to achieve?

Perfect, it’s showing the questions when I want them now!

There are still two issues:

  1. In the n-back test it plays the last stimulus presented not the second-last;
  2. Would it possible to tell the code to either pick the second-last stimulus or one that was presented way earlier (i.e., 25 stimuli before)?

Thanks for your help, really appreciate that!

What you could do is append the stimuli to a list as they appear. 2 back would then be stimuliList[-2].

This would work with 25 back so long as the list is long enough already.

Thank you both for your help! It worked!