Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27.4 (Frisky Freud)
- # Mon Feb 17 14:37:19 2014 (nt)
- # <http://www.cogsci.nl/opensesame>
- set mouse_backend "legacy"
- set subject_parity "even"
- set transparent_variables "no"
- set height "768"
- set font_italic "no"
- set custom_cursor "no"
- set synth_backend "legacy"
- set title "New experiment"
- set coordinates "relative"
- set start "experiment"
- set sampler_backend "legacy"
- set font_family "mono"
- set foreground "white"
- set font_bold "no"
- set description "Default description"
- set background "black"
- set font_size "18"
- set enable_escape "yes"
- set keyboard_backend "legacy"
- set canvas_backend "legacy"
- set compensation "0"
- set subject_nr "0"
- set width "1024"
- define inline_script SetPosWords
- ___run__
- # Import the Python modules:
- import random
- from openexp.mouse import mouse
- from math import sqrt
- # Create a mouse object
- my_mouse = mouse(exp, visible=True)
- __end__
- ___prepare__
- # Import the Python modules:
- import random
- from openexp.mouse import mouse
- from math import sqrt
- # Create a mouse object
- my_mouse = mouse(exp, visible=True)
- #Create random locations and word list
- coords= [[+184, +130], [-100, +172], [+271, -222], [+287, +39], [-87, -39] ]
- random.shuffle(coords)
- for i in range (1,6):
- xvar="x"+str(i)
- yvar="y"+str(i)
- c =coords.pop()
- x=c.pop(0)
- y=c.pop()
- exp.set(xvar,x)
- exp.set(yvar,y)
- #create random word list
- Words= ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
- random.shuffle(Words)
- for a in range (1,6):
- Wordvar="Word"+str(a)
- z =Words.pop()
- exp.set(Wordvar,z)
- __end__
- set description "Executes Python code"
- define sequence Trials
- set flush_keyboard "yes"
- set description "Runs a number of items in sequence"
- run SetPosWords "always"
- run DisplayScreen "always"
- run GetClicks "always"
- run Response "always"
- define sketchpad welcome
- set duration "mouseclick"
- set start_response_interval "no"
- set description "Displays stimuli"
- draw textline 0 0 "Welcome to the experiment" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- draw textline -320 64 "Click all the words" center=0 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- define inline_script GetClicks
- ___run__
- from openexp.mouse import mouse
- from math import sqrt
- # Create a mouse object
- my_mouse = mouse(exp, visible=True)
- # Define all valid target positions
- coords= [[+184, +130], [-100, +172], [+271, -222], [+287, +39], [-87, -39] ]
- # The maximum distance in pixels that a click can be from a target position
- max_err = 10
- # The number of clicks to collect
- max_click = 4
- # Loop until we have collected all clicks
- n_click = 0
- while n_click < max_click:
- # Get a click and extract the position
- button, position, timestamp = my_mouse.get_click()
- cursor_x, cursor_y = position
- # Walk through all target positions to check if the click was on a target
- for xvar, yvar in coords:
- err = sqrt((xvar-cursor_x)**2+(yvar-cursor_y)**2)
- if err <= max_err:
- # If the click was on a target, set the click coordinates and
- # decrease the number of clicks that we still need to collect
- exp.set('click_%d_x' % n_click, xvar)
- exp.set('click_%d_y' % n_click, yvar)
- exp.set ('click_%d_word' % n_click, Wordvar)
- n_click += 1
- __end__
- set _prepare ""
- set description "Executes Python code"
- define sequence experiment
- run welcome "always"
- run Words "always"
- define loop Words
- set repeat "1"
- set description "Repeatedly runs another item"
- set item "Trials"
- set column_order "Word1;Word2;Word3;Word4;x1;y1;x2;x3;y3;y2;y4;x4;Word5;x5;y5"
- set cycles "2"
- set order "random"
- setcycle 0 Word5 ""
- setcycle 0 y2 ""
- setcycle 0 x2 ""
- setcycle 0 Word4 ""
- setcycle 0 Word1 ""
- setcycle 0 Word3 ""
- setcycle 0 Word2 ""
- setcycle 0 y1 ""
- setcycle 0 x3 ""
- setcycle 0 y3 ""
- setcycle 0 x1 ""
- setcycle 0 y5 ""
- setcycle 0 y4 ""
- setcycle 0 x4 ""
- setcycle 0 x5 ""
- setcycle 1 Word5 ""
- setcycle 1 y2 ""
- setcycle 1 x2 ""
- setcycle 1 Word4 ""
- setcycle 1 Word1 ""
- setcycle 1 Word3 ""
- setcycle 1 Word2 ""
- setcycle 1 y1 ""
- setcycle 1 x3 ""
- setcycle 1 y3 ""
- setcycle 1 x1 ""
- setcycle 1 y5 ""
- setcycle 1 y4 ""
- setcycle 1 x4 ""
- setcycle 1 x5 ""
- run Trials
- define sketchpad DisplayScreen
- set duration "mouseclick"
- set show_cursor "yes"
- set description "Displays stimuli"
- draw textline [x1] [y1] "[Word1]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- draw textline [x2] [y2] "[Word2]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- draw textline [x3] [y3] "[Word3]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- draw textline [x4] [y4] "[Word4]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- draw textline [x5] [y5] "[Word5]" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always" html="yes"
- define logger Response
- set ignore_missing "yes"
- set description "Logs experimental data"
- set auto_log "no"
- set use_quotes "yes"
- log "x1"
- log "y1"
- log "Word5"
- log "Word4"
- log "Word1"
- log "Word3"
- log "Word2"
- log "x2"
- log "x3"
- log "y3"
- log "y2"
- log "y5"
- log "y4"
- log "x4"
- log "x5"
- log "Wordvar"
- log "xvar"
- log "yvar"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement