simondp

Untitled

Jul 13th, 2018
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. import os
  2. import numpy as np
  3.  
  4. directory = 'H:\Code\Stims' # Where are the stim images located?
  5. repeats = 20 # THIS CRASHES IF EQUAL/ABOVE THE NUMBER OF STIMS/8
  6.  
  7. # Scan dir for images
  8. jpgs = []
  9.  
  10. for path, dirs, files in os.walk(directory):
  11.     for f in files:
  12.         if f.endswith('.jpg'):
  13.             jpgs.append(f)
  14.  
  15. # Shuffle up jpgs
  16. np.random.shuffle(jpgs)
  17.  
  18.  
  19. # Create trial for capturing number
  20. trial = 0
  21.  
  22. # Create list with target and probe object, Half random, half identical
  23. display = []
  24. question = []
  25. sameobject = []
  26. position = np.repeat([0,1,2,3,4,5,6,7], repeats)
  27. for x in range(1,(repeats*8)+1):
  28.     display.append(jpgs[x])
  29.     if x % 2 == 0:
  30.         question.append(jpgs[-x])
  31.         sameobject.append(0)
  32.     else:
  33.         question.append(jpgs[x])
  34.         sameobject.append(1)
  35.  
  36.        
  37. # Concatonate objects together
  38. together = np.c_[display,question,position,sameobject]
  39. np.random.shuffle(together)
  40.  
  41. for x in together:
  42.         # Shuffle and set image (should be done before display for timing???)
  43.         np.random.shuffle(jpgs)
  44.         myList = [i for i in jpgs if i != together[trial,0]]
  45.         myList = [i for i in myList if i != together[trial,1]]
  46.        
  47.         # Set correct image for target
  48.         myList[int(together[trial,2])] = together[trial,0]
  49.         print(myList[0:7])
  50.         trial += 1
Advertisement
Add Comment
Please, Sign In to add comment