---
API: 2.1
OpenSesame: 3.3.6
Platform: posix
---
set width 1024
set uniform_coordinates yes
set title "Extended template"
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 legacy
set keyboard_backend legacy
set height 768
set fullscreen no
set form_clicks no
set foreground "#ffffff"
set font_underline no
set font_size 32
set font_italic no
set font_family mono
set font_bold no
set experiment_path "/Users/Lanting/Desktop"
set disable_garbage_collection yes
set description "A template containing a practice and an experimental phase"
set coordinates uniform
set compensation 0
set color_backend legacy
set clock_backend legacy
set canvas_backend legacy
set bidi yes
set background "#000000"
define inline_script Post_stream_canvas
set description "Executes Python code"
set _run ""
set _prepare ""
define inline_script RSVP
set description "Executes Python code"
___run__
#runphase
for letter_canvas in letter_canvas_list:
letter_canvas.show()
clock.sleep(var.letter_dur)
#blank_canvas.show()
#clock.sleep(var.isi)
__end__
___prepare__
import random
import string
from openexp.canvas import canvas
lag = self.get('lag')
#the presentation time of each stimulus
var.letter_dur = 100
#the inter-stimulus interval
#var.isi
#the position of T1 is random between 3 and 5
var. T1_pos = random.randint(4,6)
#T2 postion
var.T2_pos = var. T1_pos + var.lag
var.number_postT2 = random.randint(2,5)
#the length of the stream
var.stream_len =var.T2_pos + var.number_postT2
numbers =[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]
T1_set = ["S", "D", 'F', 'G']
T1_random_number = random.randint(0,3)
T1_letter = T1_set[T1_random_number]
T2_set = ['H','J','K','L']
T2_random_number = random.randint(0,3)
T2_letter = T2_set[T2_random_number]
#randomly sample a 'stream_len'number of letters
stim_list = random.sample (numbers,var.stream_len)
stim_list[var.T1_pos] = T1_letter
stim_list[var.T2_pos] = T2_letter
#create an empty list for the canvas objects
letter_canvas_list =[]
for i, stim in enumerate (stim_list):
#create a canvas object
letter_canvas = canvas (var)
#draw the letter
letter_canvas.text (stim)
#add the canvas to the list.
letter_canvas_list.append(letter_canvas)
blank_canvas = canvas (var)
#set variable
var.set('T1_pos', var.T1_pos)
# Extract T1 from the list
var.T1 = stim_list[var.T1_pos]
var.set('T1', var.T1)
var.set('T2_pos', var.T2_pos)
# Extract T2 from the list
var.T2 = stim_list[var.T2_pos]
var.set('T2', var.T2)
__end__
define inline_script RSVP_1
set description "Executes Python code"
___run__
#runphase
for letter_canvas in letter_canvas_list:
letter_canvas.show()
clock.sleep(var.letter_dur)
#blank_canvas.show()
#clock.sleep(var.isi)
__end__
___prepare__
import random
import string
from openexp.canvas import canvas
lag = self.get('lag')
#the presentation time of each stimulus
var.letter_dur = 100
#the inter-stimulus interval
#var.isi
#the position of T1 is random between 3 and 5
var. T1_pos = random.randint(3,5)
#T2 postion
var.T2_pos = var. T1_pos + var.lag
#the length of the stream
var.stream_len =var.T2_pos + 1
numbers =[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6]
T1_set = ["S", "D", 'F', 'G']
T1_random_number = random.randint(0,3)
T1_letter = T1_set[T1_random_number]
T2_set = ['H','J','K','L']
T2_random_number = random.randint(0,3)
T2_letter = T2_set[T2_random_number]
#randomly sample a 'stream_len'number of letters
stim_list = random.sample (numbers,var.stream_len)
stim_list[var.T1_pos] = T1_letter
stim_list[var.T2_pos] = T2_letter
#create an empty list for the canvas objects
letter_canvas_list =[]
for i, stim in enumerate (stim_list):
#create a canvas object
letter_canvas = canvas (var)
#draw the letter
letter_canvas.text (stim)
#add the canvas to the list.
letter_canvas_list.append(letter_canvas)
blank_canvas = canvas (var)
#set variable
var.set('T1_pos', var.T1_pos)
# Extract T1 from the list
var.T1 = stim_list[var.T1_pos]
var.set('T1', var.T1)
var.set('T2_pos', var.T2_pos)
# Extract T2 from the list
var.T2 = stim_list[var.T2_pos]
var.set('T2', var.T2)
__end__
define notepad about_this_template
__note__
This template already contains the basic structure of a typical experiment.
It consists of a practice phase, followed by an experimental phase. For more
information, please visit
Have fun with OpenSesame!
__end__
set description "Some pointers to help you gest started!"
define sketchpad ask_T1
set duration 0
set description "Displays stimuli"
draw textline center=1 color="#ffffff" font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="Please type the first target" x=0 y=-96 z_index=0
define sketchpad ask_T2
set duration 0
set description "Displays stimuli"
draw textline center=1 color="#080808" font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="Please type the second target" x=0 y=-96 z_index=0
draw textline center=1 color="#ffffff" font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="Please type the second target
" x=0 y=-64 z_index=0
define inline_script basic_setting
set description "Executes Python code"
set _run ""
set _prepare ""
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 standards_AB always
run time_report always
run standards_AB always
define inline_script button
set description "Executes Python code"
___run__
import tkinter
from tkinter import*
def answer():
print("你看我像靓仔吗?")
root=Tk()
button=Button(root,text="你是靓仔吗",command=answer)
button.pack()
root.mainloop()
__end__
set _prepare ""
define inline_script correct_response
set description "Executes Python code"
___run__
var.correct_response_T1 = var.T1
var.correct_response_T2 = var.T2
#get keyboard response
var.keyboard_response = keyboard()
var,keyboard_response.keylist= [u'1', u'2',u'3',u'4',u'5',u'6',u'7',u'8',u'9']
var.key_T1 = keyboard_response.get_key(var.response_T1)
var.key_T2 = keyboard_response.get_key(var.response_T2)
__end__
set _prepare ""
define inline_script determine_correct_response
set description "Executes Python code"
___run__
# The variable form_response contains the text that
# the participant selected. We give the built-in variable
# 'response' the same value:
var.response = var.form_response
# Determine whether the response was correct:
if var.response == var.target_pair:
var.correct = 1
else:
var.correct = 0
__end__
set _prepare ""
define inline_script determine_correct_response_1
set description "Executes Python code"
___run__
# The variable form_response contains the text that
# the participant selected. We give the built-in variable
# 'response' the same value:
var.response = var.form_response
# Determine whether the response was correct:
if var.response == var.target_pair:
var.correct = 1
else:
var.correct = 0
__end__
set _prepare ""
define sketchpad end_of_experiment
set start_response_interval no
set duration keypress
set description "A sketchpad notifying the participant that the experiment is finished"
draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Press any key to exit" x=0 y=0 z_index=0
define sketchpad end_of_practice
set start_response_interval no
set duration keypress
set description "A sketchpad notifying the participant that the practice phase is finished"
draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Press any key to continue" x=0 y=0 z_index=0
define sequence experiment
set flush_keyboard yes
set description "The main sequence of the experiment"
run about_this_template always
run instructions always
run practice_loop always
run end_of_practice always
run experimental_loop always
run end_of_experiment always
define loop experimental_loop
set source_file ""
set source table
set skip 0
set repeat 1
set order random
set offset no
set item block_sequence
set description "A loop containing one or more experimental blocks"
set cycles 1
set continuous no
set column_order practice
set break_if_on_first yes
set break_if never
setcycle 0 practice no
run block_sequence
define feedback feedback
set reset_variables yes
set duration keypress
set description "Provides feedback to the participant"
draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="
Your accuracy was [acc]%
Press any key to continue" x=0 y=0 z_index=0
define feedback feedback_1
set reset_variables yes
set duration keypress
set description "Provides feedback to the participant"
draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="
Your accuracy was [acc]%
Press any key to continue" x=0 y=0 z_index=0
define sketchpad fixation
set start_response_interval no
set duration 0
set description "Displays stimuli"
draw fixdot color=white show_if=always style=default x=0 y=0 z_index=0
define sketchpad fixation_1
set start_response_interval no
set duration 0
set description "Displays stimuli"
draw fixdot color=white show_if=always style=default x=0 y=0 z_index=0
define sketchpad fixation_2
set start_response_interval no
set duration 0
set description "Displays stimuli"
draw fixdot color=white show_if=always style=default x=0 y=0 z_index=0
define sketchpad instructions
set start_response_interval no
set duration keypress
set description "A sketchpad containing the instructions for the participant"
draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Press any key to begin!" x=0 y=0 z_index=0
define inline_script letter_pairs
set description "Executes Python code"
set _run ""
___prepare__
import random
var.target_pair = var.T1 + var.T2
var.correct_response = var.target_pair
print(var.target_pair)
var.irrelevant_pair = []
print(var.T1)
if var.T1 == "S":
var.irrelevant_pair = ["SH","SJ","SK","SL","S"];
elif var.T1 == "D":
var.irrelevant_pair = ["DH","DJ","DK","DL","D"];
elif var.T2 == "F":
var.irrelevant_pair = ["FH","FJ","FK","FL","F"];
elif var.T1 == "G":
var.irrelevant_pair = ["GH","GJ","GK","GL","G"]
var.irrelevant_pair.append(var.T1)
print(var.irrelevant_pair)
var.text1,var.text2,var.text3,var.text4,var.text5,var.text6 = var.irrelevant_pair
__end__
define inline_script letter_pairs_1
set description "Executes Python code"
set _run ""
___prepare__
import random
var.target_pair = var.T1 + var.T2
var.correct_response = var.target_pair
print(var.target_pair)
var.irrelevant_pair = []
print(var.T1)
if var.T1 == "S":
var.irrelevant_pair = ["SH","SJ","SK","SL","S"];
elif var.T1 == "D":
var.irrelevant_pair = ["DH","DJ","DK","DL","D"];
elif var.T2 == "F":
var.irrelevant_pair = ["FH","FJ","FK","FL","F"];
elif var.T1 == "G":
var.irrelevant_pair = ["GH","GJ","GK","GL","G"]
var.irrelevant_pair.append(var.T1)
var.text1,var.text2,var.text3,var.text4,var.text5,var.text6 = var.irrelevant_pair
print(var.irrelevant_pair)
print(var.text3)
print(var.text4)
__end__
define logger logger
set description "Logs experimental data"
set auto_log yes
define logger logger_1
set description "Logs experimental data"
set auto_log yes
define form_multiple_choice multiple_choice
set timeout infinite
set spacing 10
set question "Choose the right combination"
__options__
SH
SJ
MH
__end__
set margins "50;50;50;50"
set form_var response
set form_title "Form title"
set description "A simple multiple choice item"
set button_text Ok
set allow_multiple no
set advance_immediately yes
set _theme gray
define form_multiple_choice multiple_choice_1
set timeout infinite
set spacing 10
set question "Choose the right combination"
__options__
SH
SJ
MH
__end__
set margins "50;50;50;50"
set form_var response
set form_title "Form title"
set description "A simple multiple choice item"
set button_text Ok
set allow_multiple no
set advance_immediately yes
set _theme gray
define form_base new_form_base
set timeout infinite
set spacing 10
set rows "1;1;1;1;1;1;1;1;1;1"
set only_render no
set margins "50;100;50;100"
set description "A generic form plug-in"
set cols "2;2"
set _theme gray
widget 0 0 2 1 label text="please choose the time interval"
widget 0 2 1 1 button text="[100]"
widget 0 3 1 1 button text="[200]"
widget 0 4 1 1 button text="[300]"
widget 0 5 1 1 button text="[400]"
widget 0 6 1 1 button text="[500]"
widget 0 7 1 1 button text="[600]"
widget 0 8 1 1 button text="[700]"
widget 0 9 1 1 button text="[T1 only]"
define form_consent new_form_consent
set timeout infinite
set spacing 10
set rows "1;4;1;1"
set only_render no
set margins "50;50;50;50"
set form_title "Consent form"
__form_text__
You are about to participate in an experiment.
This experiment poses no known risks to your health and your name will not be associated with the findings.
Upon completion of your participation in this study you will be provided with a brief explanation of the question this study addresses.
If you have any questions not addressed by this consent form, please do not hesitate to ask.
You can stop at any time during experiment if you feel uncomfortable.
__end__
set description "A simple consent form"
set decline_text "Do not participate"
set decline_message "You need to accept the consent form to participate!"
set cols "2;2"
set checkbox_text "I have read and understood the information shown above"
set accept_text "Participate!"
set _theme gray
widget 0 0 2 1 label text="[form_title]"
widget 0 1 2 1 label center=no text="[form_text]"
widget 0 2 2 1 checkbox text="[checkbox_text]" var=checkbox_status
widget 0 3 1 1 button text="[accept_text]" var=accept_status
widget 1 3 1 1 button text="[decline_text]"
define form_text_display new_form_text_display
set timeout infinite
set spacing 10
set rows "1;4;1"
set only_render no
set ok_text Ok
set margins "50;50;50;50"
set form_title Title
set form_text "Your message"
set description "A simple text display form"
set cols "1;1;1"
set _theme gray
widget 0 0 3 1 label text="[form_title]"
widget 0 1 3 1 label center=no text="[form_text]"
widget 1 2 1 1 button text="[ok_text]"
define form_text_input new_form_text_input
set timeout infinite
set spacing 10
set rows "1;1;6"
set only_render no
set margins "50;50;50;50"
set form_var response
set form_title Title
set form_question "Your question"
set description "A simple text input form"
set cols 1
set _theme gray
widget 0 0 1 1 label text="[form_title]"
widget 0 1 1 1 label center=no text="[form_question]"
widget 0 2 1 1 text_input focus=yes return_accepts=yes stub="" var="[form_var]"
define inline_script new_inline_script
set description "Executes Python code"
___run__
print("Please type the first target")
#color="#ffffff",font_family=mono,font_size=32
print("your response is: ", end='')
print(var.key_T1)
__end__
set _prepare ""
define inline_script new_inline_script_1
set description "Executes Python code"
___run__
print("Please type the second target",color="#ffffff",font_family=mono,font_size=32)
print("your response is: ", end='')
print(var.key_T2)
__end__
set _prepare ""
define inline_script new_inline_script_2
set description "Executes Python code"
set _run ""
set _prepare ""
define inline_script new_inline_script_3
set description "Executes Python code"
___run__
# Import the widgets library
from libopensesame import widgets
# Create a form
form = widgets.form(exp, cols=[1,1], rows=[1,1,1],
margins=(50,100,50,100), spacing=25)
# Create four widgets
labelTitle = widgets.label(form, text='choose the right combination')
button5cts = widgets.button(form, text="[text1]")
button10cts = widgets.button(form, text="[text2]")
button15cts = widgets.button(form, text="[text3]")
button20cts = widgets.button(form, text="[text4]")
# Add the widgets to the form. The position in the form is indicated as a
# (column, row) tuple.
form.set_widget(labelTitle, (0,0), colspan=2)
form.set_widget(button5cts, (0,1))
form.set_widget(button10cts, (1,1))
form.set_widget(button10cts, (0,2))
form.set_widget(button10cts, (1,2))
# Execute the form! In this case, the form will return the text of the button that
# was clicked. This is one way to get a return value out of the form. Another way
# is to use the 'var' keyword, supported some of the widgets.
button_clicked = form._exec()
__end__
set _prepare ""
define inline_script new_inline_script_3_1
set description "Executes Python code"
___run__
# Import the widgets library
from libopensesame import widgets
# Create a form
form = widgets.form(exp, cols=[1,1], rows=[1,1,1],
margins=(50,100,50,100), spacing=25)
# Create four widgets
labelTitle = widgets.label(form, text='choose the right combination')
button5cts = widgets.button(form, text="[text1]")
button10cts = widgets.button(form, text="[text2]")
button15cts = widgets.button(form, text="[text3]")
button20cts = widgets.button(form, text="[text4]")
# Add the widgets to the form. The position in the form is indicated as a
# (column, row) tuple.
form.set_widget(labelTitle, (0,0), colspan=2)
form.set_widget(button5cts, (0,1))
form.set_widget(button10cts, (1,1))
form.set_widget(button10cts, (0,2))
form.set_widget(button10cts, (1,2))
# Execute the form! In this case, the form will return the text of the button that
# was clicked. This is one way to get a return value out of the form. Another way
# is to use the 'var' keyword, supported some of the widgets.
button_clicked = form._exec()
__end__
set _prepare ""
define loop new_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 ""
define mouse_response new_mouse_response
set timeout infinite
set show_cursor yes
set linked_sketchpad ""
set flush yes
set event_type mouseclick
set duration mouseclick
set description "Collects mouse responses"
define sequence new_sequence
set flush_keyboard yes
set description "Runs a number of items in sequence"
define sequence new_sequence_1
set flush_keyboard yes
set description "Runs a number of items in sequence"
define sketchpad new_sketchpad
set duration keypress
set description "Displays stimuli"
draw textline center=1 color="#ffffff" font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="Choose the right combination" x=0 y=-128 z_index=0
draw textline center=1 color="#ffffff" font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="SH DH FH GH
SJ DJ FJ GJ
SK DK FK GK
SL DL FL GL
S D F G
" x=0 y=32 z_index=0
define loop practice_loop
set source_file ""
set source table
set skip 0
set repeat 1
set order random
set offset no
set item block_sequence
set description "A loop containing one or more practice blocks"
set cycles 1
set continuous no
set column_order practice
set break_if_on_first yes
set break_if never
setcycle 0 practice yes
run block_sequence
define reset_feedback reset_feedback
set description "Resets the feedback variables, such as 'avg_rt' and 'acc'"
define keyboard_response response_T1
set timeout infinite
set flush yes
set event_type keypress
set duration keypress
set description "Collects keyboard responses"
define keyboard_response response_T2
set timeout infinite
set flush yes
set event_type keypress
set duration keypress
set description "Collects keyboard responses"
set correct_response "‘[T2]’"
define form_base response_selection
set timeout infinite
set spacing 25
set rows "1;1;1;1;1"
set only_render no
set margins "50;100;50;100"
set description "A generic form plug-in"
set cols "1;1;1;1;1"
set _theme gray
widget 0 0 5 1 label text="please choose the right target combination"
widget 0 2 1 1 button text="[text1]"
widget 1 2 1 1 button text="[text2]"
widget 2 2 1 1 button text="[text3]"
widget 3 2 1 1 button text="[text4]"
widget 4 2 1 1 button text="[text5]"
define form_base response_selection_1
set timeout infinite
set spacing 25
set rows "1;1;1;1"
set only_render no
set margins "50;100;50;100"
set description "A generic form plug-in"
set cols "1;1;1;1"
set _theme gray
widget 0 0 2 1 label text=Question
widget 0 2 1 1 button text="[text1]"
widget 1 2 1 1 button text="[text2]"
widget 2 2 1 1 button text="[text3]"
widget 3 2 1 1 button text="[text4]"
define sequence standard_AB_1
set flush_keyboard yes
set description "A single trial"
run fixation always
run RSVP always
run letter_pairs always
run response_selection always
run determine_correct_response always
run logger always
run feedback always
define sequence standard_AB_1_1
set flush_keyboard yes
set description "A single trial"
run fixation_1 always
run RSVP_1 always
run letter_pairs_1 always
run response_selection_1 always
run determine_correct_response_1 always
run logger_1 always
run feedback_1 always
define loop standards_AB
set source_file ""
set source table
set skip 0
set repeat 1
set order random
set offset no
set item trial_sequence
set description "A single block of trials"
set cycles 7
set continuous no
set column_order ""
set break_if_on_first yes
set break_if never
setcycle 0 lag 1
setcycle 1 lag 2
setcycle 2 lag 3
setcycle 3 lag 4
setcycle 4 lag 5
setcycle 5 lag 6
setcycle 6 lag 7
run standard_AB_1
define loop standards_AB_2
set source_file ""
set source table
set skip 0
set repeat 1
set order random
set offset no
set item trial_sequence
set description "A single block of trials"
set cycles 7
set continuous no
set column_order ""
set break_if_on_first yes
set break_if never
setcycle 0 lag 1
setcycle 1 lag 2
setcycle 2 lag 3
setcycle 3 lag 4
setcycle 4 lag 5
setcycle 5 lag 6
setcycle 6 lag 7
run standard_AB_1_1
define loop time_report
set source_file ""
set source table
set repeat 1
set order random
set description "Repeatedly runs another item"
set cycles 0
set continuous no
set break_if_on_first yes
set break_if never
run time_report_sequence
define sequence time_report_sequence
set flush_keyboard yes
set description "Runs a number of items in sequence"
run fixation_2 always
run RSVP always
run new_form_base always