Guest User

Untitled

a guest
Jun 3rd, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. # Generated by OpenSesame 0.27.2 (Frisky Freud)
  2. # Mon Jun 3 22:31:50 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 loop block_loop
  23. set repeat "1"
  24. set description "A single block of trials"
  25. set item "trial_sequence"
  26. set column_order ""
  27. set cycles "5"
  28. set order "random"
  29. run trial_sequence
  30.  
  31. define keyboard_response keyboard_response
  32.  
  33. define inline_script read_tables
  34. set _run ""
  35. ___prepare__
  36. # Read the lists of the 40 rhyming pairs and the 60
  37. # non-rhyming pairs from two separate .csv files.
  38.  
  39. # Specify the paths to the files containing the pairs
  40. # by using the built-in OpenSesame function exp.get_file.
  41. # For more info, see:
  42. # http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.get_file
  43. path_rhymes = exp.get_file("rhyme_pairs.csv")
  44. path_non_rhymes = exp.get_file("non_rhyme_pairs.csv")
  45. # We'll use the built-in Python module numpy to read our .csv file:
  46. # Import the module:
  47. import numpy as np
  48.  
  49. # And load the text file.
  50. # For more info, see:
  51. # http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html
  52. list_rhymes = np.loadtxt(path_rhymes, dtype = str)
  53. list_non_rhymes = np.loadtxt(path_non_rhymes, dtype = str)
  54.  
  55. # Make the two lists global for future use:
  56. global list_rhymes, list_non_rhymes
  57. __end__
  58. set description "Executes Python code"
  59.  
  60. define sequence trial_sequence
  61. set flush_keyboard "yes"
  62. set description "Runs a number of items in sequence"
  63. run inline_script "always"
  64. run sketchpad "always"
  65. run keyboard_response "always"
  66. run logger "always"
  67.  
  68. define loop experimental_loop
  69. set repeat "1"
  70. set description "A loop containing one or more experimental blocks"
  71. set item "block_sequence"
  72. set column_order ""
  73. set cycles "1"
  74. set order "random"
  75. run block_sequence
  76.  
  77. define sequence experiment
  78. set flush_keyboard "yes"
  79. set description "The main sequence of the experiment"
  80. run read_tables "always"
  81. run experimental_loop "always"
  82.  
  83. define inline_script block_list
  84. set _run ""
  85. ___prepare__
  86. # Randomise the from-the-csv-files-read lists
  87. # and draw two samples containing the necessary numbers of
  88. # rhymes and non-rhymes, respectively.
  89.  
  90. # First, we randomise the lists using the function random.shuffle() from
  91. # the built-in Python module random:
  92. # For more info, see:
  93. # http://docs.python.org/2/library/random.html#random.shuffle
  94.  
  95. import random
  96. random.shuffle(list_rhymes)
  97. random.shuffle(list_non_rhymes)
  98.  
  99. # We use the function random.sample()t to obtain two lists containing a convenient
  100. # number of rhyme-pairs and non-rhyme pairs.
  101.  
  102. # The number of pairs per list list is equal to half of the
  103. # number of pairs in the original list (i.e. 20 rhyme-pairs and
  104. # 30 non-rhyme-pairs).
  105.  
  106. # For more info, see:
  107. # http://docs.python.org/2/library/random.html#random.sample
  108.  
  109. samples_rhymes = random.sample(list_rhymes,len(list_rhymes)/2)
  110. samples_non_rhymes = random.sample(list_non_rhymes,len(list_non_rhymes)/2)
  111.  
  112. # Next, we merge the two lists to obtain one block list:
  113. block_list = samples_rhymes + samples_non_rhymes
  114.  
  115. # Shuffle the new list:
  116. random.shuffle(block_list)
  117.  
  118. # Finally, we make the block_list global for future use:
  119. global block_list
  120. __end__
  121. set description "Executes Python code"
  122.  
  123. define logger logger
  124.  
  125. define inline_script inline_script
  126. set _run ""
  127. ___prepare__
  128. # Determine the word pair of the current trial by drawing one word
  129. # pair from the previously-defined block list.
  130.  
  131. # To avoid that some pairs are shown twice, and others never, we draw
  132. # the pairs without replacement by using the built-in Python function
  133. # pop():
  134. # For more info, see:
  135. # http://docs.python.org/2/tutorial/datastructures.html
  136. stim_pair = block_list.pop()
  137. print stim_pair
  138. # The pair is separated by a comma (because they come from a .csv
  139. # file). We split them by using the built-in Python function split():
  140. # For more info, see:
  141. # http://docs.python.org/2/library/stdtypes.html#str.split
  142. word1, word2 = stim_pair.split(",")
  143.  
  144. # Finally, to make the variables word1 and word2 available in the GUI
  145. # (e.g. a sketchpad item), we use the built-in OpenSesame function
  146. # exp.set():
  147.  
  148. # Now, we can use the square-bracket method to display the values of those
  149. # two variables in the sketchphad item.
  150. # For more info, see:
  151. # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/
  152.  
  153. exp.set("word1", word1)
  154. exp.set("word2", word2)
  155. __end__
  156. set description "Executes Python code"
  157.  
  158. define sketchpad sketchpad
  159. set duration "0"
  160. set description "Displays stimuli"
  161. draw textline -288.0 0.0 "[word1]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
  162. draw textline 192.0 0.0 "[word2]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
  163.  
  164. define sequence block_sequence
  165. set flush_keyboard "yes"
  166. set description "A sequence containing a single block of trials followed by feedback to the participant"
  167. run block_list "always"
  168. run block_loop "always"
Advertisement
Add Comment
Please, Sign In to add comment