Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27.1 (Frisky Freud)
- # Mon Mar 4 12:23:57 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 sampler_backend "legacy"
- set coordinates "relative"
- set height "768"
- set mouse_backend "xpyriment"
- set width "1024"
- set compensation "0"
- set keyboard_backend "legacy"
- set background "black"
- set subject_nr "0"
- set canvas_backend "xpyriment"
- set start "experiment"
- set synth_backend "legacy"
- define inline_script define_dictionary
- set _run ""
- ___prepare__
- # Make a dictionary containing probability of sketchpad1
- # for every possible keyboard response.
- # See also:
- # http://docs.python.org/2/tutorial/datastructures.html#dictionaries
- dict = {}
- dict["s"] = .3
- dict["d"] = .6
- dict["b"] = .9
- dict["l"] = .1
- # Make the dictionary global such that it is available in
- # future inline_script items as well:
- global dict
- __end__
- set description "Executes Python code"
- define reset_feedback reset_feedback
- define sketchpad sketchpad2
- set duration "1000"
- set description "Displays stimuli"
- draw textline 0 -160 "This is sketchpad2" center=1 color=red font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
- define sketchpad sketchpad1
- set duration "1000"
- set description "Displays stimuli"
- draw textline 0 -192 "This is sketchpad1" center=1 color=green font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
- define loop block_loop
- set repeat "1"
- set description "A single block of trials"
- set skip "0"
- set offset "no"
- set item "trial_sequence"
- set column_order ""
- set cycles "10"
- set order "random"
- run trial_sequence
- define inline_script determine_sketchpad
- ___run__
- # Here we determine which response effect will appear
- # after a keyboard response:
- # Import the built-in Python module random()
- # See also: http://docs.python.org/2/library/random.html
- import random
- # Determine the given keyboard response by using the self.get() function.
- # See also:
- # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/
- key = self.get("response")
- # 'Look up' in the dictionary what the probability of sketchpad1 is
- # for this response:
- pSketchpad1 = dict[key]
- # Draw a random float and see whether the float is higher or lower than
- # as the probability that sketchpad1 will appear.
- # This probability depends the keyboard response.
- randomChoice = random.random()
- if randomChoice <= pSketchpad1:
- responseEffect = "sketchpad1"
- else:
- responseEffect = "sketchpad2"
- print pSketchpad1
- print randomChoice
- print responseEffect
- # Set the variable using the exp.set() function.
- # By doing so, we make sure the variable is available
- # in the graphical interface as well. This enables us,
- # for example, to log the variable and to use the square-
- # bracket method.
- # See also:
- # http://osdoc.cogsci.nl/usage/variables-and-conditional-qifq-statements/
- exp.set("responseEffect", responseEffect)
- # Also use some other variables for potential use in the GUI:
- exp.set("randomChoice", randomChoice)
- exp.set("pSketchpad1", pSketchpad1)
- exp.set("pSketchpad2", 1-pSketchpad1)
- __end__
- set _prepare ""
- set description "Executes Python code"
- define keyboard_response keyboard_response
- set description "Collects keyboard responses"
- set timeout "infinite"
- set flush "yes"
- define sequence experiment
- set flush_keyboard "yes"
- set description "The main sequence of the experiment"
- run define_dictionary "always"
- run experimental_loop "always"
- define sequence trial_sequence
- set flush_keyboard "yes"
- set description "A single trial"
- run sketchpad "always"
- run keyboard_response "always"
- run determine_sketchpad "always"
- run sketchpad1 "[responseEffect] = sketchpad1"
- run sketchpad2 "[responseEffect] = sketchpad2"
- run logger "always"
- define loop experimental_loop
- set repeat "1"
- set description "A loop containing one or more experimental blocks"
- set skip "0"
- set offset "no"
- set item "block_sequence"
- set column_order ""
- set cycles "4"
- set order "random"
- run block_sequence
- define logger logger
- set description "Logs experimental data"
- define sketchpad sketchpad
- set duration "0"
- set description "Displays stimuli"
- set start_response_interval "no"
- draw textline 0 -96 "" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
- draw textline 0.0 -224.0 "Press s, d, b, or l" 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 reset_feedback "always"
- run block_loop "always"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement