Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27.3 (Frisky Freud)
- # Mon Sep 02 18:34:03 2013 (nt)
- # <http://www.cogsci.nl/opensesame>
- set mouse_backend "xpyriment"
- set subject_parity "even"
- set height "768"
- set font_family "sans"
- set font_italic "no"
- set custom_cursor "yes"
- set synth_backend "legacy"
- set title "phonological_1234"
- set coordinates "relative"
- set start "experiment"
- set sampler_backend "legacy"
- set transparent_variables "no"
- set foreground "Black"
- set font_bold "no"
- set description "Default description"
- set background "White"
- set font_size "20"
- set keyboard_backend "legacy"
- set canvas_backend "xpyriment"
- set compensation "0"
- set subject_nr "0"
- set width "1366"
- define loop s1_block_loop
- set repeat "1"
- set description "Repeatedly runs another item"
- set skip "0"
- set item "s1_trial_sequence"
- set column_order "frame_colour;correct_cue_response"
- set cycles "50"
- set order "sequential"
- setcycle 0 frame_colour "Black"
- setcycle 0 correct_cue_response ""
- setcycle 1 frame_colour "Black"
- setcycle 1 correct_cue_response ""
- setcycle 2 frame_colour "Black"
- setcycle 2 correct_cue_response ""
- setcycle 3 frame_colour "Black"
- setcycle 3 correct_cue_response ""
- setcycle 4 frame_colour "Black"
- setcycle 4 correct_cue_response ""
- setcycle 5 frame_colour "Black"
- setcycle 5 correct_cue_response ""
- setcycle 6 frame_colour "Black"
- setcycle 6 correct_cue_response ""
- setcycle 7 frame_colour "Black"
- setcycle 7 correct_cue_response ""
- setcycle 8 frame_colour "Black"
- setcycle 8 correct_cue_response ""
- setcycle 9 frame_colour "Black"
- setcycle 9 correct_cue_response ""
- setcycle 10 frame_colour "Black"
- setcycle 10 correct_cue_response ""
- setcycle 11 frame_colour "Black"
- setcycle 11 correct_cue_response ""
- setcycle 12 frame_colour "Black"
- setcycle 12 correct_cue_response ""
- setcycle 13 frame_colour "Black"
- setcycle 13 correct_cue_response ""
- setcycle 14 frame_colour "Black"
- setcycle 14 correct_cue_response ""
- setcycle 15 frame_colour "Black"
- setcycle 15 correct_cue_response ""
- setcycle 16 frame_colour "Black"
- setcycle 16 correct_cue_response ""
- setcycle 17 frame_colour "Black"
- setcycle 17 correct_cue_response ""
- setcycle 18 frame_colour "Black"
- setcycle 18 correct_cue_response ""
- setcycle 19 frame_colour "Green"
- setcycle 19 correct_cue_response "g"
- setcycle 20 frame_colour "Black"
- setcycle 20 correct_cue_response ""
- setcycle 21 frame_colour "Black"
- setcycle 21 correct_cue_response ""
- setcycle 22 frame_colour "Black"
- setcycle 22 correct_cue_response ""
- setcycle 23 frame_colour "Black"
- setcycle 23 correct_cue_response ""
- setcycle 24 frame_colour "Black"
- setcycle 24 correct_cue_response ""
- setcycle 25 frame_colour "Black"
- setcycle 25 correct_cue_response ""
- setcycle 26 frame_colour "Black"
- setcycle 26 correct_cue_response ""
- setcycle 27 frame_colour "Black"
- setcycle 27 correct_cue_response ""
- setcycle 28 frame_colour "Black"
- setcycle 28 correct_cue_response ""
- setcycle 29 frame_colour "Black"
- setcycle 29 correct_cue_response ""
- setcycle 30 frame_colour "Black"
- setcycle 30 correct_cue_response ""
- setcycle 31 frame_colour "Black"
- setcycle 31 correct_cue_response ""
- setcycle 32 frame_colour "Black"
- setcycle 32 correct_cue_response ""
- setcycle 33 frame_colour "Black"
- setcycle 33 correct_cue_response ""
- setcycle 34 frame_colour "Black"
- setcycle 34 correct_cue_response ""
- setcycle 35 frame_colour "Black"
- setcycle 35 correct_cue_response ""
- setcycle 36 frame_colour "Black"
- setcycle 36 correct_cue_response ""
- setcycle 37 frame_colour "Black"
- setcycle 37 correct_cue_response ""
- setcycle 38 frame_colour "Black"
- setcycle 38 correct_cue_response ""
- setcycle 39 frame_colour "Green"
- setcycle 39 correct_cue_response "g"
- setcycle 40 frame_colour "Black"
- setcycle 40 correct_cue_response ""
- setcycle 41 frame_colour "Black"
- setcycle 41 correct_cue_response ""
- setcycle 42 frame_colour "Black"
- setcycle 42 correct_cue_response ""
- setcycle 43 frame_colour "Black"
- setcycle 43 correct_cue_response ""
- setcycle 44 frame_colour "Black"
- setcycle 44 correct_cue_response ""
- setcycle 45 frame_colour "Black"
- setcycle 45 correct_cue_response ""
- setcycle 46 frame_colour "Black"
- setcycle 46 correct_cue_response ""
- setcycle 47 frame_colour "Black"
- setcycle 47 correct_cue_response ""
- setcycle 48 frame_colour "Black"
- setcycle 48 correct_cue_response ""
- setcycle 49 frame_colour "Black"
- setcycle 49 correct_cue_response ""
- run s1_trial_sequence
- define inline_script s1_keyboard_response
- set _run ""
- ___prepare__
- from openexp.keyboard import keyboard
- # The keypress timeout
- timeout = 2000
- # We poll for two responses. The first 'keyboard_response_1'
- # waits for a 'g'. The second waits for a 'z' or an 'm'. These
- # responses can be given in arbitrary order, are stored in
- # different variables, and can time out indendently of each
- # other.
- exp.set('keyboard_response_1', None)
- exp.set('keyboard_response_time_1', None)
- keylist_1 = ['g']
- exp.set('keyboard_response_2', None)
- exp.set('keyboard_response_time_2', None)
- keylist_2 = ['z', 'm']
- # Create a keyboard object that doesn't block the
- # experiment, so we can use it to poll for keypresses
- # continuously.
- my_keyboard = keyboard(exp, timeout=0)
- # Loop until we timeout
- start_time = self.time()
- while self.time() - timeout < start_time:
- key, key_time = my_keyboard.get_key()
- # If a key from keylist 1 is pressed, set keyboard_response_1
- # and keyboard_response_time_1. Also, set key_list_1 to [], so
- # that we do not capture multiple keypresses from this list.
- if key in keylist_1:
- exp.set('keyboard_response_1', key)
- exp.set('keyboard_response_time_1', key_time - start_time)
- keylist_1 = []
- # The same principle is applied for keylist 2.
- if key in keylist_2:
- exp.set('keyboard_response_2', key)
- exp.set('keyboard_response_time_2', key_time - start_time)
- keylist_2 = []
- # Create a variable to check the response against the expected response:
- if self.get('keyboard_response_2') == self.get('correct_ongoing_response'):
- correct_2 = '1'
- else:
- correct_2 = '0'
- exp.set("correct_2", correct_2)
- # Create a variable to check the response against the expected response:
- if self.get('keyboard_response_1') == self.get('correct_cue_response'):
- correct_1 = '1'
- else:
- correct_1 = '0'
- exp.set("correct_1", correct_1)
- __end__
- set description "Executes Python code"
- define loop s1
- set repeat "1"
- set description "Repeatedly runs another item"
- set item "s1_sequence"
- set column_order ""
- set cycles "1"
- set order "sequential"
- run s1_sequence
- define sequence s1_trial_sequence
- set flush_keyboard "yes"
- set description "Runs a number of items in sequence"
- run ongoing_script "always"
- run s1_trial_display "always"
- run s1_response_script "always"
- run s1_keyboard_response "always"
- run logger "always"
- define sketchpad s1_trial_display
- set duration "2000"
- set description "Displays stimuli"
- draw textline -180 0 "[word1]" center=1 color=black font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always"
- draw textline 180 0 "[word2]" center=1 color=black font_family="mono" font_size=40 font_italic=no font_bold=no show_if="always"
- draw rect -480 -160 960 320 fill=0 penwidth=3 color=[frame_colour] show_if="always"
- define text_display end_s1
- set foreground "#000000"
- set font_size "20"
- set description "Presents a display consisting of text"
- set maxchar "200"
- set align "center"
- __content__
- End of Session A.
- Press any key to continue.
- __end__
- set background "#ffffff"
- set duration "keypress"
- set font_family "sans"
- define sequence experiment
- set flush_keyboard "yes"
- set description "Runs a number of items in sequence"
- run read_tables "always"
- run s1 "always"
- run end_s1 "always"
- define inline_script s1_response_script
- set _run ""
- ___prepare__
- # For the ongoing task:
- # Determine correct ongoing response, depending on whether the words
- # come from the rhyming or the non-rhyming list
- if stim_pair in list_rhymes:
- correct_keyboard_response_2 = 'm'
- if stim_pair in list_non_rhymes:
- correct_keyboard_response_2 = 'z'
- # Set the correct response for the ongoing task by giving the variable
- # 'correct_ongoing_response' a value:
- exp.set("correct_ongoing_response", correct_keyboard_response_2)
- # For the cues:
- # Determine correct response, depending on cues in session
- if self.get('frame_colour') == 'Green':
- correct_keyboard_response_1 = 'g'
- if self.get('frame_colour') == 'Black':
- correct_keyboard_response_1 = ''
- # Set the correct response by giving the variable 'correct_cue_response'
- # a value:
- exp.set("correct_cue_response", correct_keyboard_response_1)
- __end__
- set description "Executes Python code"
- define sequence s1_sequence
- set flush_keyboard "yes"
- set description "Runs a number of items in sequence"
- run ongoing_task "always"
- run s1_block_loop "always"
- define inline_script ongoing_task
- set _run ""
- ___prepare__
- # Randomise the from-the-csv-files-read lists
- # and draw two samples containing the necessary numbers of rhymes and non-rhymes, respectively.
- # First, randomise the lists using the function random.shuffle() from
- # the built-in Python module random:
- # For more info, see:
- # http://docs.python.org/2/library/random.html#random.shuffle
- import random
- random.shuffle(list_rhymes)
- random.shuffle(list_non_rhymes)
- # Use the function random.sample() to obtain two lists containing the
- # desired number of rhyme pairs and non-rhyme pairs.
- # The number of pairs per list is equal to half of the number of pairs in the
- # original list (i.e. 20 rhyme pairs and 30 non-rhyme pairs).
- # For more info, see:
- # http://docs.python.org/2/library/random.html#random.sample
- samples_rhymes = random.sample(list_rhymes,len(list_rhymes)/2)
- samples_non_rhymes = random.sample(list_non_rhymes, len(list_non_rhymes)/2)
- # The two lists are merged to create one block list:
- block_list = samples_rhymes + samples_non_rhymes
- # The block list is then shuffled:
- random.shuffle(block_list)
- # Block list made global for future use:
- global block_list
- __end__
- set description "Executes Python code"
- define logger logger
- set ignore_missing "yes"
- set description "Logs experimental data"
- set auto_log "yes"
- set use_quotes "yes"
- log "count_s1_trial_sequence"
- log "title"
- log "count_s1_sequence"
- log "frame_colour"
- log "correct_cue_response"
- log "count_experiment"
- log "correct_ongoing_response"
- define inline_script ongoing_script
- set _run ""
- ___prepare__
- # Determine the word pair of the current trial by drawing one word pair
- # from the previously defined block list.
- # To avoid repeat display of word pairs and non-display of others, draw
- # pairs without replacement by using the built-in Python function pop() .
- stim_pair = block_list.pop()
- print stim_pair
- # The pair is separated by a comma (they come from a .csv file).
- # Split them by using the built-in Python function split() :
- word1, word2 = stim_pair.split(",")
- # To make the variables word1 and word2 available in the GUI (e.g. a
- # sketchpad item), use the built-in OpenSesame function exp.set() :
- exp.set("word1", word1)
- exp.set("word2", word2)
- # Now square bracket method can be used to display values
- # of those two variables in the sketchpad item.
- __end__
- set description "Executes Python code"
- define inline_script read_tables
- set _run ""
- ___prepare__
- # Read the lists of the 40 rhyming pairs and the 60
- # non-rhyming pairs from the two seperate .csv files.
- # Specify the paths to the files containing the pairs
- # by using the built-in OpenSesame function exp.get_file.
- # For more info, see:
- #http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.get_file
- path_rhymes = exp.get_file("rhyming_pairs.csv")
- path_non_rhymes = exp.get_file("non_rhyme_pairs.csv")
- # Use the built-in Python module numpy to read the .csv file:
- # Import the module
- import numpy as np
- # And load the text file.
- #For more info, see:
- #http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html
- list_rhymes = np.loadtxt(path_rhymes, dtype = str)
- list_non_rhymes = np.loadtxt(path_non_rhymes, dtype = str)
- # Make the two lists global for future use:
- global list_rhymes, list_non_rhymes
- __end__
- set description "Executes Python code"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement