---
API: 2.1
Description: A simple word/ nonword categorization
OpenSesame: 3.3.0a49
Platform: posix
Title: Lexical-decision task
---
set width 1024
set uniform_coordinates no
set title "Lexical decision"
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 psycho
set round_decimals 2
set mouse_backend psycho
set keyboard_backend psycho
set height 768
set fullscreen no
set form_clicks no
set foreground white
set font_underline no
set font_size 32
set font_italic no
set font_family mono
set font_bold no
set experiment_path "/home/sebastiaan/git/OpenSesame/opensesame_extensions/example_experiments/examples/lexical_decision"
set disable_garbage_collection yes
set description "A simple lexical-decision example experiment"
set coordinates relative
set compensation 0
set color_backend psycho
set clock_backend psycho
set canvas_backend psycho
set bidi no
set background gray

define notepad about_this_example
	__note__
	In a lexical-decision experiment, the task is to categorize letter strings on
	some feature, such as wether they form a word (e.g. 'apple') or not
	(e.g. 'ipple'). Usually, the goal of a lexical-decision experiment is to analyze
	the response times to words as a function of another variable, that is, not the
	variable that participants base their response on.
	__end__
	set description "A simple notepad to document your experiment. This plug-in does nothing."

define loop block_loop
	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 6
	set continuous no
	set column_order "correct_response;target;category"
	set break_if_on_first yes
	set break_if never
	setcycle 0 correct_response "[word_response]"
	setcycle 0 category word
	setcycle 0 target apple
	setcycle 1 correct_response "[nonword_response]"
	setcycle 1 category nonword
	setcycle 1 target ipple
	setcycle 2 correct_response "[word_response]"
	setcycle 2 category word
	setcycle 2 target turtle
	setcycle 3 correct_response "[nonword_response]"
	setcycle 3 category nonword
	setcycle 3 target ourtel
	setcycle 4 correct_response "[word_response]"
	setcycle 4 category word
	setcycle 4 target magic
	setcycle 5 correct_response "[nonword_response]"
	setcycle 5 category nonword
	setcycle 5 target mocag
	run trial_sequence

define sequence block_sequence
	set flush_keyboard yes
	set description "A sequence containging a single block of trials followed by feedback to the participant"
	run reset_feedback always
	run block_loop always
	run feedback always

define inline_script counterbalance
	set description "Executes Python code"
	set _run ""
	___prepare__
	if var.subject_parity == 'odd':
	    var.word_response = 'z'
	    var.nonword_response = 'm'
	else:
	    var.word_response = 'm'
	    var.nonword_response = 'z'
	__end__

define sketchpad end_of_practice
	set duration keypress
	set description "Displays stimuli"
	draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="The practice phase is finished<br />The real experiment will start now<br /><br />Press any key to continue" x=0 y=0 z_index=0

define sequence experiment
	set flush_keyboard yes
	set description "Runs a number of items in sequence"
	run about_this_example always
	run counterbalance always
	run instructions always
	run practice_loop always
	run end_of_practice always
	run experimental_loop always
	run goodbye 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 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 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=sans font_italic=no font_size=32 html=yes show_if=always text="End of block [=var.count_block_sequence+1]<br /><br />Your average response time was [avg_rt] ms<br />Your accuracy was [acc] %<br /><br />Press any key to continue" x=0 y=0 z_index=0

define sketchpad fixation
	set start_response_interval no
	set duration 500
	set description "Displays stimuli"
	draw line color=white penwidth=2 show_if=always x1=-32 x2=32 y1=-32 y2=-32 z_index=0
	draw line color=white penwidth=2 show_if=always x1=-32 x2=32 y1=32 y2=32 z_index=0

define sketchpad goodbye
	set duration keypress
	set description "Displays stimuli"
	draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="The experiment is finished<br />Thank you for participating<br /><br />Press any key to exit" x=0 y=0 z_index=0

define sketchpad green_fix
	set start_response_interval no
	set duration 500
	set description "Displays stimuli"
	draw line color=green penwidth=2 show_if=always x1=-32 x2=32 y1=-32 y2=-32 z_index=0
	draw line color=green penwidth=2 show_if=always x1=-32 x2=32 y1=32 y2=32 z_index=0

define sketchpad instructions
	set duration keypress
	set description "Displays stimuli"
	draw textline center=1 color=white font_bold=no font_family=sans font_italic=no font_size=32 html=yes show_if=always text="Instructions<br /><br /><br />You will see strings of letters<br />Your task is to say whether these letters form a word or not<br /><br />If the letters form a word, press [word_response]<br />If the letters do not form a word, press [nonword_response]<br /><br />Examples<br /><br /><span style='mono'>apple</span> is a word, so you press [word_response]<br /><span style='mono'>ipple</span> is not a word, so you press [nonword_response]<br /><br /><br />Press a key to start practice" x=0 y=0 z_index=0

define keyboard_response keyboard_response
	set timeout 5000
	set flush yes
	set event_type keypress
	set duration keypress
	set description "Collects keyboard responses"
	set allowed_responses "z;m"

define logger logger
	set description "Logs experimental data"
	set auto_log yes

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 "Repeatedly runs another item"
	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 sketchpad red_fix
	set start_response_interval no
	set duration 500
	set description "Displays stimuli"
	draw line color=red penwidth=2 show_if=always x1=-32 x2=32 y1=-32 y2=-32 z_index=0
	draw line color=red penwidth=2 show_if=always x1=-32 x2=32 y1=32 y2=32 z_index=0

define reset_feedback reset_feedback
	set description "Resets the feedback variables, such as 'avg_rt' and 'acc'"

define sequence trial_sequence
	set flush_keyboard yes
	set description "A single trial"
	run fixation always
	run word always
	run keyboard_response always
	run red_fix "[correct] = 0"
	run green_fix "[correct] = 1"
	run logger always

define sketchpad word
	set start_response_interval no
	set duration 0
	set description "Displays stimuli"
	draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=32 html=yes show_if=always text="[target]" x=0 y=0 z_index=0
	draw line color=white penwidth=2 show_if=always x1=-32 x2=32 y1=-32 y2=-32 z_index=0
	draw line color=white penwidth=2 show_if=always x1=-32 x2=32 y1=32 y2=32 z_index=0

