Advertisement
LeeB_86

BK_PM

Oct 18th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 16.20 KB | None | 0 0
  1. # Generated by OpenSesame 0.27.4 (Frisky Freud)
  2. # Fri Oct 18 20:39:38 2013 (nt)
  3. # <http://www.cogsci.nl/opensesame>
  4.  
  5. set foreground "#ffffff"
  6. set subject_parity "even"
  7. set font_size "60"
  8. set description "Default description"
  9. set title "bk_new_pm_exp"
  10. set transparent_variables "no"
  11. set font_bold "yes"
  12. set coordinates "relative"
  13. set height "1080"
  14. set mouse_backend "xpyriment"
  15. set width "1920"
  16. set compensation "0"
  17. set sampler_backend "legacy"
  18. set font_italic "no"
  19. set background "#000000"
  20. set subject_nr "0"
  21. set keyboard_backend "legacy"
  22. set start "experiment"
  23. set font_family "sans"
  24. set synth_backend "legacy"
  25. set canvas_backend "xpyriment"
  26.  
  27. define loop s1_block_loop
  28.     set repeat "1"
  29.     set description "Repeatedly runs another item"
  30.     set skip "0"
  31.     set item "s1_trial_sequence"
  32.     set column_order "cue"
  33.     set cycles "24"
  34.     set order "sequential"
  35.     setcycle 0 cue ""
  36.     setcycle 1 cue ""
  37.     setcycle 2 cue ""
  38.     setcycle 3 cue ""
  39.     setcycle 4 cue ""
  40.     setcycle 5 cue ""
  41.     setcycle 6 cue ""
  42.     setcycle 7 cue ""
  43.     setcycle 8 cue ""
  44.     setcycle 9 cue ""
  45.     setcycle 10 cue ""
  46.     setcycle 11 cue ""
  47.     setcycle 12 cue ""
  48.     setcycle 13 cue ""
  49.     setcycle 14 cue ""
  50.     setcycle 15 cue ""
  51.     setcycle 16 cue ""
  52.     setcycle 17 cue ""
  53.     setcycle 18 cue ""
  54.     setcycle 19 cue ""
  55.     setcycle 20 cue ""
  56.     setcycle 21 cue ""
  57.     setcycle 22 cue ""
  58.     setcycle 23 cue "Mouse"
  59.     run s1_trial_sequence
  60.  
  61. define sequence sequence
  62.     run question_word "always"
  63.     run blank "always"
  64.  
  65. define parallel _parallel
  66.     run s_keyboard_response "always"
  67.     run _sequence "always"
  68.  
  69. define sequence _sequence
  70.     run question_word "always"
  71.     run blank "always"
  72.  
  73. define sequence p_trial_sequence
  74.     set flush_keyboard "yes"
  75.     set description "Runs a number of items in sequence"
  76.     run p_ongoing_script "always"
  77.     run p_response_script "always"
  78.     run fixation_dot "always"
  79.     run question "always"
  80.     run parallel "always"
  81.     run logger "always"
  82.  
  83. define sequence s1_trial_sequence
  84.     set flush_keyboard "yes"
  85.     set description "Runs a number of items in sequence"
  86.     run s1_ongoing_script "always"
  87.     run s1_response_script "always"
  88.     run fixation_dot "always"
  89.     run question "always"
  90.     run _parallel "always"
  91.     run logger "always"
  92.  
  93. define sequence s1_sequence
  94.     set flush_keyboard "yes"
  95.     set description "Runs a number of items in sequence"
  96.     run s1_ongoing_list "always"
  97.     run s1_block_loop "always"
  98.  
  99. define sketchpad blank
  100.     set duration "1400"
  101.     set description "Displays stimuli"
  102.  
  103. define inline_script p_response_script
  104.     set _run ""
  105.     ___prepare__
  106.     # For the ongoing task.
  107.    
  108.     # Set the variable 'correct_response':
  109.     exp.set('correct_response', None)
  110.    
  111.     # Define correct/incorrect responses:
  112.     correct = 'l'
  113.     incorrect = 'a'
  114.    
  115.     # State what constitutes a correct response for each question:
  116.     if stim_word in one:
  117.         exp.set('correct_response', correct)
  118.     if stim_word in n_one:
  119.         exp.set('correct_response', incorrect)
  120.     if stim_word in ee:
  121.         exp.set('correct_response', correct)
  122.     if stim_word in n_ee:
  123.         exp.set('correct_response', incorrect)
  124.     if stim_word in wiw:
  125.         exp.set('correct_response', correct)
  126.     if stim_word in n_wiw:
  127.         exp.set('correct_response', incorrect)
  128.        
  129.     # Determine correct ongoing keyboard response:
  130.     if self.get('correct_response') == 'l':
  131.         correct_keyboard_response_1 = 'l'
  132.     else:
  133.         correct_keyboard_response_1 = 'a'
  134.    
  135.     # Set the correct response for the ongoing task and PM cue by giving the variables
  136.     # 'correct_ongoing_response' and 'correct_cue_response' values:
  137.     exp.set("correct_ongoing_response", correct_keyboard_response_1)
  138.     __end__
  139.     set description "Executes Python code"
  140.  
  141. define inline_script s1_ongoing_script
  142.     set _run ""
  143.     ___prepare__
  144.     # Import the module 'numpy':
  145.     import numpy as np
  146.    
  147.     # Set variable 'question' for use in the GUI (e.g. can be accessed in a sketchpad):
  148.     exp.set('question', None)
  149.    
  150.     # To avoid that some words are shown twice, and others never, we draw the
  151.     # words without replacement by using the built-in Python function pop():
  152.     # For more info, see: http://docs.python.org/2/tutorial/datastructures.html
  153.     stim_word = s1_twl.pop()
  154.    
  155.     # Define task questions:
  156.     q1 = "1 Syllable?"
  157.     q2 = "Long 'EE' sound?"
  158.     q3 = "Word in word?"
  159.    
  160.     # Define word lists relevant to each question:
  161.     one = ["Dad", "Found", "Deep", "Set"] # 'Correct' words...
  162.     n_one = ["Lever", "Police", "Competed", "Idea"] # 'Non-correct' words...
  163.     ee = ["Envy", "Key", "Misery", "Minister"]
  164.     n_ee = ["Extra", "Major", "North"]
  165.     wiw = ["Feel", "Start", "Peace", "President"]
  166.     n_wiw = ["Bank", "Tea", "Ear", "Heaven"]
  167.    
  168.     # Now connect each question with the random word produced:
  169.     if stim_word in one:
  170.         exp.set('question', q1)
  171.     if stim_word in n_one:
  172.         exp.set('question', q1)
  173.     if stim_word in ee:
  174.         exp.set('question', q2)
  175.     if stim_word in n_ee:
  176.         exp.set('question', q2)
  177.     if stim_word in wiw:
  178.         exp.set('question', q3)
  179.     if stim_word in n_wiw:
  180.         exp.set('question', q3)
  181.    
  182.     # Connect the session cue with the correct question:
  183.     if stim_word == "Mouse":
  184.         exp.set('question', q2)
  185.        
  186.     # Set the variable 'stim_word' to be available in the GUI (e.g. can be accessed in a sketchpad):
  187.     exp.set('stim_word', stim_word)
  188.     __end__
  189.     set description "Executes Python code"
  190.  
  191. define loop s1
  192.     set repeat "1"
  193.     set description "Repeatedly runs another item"
  194.     set item "s1_sequence"
  195.     set column_order ""
  196.     set cycles "1"
  197.     set order "random"
  198.     run s1_sequence
  199.  
  200. define sketchpad question
  201.     set duration "1000"
  202.     set description "Displays stimuli"
  203.     draw textline 0 -128 "[question]" center=1 color=#ffffff font_family="mono" font_size=60 font_italic=no font_bold=yes show_if="always" html="yes"
  204.  
  205. define text_display experiment_instructions
  206.     set foreground "#ffffff"
  207.     set font_size "20"
  208.     set description "Presents a display consisting of text"
  209.     set maxchar "200"
  210.     set align "center"
  211.     __content__
  212.     You will see a series of words one at a time
  213.     For each word you will be asked to respond to a question
  214.    
  215.     Press the 'L' key if your answer is YES
  216.     Press the 'A' key if your answer is NO
  217.    
  218.     As you look at the screen a an asterisk will appear in the centre
  219.     This will be replaced by the cue for each question
  220.     A different word will appear below the cue each time
  221.     Press the appropriate key to record your answer
  222.     There will be a blank screen before the next sequence begins, starting with *
  223.    
  224.     Please press the space bar when you are ready to begin
  225.     __end__
  226.     set background "#000000"
  227.     set duration "keypress"
  228.     set font_family "sans"
  229.  
  230. define sequence experiment
  231.     run experiment_instructions "always"
  232.     run practice "always"
  233.     run text_display "always"
  234.     run s1 "always"
  235.  
  236. define sketchpad fixation_dot
  237.     set duration "1400"
  238.     set description "Displays stimuli"
  239.     draw textline 0 -128 "*" center=1 color=#ffffff font_family="sans" font_size=60 font_italic=no font_bold=yes show_if="always" html="yes"
  240.  
  241. define logger logger
  242.     set ignore_missing "yes"
  243.     set description "Logs experimental data"
  244.     set auto_log "no"
  245.     set use_quotes "yes"
  246.     log "cue"
  247.     log "subject_nr"
  248.     log "correct_1"
  249.     log "keyboard_response_1"
  250.     log "keyboard_response_time_1"
  251.     log "question"
  252.     log "stim_word"
  253.     log "correct_ongoing_response"
  254.     log "correct_cue_response"
  255.     log "pm_correct_response"
  256.     log "correct_2"
  257.     log "keyboard_response_2"
  258.     log "keyboard_response_time_2"
  259.  
  260. define inline_script s_keyboard_response
  261.     ___run__
  262.     from openexp.keyboard import keyboard
  263.    
  264.     # The keypress timeout
  265.     timeout = 2600
  266.    
  267.     # Poll for responses. First, 'keyboard_response_1' waits for an 'A' or an 'L'.
  268.     # Second, 'keyboard_response_2' waits for a '1':
  269.     exp.set('keyboard_response_1', None)
  270.     exp.set('keyboard_response_time_1', None)
  271.     keylist_1 = ['a', 'l']
  272.     exp.set('keyboard_response_2', None)
  273.     exp.set('keyboard_response_time_2', None)
  274.     keylist_2 = ['1']
  275.    
  276.     # Create a keyboard object that doesn't block the experiment, so we can use it to poll for
  277.     # keypresses continuously:
  278.     my_keyboard = keyboard(exp, timeout=0)
  279.    
  280.     # Loop until we timeout:
  281.     start_time = self.time()
  282.     while self.time() - timeout < start_time:
  283.         key, key_time = my_keyboard.get_key()
  284.    
  285.     # If a key from keylist 1 is pressed, set keyboard_response_1 and keyboard_response_time_1.
  286.     # Also, set key_list_1 to [], so that we do not capture multiple keypresses from this list:
  287.     if key in keylist_1:
  288.         exp.set('keyboard_response_1', key)
  289.         exp.set('keyboard_response_time_1', key_time - start_time)
  290.         keylist_1 = []
  291.    
  292.     # If a key from keylist 2 is pressed, set keyboard_response_2 and keyboard_response_time_2.
  293.     # Also, set key_list_2 to [], so that we do not capture multiple keypresses from this list:
  294.     if key in keylist_2:
  295.         exp.set('keyboard_response_2', key)
  296.         exp.set('keyboard_response_time_2', key_time - start_time)
  297.         keylist_2 = []
  298.    
  299.     # Create a variable to check the first key response against the expected response:
  300.     if self.get('keyboard_response_1') == self.get('correct_ongoing_response'):
  301.         correct_1 = '1'
  302.     else:
  303.         correct_1 = '0'
  304.     exp.set("correct_1", correct_1)
  305.    
  306.     # Create a variable to check the second key response against the expected response:
  307.     if self.get('keyboard_response_2') == self.get('correct_cue_response'):
  308.         correct_2 = '1'
  309.     else:
  310.         correct_2 = '0'
  311.     exp.set("correct_2", correct_2)
  312.     __end__
  313.     set _prepare ""
  314.     set description "Executes Python code"
  315.  
  316. define loop p_block_loop
  317.     set repeat "1"
  318.     set description "Repeatedly runs another item"
  319.     set skip "0"
  320.     set item "p_trial_sequence"
  321.     set column_order ""
  322.     set cycles "12"
  323.     set order "sequential"
  324.     run p_trial_sequence
  325.  
  326. define inline_script p_keyboard_response
  327.     ___run__
  328.     from openexp.keyboard import keyboard
  329.    
  330.     # The keypress timeout
  331.     timeout = 2600
  332.    
  333.     # Poll for responses. 'keyboard_response_1' waits for an 'A' or an 'L':
  334.     exp.set('keyboard_response_1', None)
  335.     exp.set('keyboard_response_time_1', None)
  336.     keylist_1 = ['a', 'l']
  337.    
  338.     # Create a keyboard object that doesn't block the experiment, so we can use it to poll for
  339.     # keypresses continuously:
  340.     my_keyboard = keyboard(exp, timeout=0)
  341.    
  342.     # Loop until we timeout:
  343.     start_time = self.time()
  344.     while self.time() - timeout < start_time:
  345.         key, key_time = my_keyboard.get_key()
  346.            
  347.     # If a key from keylist 1 is pressed, set keyboard_response_1 and keyboard_response_time_1.
  348.     # Also, set key_list_1 to [], so that we do not capture multiple keypresses from this list:
  349.     if key in keylist_1:
  350.         exp.set('keyboard_response_1', key)
  351.         exp.set('keyboard_response_time_1', key_time - start_time)
  352.         keylist_1 = []
  353.    
  354.     # Create a variable to check the key response against the expected response:
  355.     if self.get('keyboard_response_1') == self.get('correct_ongoing_response'):
  356.         correct_1 = '1'
  357.     else:
  358.         correct_1 = '0'
  359.     exp.set("correct_1", correct_1)
  360.     __end__
  361.     set _prepare ""
  362.     set description "Executes Python code"
  363.  
  364. define inline_script s1_ongoing_list
  365.     set _run ""
  366.     ___prepare__
  367.     # Import the module 'Random':
  368.     import random as rdm
  369.    
  370.     # Define trial word list:
  371.     twl = ["Dad", "Found", "Deep", "Set", "Lever", "Police", "Competed", "Idea", \
  372.     "Extra", "Envy", "Key", "Misery", "Major", "North", "Minister", \
  373.     "Feel", "Start", "Peace", "President", "Bank", "Tea", "Ear", "Heaven"]
  374.    
  375.     # Shuffle list order.
  376.     rdm.shuffle(twl)
  377.    
  378.     # Define PM cue word:
  379.     cue = ["Mouse"]
  380.    
  381.     # Add twl list to cue:
  382.     s1_twl = cue + twl
  383.     #   Note: it is VERY important that the cue be first in the expression 'cue + twl'.
  384.     #   'twl + cue' will make the cue appear FIRST in the experimental session!
  385.    
  386.     # Make list 's1_twl' global for future use:
  387.     global s1_twl
  388.     __end__
  389.     set description "Executes Python code"
  390.  
  391. define loop practice
  392.     set repeat "1"
  393.     set description "Repeatedly runs another item"
  394.     set skip "0"
  395.     set item "p_sequence"
  396.     set column_order ""
  397.     set cycles "1"
  398.     set order "sequential"
  399.     run p_sequence
  400.  
  401. define inline_script s1_response_script
  402.     set _run ""
  403.     ___prepare__
  404.     # For the ongoing task.
  405.    
  406.     # Set the variable 'correct_response':
  407.     exp.set('correct_response', None)
  408.    
  409.     # Define correct/incorrect responses:
  410.     correct = 'l'
  411.     incorrect = 'a'
  412.    
  413.     # State what constitutes a correct response for each question:
  414.     if stim_word in one:
  415.         exp.set('correct_response', correct)
  416.     if stim_word in n_one:
  417.         exp.set('correct_response', incorrect)
  418.     if stim_word in ee:
  419.         exp.set('correct_response', correct)
  420.     if stim_word in n_ee:
  421.         exp.set('correct_response', incorrect)
  422.     if stim_word in wiw:
  423.         exp.set('correct_response', correct)
  424.     if stim_word in n_wiw:
  425.         exp.set('correct_response', incorrect)
  426.        
  427.     # Determine correct ongoing keyboard response:
  428.     if self.get('correct_response') == 'l':
  429.         correct_keyboard_response_1 = 'l'
  430.     else:
  431.         correct_keyboard_response_1 = 'a'
  432.    
  433.     # Set the correct response for the ongoing task and PM cue by giving the variables
  434.     # 'correct_ongoing_response' and 'correct_cue_response' values:
  435.     exp.set("correct_ongoing_response", correct_keyboard_response_1)
  436.    
  437.     # For the PM cue:
  438.    
  439.     # Set the variable 'pm_correct_response':
  440.     exp.set('pm_correct_response', None)
  441.    
  442.     # Define PM correct response:
  443.     pm_cue = '1'
  444.    
  445.     # State what constitutes a correct cue response:
  446.     if stim_word == "Mouse":
  447.         exp.set('pm_correct_response', pm_cue)
  448.    
  449.     # Determine correct ongoing keyboard response:
  450.     if self.get('pm_correct_response') == '1':
  451.         correct_keyboard_response_2 = '1'
  452.     else:
  453.         correct_keyboard_response_2 = ''
  454.    
  455.     # Set the correct response for the ongoing task and PM cue by giving the variables
  456.     # 'correct_ongoing_response' and 'correct_cue_response' values:
  457.     exp.set("correct_cue_response", correct_keyboard_response_2)
  458.     __end__
  459.     set description "Executes Python code"
  460.  
  461. define inline_script p_ongoing_script
  462.     set _run ""
  463.     ___prepare__
  464.     # Import the module 'numpy':
  465.     import numpy as np
  466.    
  467.     # Set variable 'question' for use in the GUI (e.g. can be accessed in a sketchpad):
  468.     exp.set('question', None)
  469.    
  470.     # To avoid that some words are shown twice, and others never, we draw the
  471.     # words without replacement by using the built-in Python function pop():
  472.     # For more info, see: http://docs.python.org/2/tutorial/datastructures.html
  473.     stim_word = p_twl.pop()
  474.    
  475.     # Define task questions:
  476.     q1 = "1 Syllable?"
  477.     q2 = "Long 'EE' sound?"
  478.     q3 = "Word in word?"
  479.    
  480.     # Define word lists relevant to each question:
  481.     one = ["Hard", "Form"] # 'Correct' words...
  482.     n_one = ["Money", "Comedy"] # 'Incorrect' words...
  483.     ee = ["Reef", "Achieve"]
  484.     n_ee = ["Island", "Papers"]
  485.     wiw = ["Clear", "Afford"]
  486.     n_wiw = ["She", "Heavy"]
  487.    
  488.     # Now connect each question with the random word produced:
  489.     if stim_word in one:
  490.         exp.set('question', q1)
  491.     if stim_word in n_one:
  492.         exp.set('question', q1)
  493.     if stim_word in ee:
  494.         exp.set('question', q2)
  495.     if stim_word in n_ee:
  496.         exp.set('question', q2)
  497.     if stim_word in wiw:
  498.         exp.set('question', q3)
  499.     if stim_word in n_wiw:
  500.         exp.set('question', q3)
  501.    
  502.     # Set the variable 'stim_word' to be available in the GUI (e.g. can be accessed in a sketchpad):
  503.     exp.set('stim_word', stim_word)
  504.     __end__
  505.     set description "Executes Python code"
  506.  
  507. define sequence p_sequence
  508.     set flush_keyboard "yes"
  509.     set description "Runs a number of items in sequence"
  510.     run p_ongoing_list "always"
  511.     run p_block_loop "always"
  512.  
  513. define parallel parallel
  514.     run p_keyboard_response "always"
  515.     run sequence "always"
  516.  
  517. define text_display text_display
  518.     set foreground "#ffffff"
  519.     set font_size "60"
  520.     set description "Presents a display consisting of text"
  521.     set maxchar "50"
  522.     set align "center"
  523.     __content__
  524.     s1 start
  525.    
  526.     press a key
  527.     __end__
  528.     set background "#000000"
  529.     set duration "keypress"
  530.     set font_family "sans"
  531.  
  532. define inline_script p_ongoing_list
  533.     set _run ""
  534.     ___prepare__
  535.     # Import the module 'Random':
  536.     import random as rdm
  537.    
  538.     # Define trial word list:
  539.     p_twl = ["Hard", "Form", "Money", "Comedy", "Reef", "Achieve",\
  540.     "Island", "Papers", "Clear", "Afford", "She", "Heavy"]
  541.    
  542.     # Shuffle list order.
  543.     rdm.shuffle(p_twl)
  544.    
  545.     # Make list global for future use:
  546.     global p_twl
  547.     __end__
  548.     set description "Executes Python code"
  549.  
  550. define sketchpad question_word
  551.     set duration "1200"
  552.     set description "Displays stimuli"
  553.     draw textline 0 -128 "[question]" center=1 color=#ffffff font_family="mono" font_size=60 font_italic=no font_bold=yes show_if="always" html="yes"
  554.     draw textline 0 -32 "[stim_word]" center=1 color=#ffff00 font_family="mono" font_size=60 font_italic=no font_bold=yes show_if="always" html="yes"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement