Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- API: 2
- OpenSesame: 3.1.6
- Platform: nt
- ---
- set width 1280
- set uniform_coordinates no
- set title "Test Task"
- set synth_backend legacy
- set subject_parity even
- set subject_nr 0
- set start experiment
- set sound_sample_size -16
- set sound_freq 48000
- set sound_channels 2
- set sound_buf_size 1024
- set sampler_backend legacy
- set round_decimals 2
- set mouse_backend droid
- set keyboard_backend droid
- set height 800
- set fullscreen no
- set form_clicks no
- set foreground black
- set font_underline no
- set font_size 18
- set font_italic no
- set font_family sans
- set font_bold no
- set experiment_path "C:\\Users\\ms\\Desktop"
- set disable_garbage_collection yes
- set description "Default description"
- set coordinates relative
- set compensation 0
- set color_backend legacy
- set clock_backend legacy
- set canvas_backend droid
- set bidi no
- set background white
- set _run ""
- define sketchpad blank
- set duration 700
- set description "Displays stimuli"
- define sketchpad end_of_test
- set duration keypress
- set description "Displays stimuli"
- draw textline center=1 color="#000000" font_bold=yes font_family=Calibri font_italic=no font_size=50 html=yes show_if=always text="Well done!" x=0 y=0 z_index=0
- draw textline center=1 color=black font_bold=no font_family=sans font_italic=no font_size=18 html=yes show_if=always text="[reaction_mean]" x=-544 y=288 z_index=0
- draw textline center=1 color=black font_bold=no font_family=sans font_italic=no font_size=18 html=yes show_if=always text="[reaction_median]" x=-544 y=320 z_index=0
- draw textline center=1 color=black font_bold=no font_family=sans font_italic=no font_size=18 html=yes show_if=always text="[responses_correct]" x=-544 y=352 z_index=0
- draw textline center=1 color=black font_bold=no font_family=sans font_italic=no font_size=18 html=yes show_if=always text="[logfile]" x=-544 y=384 z_index=0
- define sequence experiment
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run setup always
- run intro always
- run experimental_loop always
- run shim_loop always
- define loop experimental_loop
- set source_file ""
- set source table
- set skip 0
- set repeat 10
- set order random
- set offset no
- set item experimental_sequence
- set description "Repeatedly runs another item"
- set cycles 4
- set continuous no
- set column_order "correct_key;response_key;fish"
- set break_if_on_first yes
- set break_if never
- setcycle 0 fish ll
- setcycle 0 correct_key z
- setcycle 1 fish lr
- setcycle 1 correct_key z
- setcycle 2 fish rr
- setcycle 2 correct_key m
- setcycle 3 fish rl
- setcycle 3 correct_key m
- run experimental_sequence
- define sequence experimental_sequence
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run blank always
- run star always
- run fish_lr "[fish]=lr"
- run fish_ll "[fish]=ll"
- run fish_rr "[fish]=rr"
- run fish_rl "[fish]=rl"
- run timing always
- define sketchpad fish_ll
- set duration 0
- set description "Displays stimuli"
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=-410 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=0 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=410 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=-210 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=210 y=0 z_index=0
- define sketchpad fish_lr
- set duration 0
- set description "Displays stimuli"
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=-410 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=0 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=410 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=-210 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=210 y=0 z_index=0
- define sketchpad fish_rl
- set duration 0
- set description "Displays stimuli"
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=-410 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=0 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=410 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=-210 y=0 z_index=0
- draw image center=1 file="fish_left_150.png" scale=0.7 show_if=always x=210 y=0 z_index=0
- define sketchpad fish_rr
- set duration 0
- set description "Displays stimuli"
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=-410 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=0 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=410 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=-210 y=0 z_index=0
- draw image center=1 file="fish_right_150.png" scale=0.7 show_if=always x=210 y=0 z_index=0
- define sketchpad intro
- set duration keypress
- set description "Displays stimuli"
- draw textline center=1 color="#000000" font_bold=yes font_family=Calibri font_italic=no font_size=40 html=yes show_if=always text="Here is a fish!<br />" x=0 y=-180 z_index=0
- draw image center=1 file="fish_left_150.png" scale=1 show_if=always x=0 y=0 z_index=0
- draw textline center=1 color="#000000" font_bold=yes font_family=Calibri font_italic=no font_size=40 html=yes show_if=always text="This is the mouth" x=-320 y=-64 z_index=0
- draw textline center=1 color="#000000" font_bold=yes font_family=Calibri font_italic=no font_size=40 html=yes show_if=always text="This is the tail" x=288 y=-96 z_index=0
- draw arrow arrow_body_length=0.7 arrow_body_width=0.2 arrow_head_width=30 color="#000000" fill=1 penwidth=2 show_if=always x1=-192 x2=-128 y1=-32 y2=0 z_index=0
- draw arrow arrow_body_length=0.7 arrow_body_width=0.2 arrow_head_width=30 color="#000000" fill=1 penwidth=2 show_if=always x1=192 x2=128 y1=-64 y2=-32 z_index=0
- draw textline center=1 color="#000000" font_bold=no font_family=Calibri font_italic=no font_size=25 html=yes show_if=always text="The fish is pointing this" x=-96 y=160 z_index=0
- draw arrow arrow_body_length=0.65 arrow_body_width=0.1 arrow_head_width=31 color="#000000" fill=1 penwidth=2 show_if=always x1=96 x2=32 y1=160 y2=160 z_index=0
- draw textline center=1 color="#000000" font_bold=no font_family=Calibri font_italic=no font_size=25 html=yes show_if=always text="way." x=128 y=160 z_index=0
- draw textline center=1 color="#000000" font_bold=no font_family=Calibri font_italic=no font_size=25 html=yes show_if=always text="The way the fish is swimming." x=0 y=224 z_index=0
- draw textline center=1 color="#000000" font_bold=yes font_family=Calibri font_italic=no font_size=40 html=yes show_if=always text="" x=0 y=224 z_index=0
- draw textline center=1 color=black font_bold=no font_family=sans font_italic=no font_size=12 html=yes show_if=always text="Touch to continue." x=416 y=352 z_index=0
- define inline_script setup
- set description "Executes Python code"
- ___run__
- reaction_times = []
- responses_correct = 0
- import datetime
- from time import strftime
- logfile = strftime("%Y-%m-%d-%H-%M-%S") + '.csv'
- print 'Using logfile: ' + logfile
- log.open(logfile)
- exp.set('logfile', logfile)
- log.write('correct_key, response, reaction_time')
- def median(lst):
- sortedLst = sorted(lst)
- lstLen = len(lst)
- index = (lstLen - 1) // 2
- if (lstLen % 2):
- return sortedLst[index]
- else:
- return (sortedLst[index] + sortedLst[index + 1])/2.0
- __end__
- set _prepare ""
- define loop shim_loop
- set source_file ""
- set source table
- set repeat 1
- set order random
- set description "Repeatedly runs another item"
- set cycles 1
- set continuous no
- set break_if_on_first yes
- set break_if never
- setcycle 0 empty_column ""
- run end_of_test
- define sketchpad star
- set duration 1000
- set description "Displays stimuli"
- draw image center=1 file="star_75.png" scale=1 show_if=always x=0 y=0 z_index=0
- define inline_script timing
- set description "Executes Python code"
- ___run__
- correct_key = exp.get('correct_key')
- print 'Expected: ' + correct_key
- my_keyboard = keyboard()
- time_before = self.time()
- response, time_after = my_keyboard.get_key(keylist=['z', 'm'])
- reaction_time = time_after - time_before
- reaction_times.append(reaction_time)
- exp.set('reaction_mean', sum(reaction_times) / float(len(reaction_times)))
- exp.set('reaction_median', median(reaction_times))
- if response is None:
- print(u'A timeout occurred!')
- else:
- print 'Response: ' + response
- print reaction_time
- if response == correct_key:
- print 'CORRECT!'
- responses_correct += 1
- exp.set('responses_correct', responses_correct)
- else:
- print 'INCORRECT!'
- log.write('%s, %s, %d' % (correct_key, response, reaction_time))
- print
- __end__
- set _prepare ""
Advertisement
Add Comment
Please, Sign In to add comment