Advertisement
smathot

Untitled

Dec 18th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from psychopy import core, visual, event
  3. import numpy as np
  4.  
  5. # Main constants
  6.  
  7. brightness = .3 # brightness between 0 and 1
  8. res = 1280, 960
  9. nX = 44
  10. nY = 33
  11. bgOri = 0
  12. targetOri = 45
  13. distOri = 90
  14. targetPos = range(33, 35), range(5, 15)
  15. distPos = range(23, 24), range(2, 20)
  16.  
  17. w = res[0] / nX
  18. h = res[0] / nY
  19. dx = w/2
  20. dy = h/2
  21.  
  22. x = np.linspace(0, 4*np.pi, 256) # Create a linspace as input for sin
  23. tex = np.cos([x]) # A sine between 1 and -1
  24. tex = tex * brightness - (1-brightness) # Adjust the texture brightness
  25.  
  26. myWin = visual.Window(res, units='pix', color=(-1+brightness))
  27. bgStim = visual.GratingStim(myWin, size=(w,h), tex=tex, mask='gauss', ori=bgOri)
  28. targetStim = visual.GratingStim(myWin, size=(w,h), tex=tex, mask='gauss', ori= \
  29.     targetOri)
  30. distStim = visual.GratingStim(myWin, size=(w,h), tex=tex, mask='gauss', ori= \
  31.     distOri)
  32.  
  33. for i in range(nX):
  34.     for j in range(nY):
  35.         x = (w*i + dx) - res[0]/2
  36.         y = res[1]/2 - (h*j + dy)
  37.         if i in targetPos[0] and j in targetPos[1]:
  38.             print 'Target at %d, %d / %d, %d' % (i, j, x, y)
  39.             patch = targetStim
  40.         elif i in distPos[0] and j in distPos[1]:
  41.             print 'Distractor at %d, %d / %d, %d' % (i, j, x, y)
  42.             patch = distStim
  43.         else:
  44.             patch = bgStim
  45.         patch.setPos( (x, y) )
  46.         patch.draw()
  47.  
  48. myWin.flip()
  49. print 'Done!'
  50. raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement