Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27.2 (Frisky Freud)
- # Mon Jun 3 22:31:50 2013 (posix)
- # <http://www.cogsci.nl/opensesame>
- set foreground "white"
- set subject_parity "even"
- set description "A template containing a practice and an experimental phase"
- set title "Extended template"
- set compensation "0"
- set coordinates "relative"
- set height "768"
- set mouse_backend "xpyriment"
- set width "1024"
- set sampler_backend "legacy"
- set keyboard_backend "legacy"
- set background "black"
- set subject_nr "0"
- set canvas_backend "xpyriment"
- set start "experiment"
- set synth_backend "legacy"
- define loop block_loop
- set repeat "1"
- set description "A single block of trials"
- set item "trial_sequence"
- set column_order ""
- set cycles "5"
- set order "random"
- run trial_sequence
- define keyboard_response keyboard_response
- define inline_script read_tables
- set _run ""
- ___prepare__
- # Read the lists of the 40 rhyming pairs and the 60
- # non-rhyming pairs from two separate .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("rhyme_pairs.csv")
- path_non_rhymes = exp.get_file("non_rhyme_pairs.csv")
- # We'll use the built-in Python module numpy to read our .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"
- define sequence trial_sequence
- set flush_keyboard "yes"
- set description "Runs a number of items in sequence"
- run inline_script "always"
- run sketchpad "always"
- run keyboard_response "always"
- run logger "always"
- define loop experimental_loop
- set repeat "1"
- set description "A loop containing one or more experimental blocks"
- set item "block_sequence"
- set column_order ""
- set cycles "1"
- set order "random"
- run block_sequence
- define sequence experiment
- set flush_keyboard "yes"
- set description "The main sequence of the experiment"
- run read_tables "always"
- run experimental_loop "always"
- define inline_script block_list
- 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, we 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)
- # We use the function random.sample()t to obtain two lists containing a convenient
- # number of rhyme-pairs and non-rhyme pairs.
- # The number of pairs per list 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)
- # Next, we merge the two lists to obtain one block list:
- block_list = samples_rhymes + samples_non_rhymes
- # Shuffle the new list:
- random.shuffle(block_list)
- # Finally, we make the block_list global for future use:
- global block_list
- __end__
- set description "Executes Python code"
- define logger logger
- define inline_script inline_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 that some pairs are shown twice, and others never, we draw
- # the pairs without replacement by using the built-in Python function
- # pop():
- # For more info, see:
- # http://docs.python.org/2/tutorial/datastructures.html
- stim_pair = block_list.pop()
- print stim_pair
- # The pair is separated by a comma (because they come from a .csv
- # file). We split them by using the built-in Python function split():
- # For more info, see:
- # http://docs.python.org/2/library/stdtypes.html#str.split
- word1, word2 = stim_pair.split(",")
- # Finally, to make the variables word1 and word2 available in the GUI
- # (e.g. a sketchpad item), we use the built-in OpenSesame function
- # exp.set():
- # Now, we can use the square-bracket method to display the values of those
- # two variables in the sketchphad item.
- # For more info, see:
- # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/
- exp.set("word1", word1)
- exp.set("word2", word2)
- __end__
- set description "Executes Python code"
- define sketchpad sketchpad
- set duration "0"
- set description "Displays stimuli"
- 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"
- 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"
- define sequence block_sequence
- set flush_keyboard "yes"
- set description "A sequence containing a single block of trials followed by feedback to the participant"
- run block_list "always"
- run block_loop "always"
Advertisement
Add Comment
Please, Sign In to add comment