Advertisement
Guest User

Untitled

a guest
Aug 19th, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.34 KB | None | 0 0
  1. # Generated by OpenSesame 0.27.3 (Frisky Freud)
  2. # Mon Aug 19 13:39:04 2013 (posix)
  3. # <http://www.cogsci.nl/opensesame>
  4.  
  5. set foreground "white"
  6. set subject_parity "even"
  7. set description "A template containing a practice and an experimental phase"
  8. set title "Extended template"
  9. set coordinates "relative"
  10. set height "768"
  11. set pygame_doublebuf "yes"
  12. set width "1024"
  13. set compensation "0"
  14. set background "black"
  15. set subject_nr "0"
  16. set start "experiment"
  17.  
  18. define inline_script target_position_list
  19. set _run ""
  20. ___prepare__
  21. # Import the Python module itertools:
  22. import itertools
  23. global itertools
  24.  
  25. # Get the target lists:
  26.  
  27. # Make a list of lists containing all 16 combinations by using
  28. # the itertools.product() function:
  29. temp_list = itertools.product(x_list, y_list)
  30. target_list = []
  31.  
  32. for i in temp_list:
  33. target_list.append(i)
  34.  
  35. # Randomize the items in the list by using the shuffle() function:
  36. shuffle(target_list)
  37.  
  38. # Make the list global such that it is also available in
  39. # future inline scripts:
  40. global target_list
  41. __end__
  42. set description "Executes Python code"
  43.  
  44. define loop block_loop
  45. set repeat "16"
  46. set description "A single block of trials"
  47. set skip "0"
  48. set offset "no"
  49. set item "trial_sequence"
  50. set column_order "target_presence;display_size"
  51. set cycles "1"
  52. set order "random"
  53. setcycle 0 target_presence "present"
  54. setcycle 0 display_size "16"
  55. run trial_sequence
  56.  
  57. define text_display text_display
  58. set foreground "white"
  59. set font_size "18"
  60. set description "Presents a display consisting of text"
  61. set maxchar "50"
  62. set align "center"
  63. set content "Look for the red circle."
  64. set background "black"
  65. set duration "keypress"
  66. set font_family "mono"
  67.  
  68. define inline_script objects
  69. ___run__
  70. # Show the canvas:
  71.  
  72. my_canvas.show()
  73. self.sleep(0)
  74. __end__
  75. ___prepare__
  76. """
  77. DESCRIPTION:
  78. Prepare canvas.
  79.  
  80. If block = feature:
  81. If dist_type = shape: dist = red squaretion
  82. If dist_type = color: dist = green circle
  83. If dist_type = color: dist = green circle
  84.  
  85. TODO:
  86. Make SURE conjunction is conjunction!!
  87. """
  88.  
  89. # Import modules:
  90. from openexp.canvas import canvas
  91. from random import choice, shuffle
  92.  
  93. # Make a canvas:
  94. # See also:
  95. # http://osdoc.cogsci.nl/python-inline-code/canvas-functions/
  96.  
  97. global my_canvas
  98. my_canvas = canvas(self.experiment)
  99.  
  100.  
  101. # Make a list for the distractor positions:
  102.  
  103. # Make a list of lists containing all 16 combinations by using
  104. # the itertools.product() function:
  105. temp_list = itertools.product(x_list, y_list)
  106. dist_list = []
  107.  
  108. for i in temp_list:
  109. dist_list.append(i)
  110. shuffle(dist_list)
  111.  
  112. # Determine the traget position by using the pop() function.
  113. # ('Popping' indicates drawing an item without replacing it.)
  114.  
  115. target_pos = target_list.pop()
  116.  
  117. # Now remove this position from the distractor list (because
  118. # we don't want to accidently superimpose a distractor
  119. # on the target.
  120. dist_list.remove(target_pos)
  121.  
  122. # Determine the distractor type:
  123. dist_type = choice(dist_types)
  124.  
  125. # Draw the target to the canvas:
  126. x_target = target_pos[0]
  127. y_target = target_pos[1]
  128. my_canvas.circle(x_target,y_target, r, color = "red", fill = True)
  129.  
  130. # Draw the distractors to the canvas:
  131.  
  132. for i in range(0, 15):
  133.  
  134. # Keep removing the used positions so that two distractors will never overlap:
  135. dist_pos = dist_list.pop()
  136. x_dist = dist_pos[0]
  137. y_dist = dist_pos[1]
  138.  
  139. # If search task is conjunction, determine distractor type separately for
  140. # for every distractor.
  141. if self.get("search_task") == "conjunction":
  142. dist_type = choice(dist_types)
  143.  
  144. # Determine the properties of the to-be-drawn distractor:
  145. if dist_type == "color":
  146. my_canvas.circle(x_dist,y_dist,r, color = "green", fill = True)
  147. else:
  148. my_canvas.rect(x_dist-w/2,y_dist-w/2, w, h, color = "red", fill = True)
  149. __end__
  150. set description "Executes Python code"
  151.  
  152. define sketchpad red
  153. set duration "500"
  154. set description "Displays stimuli"
  155. set start_response_interval "no"
  156. draw fixdot 0 0 color=red show_if="always"
  157.  
  158. define sequence trial_sequence
  159. set flush_keyboard "yes"
  160. set description "A single trial"
  161. run sketchpad "always"
  162. run objects "always"
  163. run keyboard_response "always"
  164. run green "[correct]=1"
  165. run red "[correct]=0"
  166. run logger "always"
  167.  
  168. define sketchpad sketchpad
  169. set duration "1000"
  170. set description "Displays stimuli"
  171. set start_response_interval "no"
  172. draw fixdot 0 0 color=white show_if="always"
  173.  
  174. define sequence experiment
  175. set flush_keyboard "yes"
  176. set description "The main sequence of the experiment"
  177. run constants "always"
  178. run text_display "always"
  179. run experimental_loop "always"
  180.  
  181. define sketchpad green
  182. set duration "500"
  183. set description "Displays stimuli"
  184. set start_response_interval "no"
  185. draw fixdot 0 0 color=green show_if="always"
  186.  
  187. define loop experimental_loop
  188. set repeat "1"
  189. set description "A loop containing one or more experimental blocks"
  190. set skip "0"
  191. set offset "no"
  192. set item "block_sequence"
  193. set column_order "search_task"
  194. set cycles "2"
  195. set order "random"
  196. setcycle 0 search_task "feature"
  197. setcycle 1 search_task "conjunction"
  198. run block_sequence
  199.  
  200. define keyboard_response keyboard_response
  201. set description "Collects keyboard responses"
  202. set timeout "infinite"
  203. set flush "yes"
  204.  
  205. define logger logger
  206. set description "Logs experimental data"
  207.  
  208. define sequence block_sequence
  209. set flush_keyboard "yes"
  210. set description "A sequence containing a single block of trials followed by feedback to the participant"
  211. run target_position_list "always"
  212. run reset_feedback "always"
  213. run block_loop "always"
  214.  
  215. define inline_script constants
  216. set _run ""
  217. ___prepare__
  218. """
  219. Define constants.
  220. """
  221.  
  222. # Import modules
  223. import numpy as np
  224. from random import shuffle
  225.  
  226.  
  227. xCen = self.get("width")/2
  228. yCen = self.get("height")/2
  229.  
  230. w = 80
  231. h = w
  232. r = 40
  233.  
  234. # Determine distance such that objects will not fall out of screen
  235. dist = w+(w/2)
  236.  
  237. x_list = np.linspace(0+dist,self.get("width")-dist,4).tolist()
  238. y_list = np.linspace(0+dist, self.get("height")-dist,4).tolist()
  239.  
  240. dist_types = ["shape", "color"]
  241.  
  242. # Make all variables that we need in subsequent inline scripts global
  243. global xCen, yCen, x_list, y_list, dist_types, w, h, r
  244. __end__
  245. set description "Executes Python code"
  246.  
  247. define reset_feedback reset_feedback
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement