N-back with time reproduction

Hey everyone,

I am trying to build an experiment with the Builder and using some code components. The task is basically this: Participants will see number of stimuli for various duration and reproduce the duration n times before. For instance, they will see 3 stimuli back-to-back (various duration) and then they will be asked to reproduce the duration of the stimulus 2-back. And what I want is presenting maximum 5 stimuli back to back and ask them to reproduce the duration n-back (n=1 or n=2 or n=3) before. There should be 12 ways and I want them to occur with equal probabilities:
5 back-to-back stimuli, asking to reproduce 1-back before
5 back-to-back stimuli- asking to reproduce 2-back before
5 back-to-back stimuli- asking to reproduce 3-back before
.
.
.
What I have until now is a basic time reproduction task which is presenting stimuli for various seconds and asking them to reproduce the duration of the previous stimulus with pressing a key. I cannot think of ways to implement what I described above. I have checked the posts here about n-back tasks but couldn’t think of anything. I know this is not a question about a specific thing but I just need a suggestion, a starting point. I am very much stuck. Does anyone have a suggestion?

Thanks.

So, just to check I’ve read this right, what you want to do is:
Measure how long participants have pressed a key for, then compare this to the duration of one of the 5 stimuli previously shown to them?

Choosing the stimulus to get duration from should be fairly easy, you just need to stick the object handles together in a list like so:

backStim = [stim1, stim2, stim3, stim4, stim5] # Stick stimuli together in a list

replacing stim1, stim2, etc. with your stimulus names, and then choose one by indexing this list with a random value (you would need to add import random to the beginning of the experiment), e.g.

nBack = random.choice[0, 1, 2, 3, 4] # Choose a random value of n-back
backTarget = backStim[nBack] # Get target stim using n-back

Then you can get its duration like so:

targetDur = backTarget.Stop - backTarget.Start

I’d put all this at the beginning of your routine, so that you have targetDur to compare against later.

To get the duration the participants press the keyboard for, you would do something like this at the end of the routine:

keys = keyboard.getKeys() # Get all keypresses this trial
for key in keys: # For each keypress
   pDur = key.duration

with keyboard replaced with the name of your keyboard component. This will replace pDur each iteration of the loop, keep in mind, so will only store the last keypress. You could use a list if you wanted to store all keypress durations, but if the keypress ends the routine on release that shouldn’t be an issue.

Once you have pDur, you can compare it to targetDur - subtract them to get the difference, compare them for equal to / not equal to, test whether they’re within a set range of one another, etc.

Is this pretty much what you’re after?

1 Like

Whoops. I accidentally deleted my post but I solved the issue. Thanks again.