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 = 40 # 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 % len(jpgs)])
- if x % 2 == 0:
- question.append(jpgs[-x % len(jpgs)])
- sameobject.append(0)
- else:
- question.append(jpgs[x % len(jpgs)])
- 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
- ### Are things as wanted?
- samewished = (together[:,3])
- check = (samewished=='1')*1
- samedisplayed = (together[:,0] == together[:,1])*1
- print(check) # Did we want them identical?
- print(samedisplayed) # Were they displayed identical?
- print((samedisplayed==check)*1) # Do the two correspond?
- print'Errors: ',sum((check!=samedisplayed)*1) # How many errors were spotted?
Advertisement
Add Comment
Please, Sign In to add comment