Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import numpy as np
- directory = 'H:\Code\Stims' # Where are the stim images located?
- repeats = 20 # THIS CRASHES IF EQUAL/ABOVE THE NUMBER OF STIMS/8
- # Scan dir for images
- jpgs = []
- for path, dirs, files in os.walk(directory):
- for f in files:
- if f.endswith('.jpg'):
- jpgs.append(f)
- # Shuffle up jpgs
- np.random.shuffle(jpgs)
- # Create trial for capturing number
- trial = 0
- # Create list with target and probe object, Half random, half identical
- display = []
- question = []
- sameobject = []
- position = np.repeat([0,1,2,3,4,5,6,7], repeats)
- for x in range(1,(repeats*8)+1):
- display.append(jpgs[x])
- if x % 2 == 0:
- question.append(jpgs[-x])
- sameobject.append(0)
- else:
- question.append(jpgs[x])
- sameobject.append(1)
- # Concatonate objects together
- together = np.c_[display,question,position,sameobject]
- np.random.shuffle(together)
- for x in together:
- # Shuffle and set image (should be done before display for timing???)
- np.random.shuffle(jpgs)
- myList = [i for i in jpgs if i != together[trial,0]]
- myList = [i for i in myList if i != together[trial,1]]
- # Set correct image for target
- myList[int(together[trial,2])] = together[trial,0]
- print(myList[0:7])
- trial += 1
Advertisement
Add Comment
Please, Sign In to add comment