Advertisement
Guest User

Untitled

a guest
Apr 1st, 2013
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. # Generated by OpenSesame 0.27.2~pre4 (Frisky Freud)
  2. # Mon Apr 1 15:27:48 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 compensation "0"
  10. set coordinates "relative"
  11. set height "768"
  12. set mouse_backend "xpyriment"
  13. set width "1024"
  14. set sampler_backend "legacy"
  15. set keyboard_backend "legacy"
  16. set background "black"
  17. set subject_nr "0"
  18. set canvas_backend "xpyriment"
  19. set start "experiment"
  20. set synth_backend "legacy"
  21.  
  22. define inline_script determine_trial_type
  23. set _run ""
  24. ___prepare__
  25. # Determine the trial type of the current trial
  26. # by 'popping' (i.e. taking without replacement)
  27. # one item from the previously-defined trial list.
  28.  
  29. # We do this by using the built-in Python function pop():
  30. trial_type = trial_list.pop()
  31.  
  32. # Next, we should set the variable 'trial_type' to
  33. # make it available in the GUI (notably, the Run-if
  34. # boxes in the trial_sequence item).
  35.  
  36. # We do this by using the built-in OpenSesame experiment
  37. # function exp.set():
  38. exp.set("trial_type", trial_type)
  39. __end__
  40. set description "Executes Python code"
  41.  
  42. define inline_script determine_trial_order
  43. set _run ""
  44. ___prepare__
  45. # Import the built-in Python module random:
  46. import random
  47.  
  48. # Define counters:
  49. nTarget = 50
  50. nNonTarget = 250
  51.  
  52.  
  53. # Create a list containing for example 50 targets and
  54. # 250 non target:
  55. trial_list = ["target"]*nTarget+ ["non_target"]*nNonTarget
  56.  
  57. # Shuffle the list by using the random.shuffle() function:
  58. random.shuffle(trial_list)
  59.  
  60. # Check for two targets in a row:
  61.  
  62. # Give the Boolean keepRunning a starting value:
  63. keepRunning = True
  64.  
  65. # We walk through the list until our criteria are met:
  66. while keepRunning:
  67.  
  68. # Set keepRunning to False
  69. keepRunning = False
  70.  
  71. # For every item in the list, check whether this item AND the next
  72. # one are 'target' (note that we skip the very last one because
  73. # it has no following item):
  74. for i in range(len(trial_list)-1):
  75.  
  76. # If the current item and the next one are 'target':
  77. if trial_list[i] == trial_list[i+1] == "target":
  78.  
  79. # Set keepRunning to True, meaning the list doesn't meet our criteria yet:
  80. keepRunning = True
  81.  
  82. # Swap the content of the current item and the previous one:
  83. trial_list[i], trial_list[i-1] = trial_list[i-1], trial_list[i]
  84.  
  85. # And break from the current loop to walk through the list again:
  86. break
  87.  
  88. # Make the trial_list global such that it becomes available in future inline_sript
  89. # items as well:
  90. global trial_list
  91. __end__
  92. set description "Executes Python code"
  93.  
  94. define loop block_loop
  95. set repeat "1"
  96. set description "A single block of trials"
  97. set item "trial_sequence"
  98. set column_order ""
  99. set cycles "300"
  100. set order "random"
  101. run trial_sequence
  102.  
  103. define sketchpad non_target
  104. set duration "750"
  105. set description "Displays stimuli"
  106. draw rect -50 -50 100 100 fill=1 penwidth=1 color=red show_if="always"
  107.  
  108. define sequence block_sequence
  109. set flush_keyboard "yes"
  110. set description "A sequence containing a single block of trials followed by feedback to the participant"
  111. run determine_trial_order "always"
  112. run block_loop "always"
  113.  
  114. define sketchpad fixdot
  115. set duration "500"
  116. set description "Displays stimuli"
  117. set start_response_interval "no"
  118. draw fixdot 0 0 color=white show_if="always"
  119.  
  120. define sketchpad target
  121. set duration "750"
  122. set description "Displays stimuli"
  123. draw circle 0 0 143.10835056 fill=1 penwidth=1 color=blue show_if="always"
  124.  
  125. define sequence trial_sequence
  126. set flush_keyboard "yes"
  127. set description "A single trial"
  128. run determine_trial_type "always"
  129. run target "[trial_type] = target"
  130. run non_target "[trial_type] = non_target"
  131. run fixdot "always"
  132. run logger "always"
  133.  
  134. define loop experimental_loop
  135. set repeat "1"
  136. set description "A loop containing one or more experimental blocks"
  137. set item "block_sequence"
  138. set column_order "practice"
  139. set cycles "1"
  140. set order "random"
  141. setcycle 0 practice "no"
  142. run block_sequence
  143.  
  144. define sequence experiment
  145. set flush_keyboard "yes"
  146. set description "The main sequence of the experiment"
  147. run experimental_loop "always"
  148.  
  149. define logger logger
  150. set description "Logs experimental data"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement