Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27.3 (Frisky Freud)
- # Mon Aug 19 13:39:04 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 coordinates "relative"
- set height "768"
- set pygame_doublebuf "yes"
- set width "1024"
- set compensation "0"
- set background "black"
- set subject_nr "0"
- set start "experiment"
- define inline_script target_position_list
- set _run ""
- ___prepare__
- # Import the Python module itertools:
- import itertools
- global itertools
- # Get the target lists:
- # Make a list of lists containing all 16 combinations by using
- # the itertools.product() function:
- temp_list = itertools.product(x_list, y_list)
- target_list = []
- for i in temp_list:
- target_list.append(i)
- # Randomize the items in the list by using the shuffle() function:
- shuffle(target_list)
- # Make the list global such that it is also available in
- # future inline scripts:
- global target_list
- __end__
- set description "Executes Python code"
- define loop block_loop
- set repeat "16"
- set description "A single block of trials"
- set skip "0"
- set offset "no"
- set item "trial_sequence"
- set column_order "target_presence;display_size"
- set cycles "1"
- set order "random"
- setcycle 0 target_presence "present"
- setcycle 0 display_size "16"
- run trial_sequence
- define text_display text_display
- set foreground "white"
- set font_size "18"
- set description "Presents a display consisting of text"
- set maxchar "50"
- set align "center"
- set content "Look for the red circle."
- set background "black"
- set duration "keypress"
- set font_family "mono"
- define inline_script objects
- ___run__
- # Show the canvas:
- my_canvas.show()
- self.sleep(0)
- __end__
- ___prepare__
- """
- DESCRIPTION:
- Prepare canvas.
- If block = feature:
- If dist_type = shape: dist = red squaretion
- If dist_type = color: dist = green circle
- If dist_type = color: dist = green circle
- TODO:
- Make SURE conjunction is conjunction!!
- """
- # Import modules:
- from openexp.canvas import canvas
- from random import choice, shuffle
- # Make a canvas:
- # See also:
- # http://osdoc.cogsci.nl/python-inline-code/canvas-functions/
- global my_canvas
- my_canvas = canvas(self.experiment)
- # Make a list for the distractor positions:
- # Make a list of lists containing all 16 combinations by using
- # the itertools.product() function:
- temp_list = itertools.product(x_list, y_list)
- dist_list = []
- for i in temp_list:
- dist_list.append(i)
- shuffle(dist_list)
- # Determine the traget position by using the pop() function.
- # ('Popping' indicates drawing an item without replacing it.)
- target_pos = target_list.pop()
- # Now remove this position from the distractor list (because
- # we don't want to accidently superimpose a distractor
- # on the target.
- dist_list.remove(target_pos)
- # Determine the distractor type:
- dist_type = choice(dist_types)
- # Draw the target to the canvas:
- x_target = target_pos[0]
- y_target = target_pos[1]
- my_canvas.circle(x_target,y_target, r, color = "red", fill = True)
- # Draw the distractors to the canvas:
- for i in range(0, 15):
- # Keep removing the used positions so that two distractors will never overlap:
- dist_pos = dist_list.pop()
- x_dist = dist_pos[0]
- y_dist = dist_pos[1]
- # If search task is conjunction, determine distractor type separately for
- # for every distractor.
- if self.get("search_task") == "conjunction":
- dist_type = choice(dist_types)
- # Determine the properties of the to-be-drawn distractor:
- if dist_type == "color":
- my_canvas.circle(x_dist,y_dist,r, color = "green", fill = True)
- else:
- my_canvas.rect(x_dist-w/2,y_dist-w/2, w, h, color = "red", fill = True)
- __end__
- set description "Executes Python code"
- define sketchpad red
- set duration "500"
- set description "Displays stimuli"
- set start_response_interval "no"
- draw fixdot 0 0 color=red show_if="always"
- define sequence trial_sequence
- set flush_keyboard "yes"
- set description "A single trial"
- run sketchpad "always"
- run objects "always"
- run keyboard_response "always"
- run green "[correct]=1"
- run red "[correct]=0"
- run logger "always"
- define sketchpad sketchpad
- set duration "1000"
- set description "Displays stimuli"
- set start_response_interval "no"
- draw fixdot 0 0 color=white show_if="always"
- define sequence experiment
- set flush_keyboard "yes"
- set description "The main sequence of the experiment"
- run constants "always"
- run text_display "always"
- run experimental_loop "always"
- define sketchpad green
- set duration "500"
- set description "Displays stimuli"
- set start_response_interval "no"
- draw fixdot 0 0 color=green show_if="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 "search_task"
- set cycles "2"
- set order "random"
- setcycle 0 search_task "feature"
- setcycle 1 search_task "conjunction"
- run block_sequence
- define keyboard_response keyboard_response
- set description "Collects keyboard responses"
- set timeout "infinite"
- set flush "yes"
- define logger logger
- set description "Logs experimental data"
- 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 target_position_list "always"
- run reset_feedback "always"
- run block_loop "always"
- define inline_script constants
- set _run ""
- ___prepare__
- """
- Define constants.
- """
- # Import modules
- import numpy as np
- from random import shuffle
- xCen = self.get("width")/2
- yCen = self.get("height")/2
- w = 80
- h = w
- r = 40
- # Determine distance such that objects will not fall out of screen
- dist = w+(w/2)
- x_list = np.linspace(0+dist,self.get("width")-dist,4).tolist()
- y_list = np.linspace(0+dist, self.get("height")-dist,4).tolist()
- dist_types = ["shape", "color"]
- # Make all variables that we need in subsequent inline scripts global
- global xCen, yCen, x_list, y_list, dist_types, w, h, r
- __end__
- set description "Executes Python code"
- define reset_feedback reset_feedback
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement