Presenting one stimuli from a column

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

OS (e.g. Win10): Win11
PsychoPy version (e.g. 1.84.x):
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
I’m very new to PsychoPy and I want to recreate the Steinberg memory task in which stimuli is presented in a sequence and it’s up to the test subject to determine whether or not a test stimulus was or wasn’t a part of the original sequence. I’m using a list of English consonants (b,c,d,f,etc.) and I would like to show a random sequence of 6 of those letters. For example, when I run my experiment, I would like a random set of letters such as “d”, “l”, “t”, “p”, “n”, and “q” to show up and then move onto the test letter. When I rum my experiment, all 20 consonants show up and that is not the result that I want.

What did you try to make it work?:
Since I want the experiment to show six different letters, I duplicated the column I was using for six different variables, created new routines that would utilize each of these columns (for example, the routine “testItem2” would correspond with the “testLetter2” columns. I also implemented some code that could prevent any letters from being repeated in the sequence:

if “testletter6” == (“testletter5” or “testletter4” or “testletter3” or “testletter2” or “testletter”):
continueRoutine= False;

What specifically went wrong when you tried that?:

Letters did show up but there were two issues:
1.) I set each letter to appear for 1.2 seconds but now the letters stay on the screen for much longer (I did not change the duration)
2.) All 20 letters still show up.

Include pasted full error message if possible. “That didn’t work” is not enough information.

Hi @Muzzahmed, one option would be to have all consonants in one column of an xlsx but use the „selected rows“ field in the loop panel to select only 6 random rows. This way you could sample 6 random consonants from the loop for each trial.

How exactly would I be able to get the 6 random rows? When I use the “selected rows” field in the loop panel, the letters shown are random from the 6 I choose. For example, if I pick letters from 0:5, I’ll have “b”, “c”, “d”, “f”, “g”, “h” and while they’ll appear in a random order, I’m missing out on 14 other letters that can be shown.

You can insert a code component somewhere in front of the loop saying

random_rows = random.sample(range(20), 6)

and then, put $random_rows in the “selected rows” field. This way, every time you run this loop another 6 letters are sampled.