# Generated by OpenSesame 0.27.2~pre4 (Frisky Freud) # Mon Apr 1 15:27:48 2013 (posix) # set foreground "white" set subject_parity "even" set description "A template containing a practice and an experimental phase" set title "Extended template" set compensation "0" set coordinates "relative" set height "768" set mouse_backend "xpyriment" set width "1024" set sampler_backend "legacy" set keyboard_backend "legacy" set background "black" set subject_nr "0" set canvas_backend "xpyriment" set start "experiment" set synth_backend "legacy" define inline_script determine_trial_type set _run "" ___prepare__ # Determine the trial type of the current trial # by 'popping' (i.e. taking without replacement) # one item from the previously-defined trial list. # We do this by using the built-in Python function pop(): trial_type = trial_list.pop() # Next, we should set the variable 'trial_type' to # make it available in the GUI (notably, the Run-if # boxes in the trial_sequence item). # We do this by using the built-in OpenSesame experiment # function exp.set(): exp.set("trial_type", trial_type) __end__ set description "Executes Python code" define inline_script determine_trial_order set _run "" ___prepare__ # Import the built-in Python module random: import random # Define counters: nTarget = 50 nNonTarget = 250 # Create a list containing for example 50 targets and # 250 non target: trial_list = ["target"]*nTarget+ ["non_target"]*nNonTarget # Shuffle the list by using the random.shuffle() function: random.shuffle(trial_list) # Check for two targets in a row: # Give the Boolean keepRunning a starting value: keepRunning = True # We walk through the list until our criteria are met: while keepRunning: # Set keepRunning to False keepRunning = False # For every item in the list, check whether this item AND the next # one are 'target' (note that we skip the very last one because # it has no following item): for i in range(len(trial_list)-1): # If the current item and the next one are 'target': if trial_list[i] == trial_list[i+1] == "target": # Set keepRunning to True, meaning the list doesn't meet our criteria yet: keepRunning = True # Swap the content of the current item and the previous one: trial_list[i], trial_list[i-1] = trial_list[i-1], trial_list[i] # And break from the current loop to walk through the list again: break # Make the trial_list global such that it becomes available in future inline_sript # items as well: global trial_list __end__ set description "Executes Python code" define loop block_loop set repeat "1" set description "A single block of trials" set item "trial_sequence" set column_order "" set cycles "300" set order "random" run trial_sequence define sketchpad non_target set duration "750" set description "Displays stimuli" draw rect -50 -50 100 100 fill=1 penwidth=1 color=red show_if="always" 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 determine_trial_order "always" run block_loop "always" define sketchpad fixdot set duration "500" set description "Displays stimuli" set start_response_interval "no" draw fixdot 0 0 color=white show_if="always" define sketchpad target set duration "750" set description "Displays stimuli" draw circle 0 0 143.10835056 fill=1 penwidth=1 color=blue show_if="always" define sequence trial_sequence set flush_keyboard "yes" set description "A single trial" run determine_trial_type "always" run target "[trial_type] = target" run non_target "[trial_type] = non_target" run fixdot "always" run logger "always" define loop experimental_loop set repeat "1" set description "A loop containing one or more experimental blocks" set item "block_sequence" set column_order "practice" set cycles "1" set order "random" setcycle 0 practice "no" run block_sequence define sequence experiment set flush_keyboard "yes" set description "The main sequence of the experiment" run experimental_loop "always" define logger logger set description "Logs experimental data"