

It's still much faster than generating a full Window/ImageStim each loop though.Īnother way to randomize the images while maintaining the pairing is something you'd probably do anyway sometime: put them together in a list of dictionaries, where each dict represents a trial. Probably between 20 and 500 ms depending mainly on image dimensions. Rather than just showing two stimuli, I've set it to loop over all stimuli. Set autodraw here since you didn't seem to change it during runtime. Targetstim = visual.ImageStim(win=win, pos=pos2, size=)ĭistractorstim = visual.ImageStim(win=win, pos=pos1, size=) # removed all default values and initiated without an image. Win = visual.Window(size=(1280, 800), fullscr=True, screen=0, monitor='testMonitor', color=) # removed a default value
#SHUFFLE PSYCHOPY UPDATE#
Think of them as containers in which you can update the content on the fly.

Target = map(target._getitem_, indices)ĭistractor = map(distractor._getitem_, indices) Indices = random.sample(range(len(target)), len(target)) # because you're using python 2 Target = glob.glob("DDtest/targetimagelist1/*")ĭistractor = glob.glob("DDtest/distractorimagelist1/*") # import two images sequences and randomize in the same order This section was simplified.įrom psychopy import visual, event, gui # gui is not used in this script
#SHUFFLE PSYCHOPY CODE#
Note that I've changed quite a bit to make the code much shorter, cleaner and faster. I particularly like the following for its syntactic simplicity randomizedItems = map(items._getitem_, indices)įor a complete working example, see code below. This question has been answered here and here. However, I would like it is shuffle the images in the same order so that both lists are displayed in the same random order. This code randomly shuffles a bunch of images and displays them. TexRes=128, interpolate=True, depth=-2.0) TexRes=128, interpolate=True, depth=-1.0) Win = visual.Window(size=(1280, 800), fullscr=True, screen=0, monitor='testMonitor', color=, colorSpace='rgb')ĭistractorstim = visual.ImageStim(win=win,Ĭolor=, colorSpace='rgb', opacity=1, So far I have tried to replace the random.shuffle function with the random.choice function, but I'm not sure if I'm going in the wrong direction.I have a question about shuffling, but first, here is my code: from psychopy import visual, event, guiĪ = glob.glob("DDtest/targetimagelist1/*")ī = glob.glob("DDtest/distractorimagelist1/*") I understand that I may need to change the way I use the random.shuffle function, however, I'm not sure if I also need to change my for loop as well to make this work. I need to do this so the frequency of the audio tones isn't the same for consecutive audio tones. However, my problem is that I need to create the new_pitch_list so there are no repetitions of 2 numbers. My code works for randomly producing an array of 256 numbers of which there are 4 possibilities (500, 625, 750, 875). #Replace 1-4 integers in new_pitch_list with frequency values New_pitch_list = np.repeat(pitch_list,64) So far I have created an array of 4 numbers representing the 4 different frequency levels for my audio tones: #Pitch list - create an array from 1 to 4 repeated for 256 stimuli

I'm trying to create an array of 256 stimuli that represents the frequency value to input into my sound stimuli.
