Created
December 15, 2011 10:08
-
-
Save smathot/1480593 to your computer and use it in GitHub Desktop.
OpenSesame correction trials example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by OpenSesame 0.25 (Dashy Darwin) | |
# Thu Dec 15 11:06:26 2011 (posix) | |
# | |
# Copyright Sebastiaan Mathot (2010-2011) | |
# <http://www.cogsci.nl> | |
# | |
set foreground "white" | |
set subject_parity "even" | |
set description "A template containing a practice and an experimental phase" | |
set title "Repeat trials" | |
set sampler_backend "legacy" | |
set coordinates "relative" | |
set height "768" | |
set mouse_backend "legacy" | |
set width "1024" | |
set compensation "0" | |
set keyboard_backend "legacy" | |
set background "black" | |
set subject_nr "0" | |
set canvas_backend "legacy" | |
set start "experiment" | |
set synth_backend "legacy" | |
define notepad about_this_template | |
__note__ | |
Hi, | |
This template already contains the basic structure | |
needed for a typical experiment, consisting of a | |
practice phase, followed by an experimental phase. | |
For more information, please refer to the website: | |
<http://www.cogsci.nl/opensesame> | |
Have fun with OpenSesame! | |
-- | |
Sebastiaan | |
__end__ | |
set description "Some pointers to help you gest started!" | |
define loop repeat_loop | |
set repeat "100" | |
set description "Repeatedly runs another item" | |
set item "trial_sequence" | |
set column_order "is_repeat" | |
set cycles "1" | |
set order "random" | |
setcycle 0 is_repeat "yes" | |
run trial_sequence | |
define text_display _text_display | |
set description "Presents a display consisting of text" | |
define text_display repeat_msg | |
set foreground "white" | |
set font_size "18" | |
set description "Presents a display consisting of text" | |
set maxchar "50" | |
set align "center" | |
set content "Now we're going to repeat the left-over trials" | |
set background "black" | |
set duration "keypress" | |
set font_family "mono" | |
define inline_script get_repeat | |
set _run "" | |
___prepare__ | |
import random | |
# By default, do *not* skip the trial | |
self.experiment.set('skip_trial', 'no') | |
# If this is a repeat trial, we should load the conditions from | |
# the correction_trials list | |
if self.get('is_repeat') == 'yes': | |
# If the correction_trials list is empty, there is nothing to | |
# repeat so we skip the trial | |
if len(self.experiment.correction_trials) == 0: | |
self.experiment.set('skip_trial', 'yes') | |
# Otherwise, restore the conditions from the correction_trials list | |
else: | |
random.shuffle(self.experiment.correction_trials) | |
d = self.experiment.correction_trials.pop() | |
print 'Restoring %s' % d | |
for cond in d: | |
self.experiment.set(cond, d[cond]) | |
__end__ | |
set description "Executes Python code" | |
define loop block_loop | |
set repeat "2" | |
set description "A single block of trials" | |
set item "trial_sequence" | |
set column_order "is_repeat;my_condition1;my_condition2" | |
set cycles "2" | |
set order "random" | |
setcycle 0 my_condition2 "a" | |
setcycle 0 my_condition1 "1" | |
setcycle 0 is_repeat "no" | |
setcycle 1 my_condition2 "b" | |
setcycle 1 my_condition1 "2" | |
setcycle 1 is_repeat "no" | |
run trial_sequence | |
define inline_script init | |
set _run "" | |
___prepare__ | |
# A list to store correction trials. | |
self.experiment.correction_trials = [] | |
__end__ | |
set description "Executes Python code" | |
define sequence experiment | |
set flush_keyboard "yes" | |
set description "The main sequence of the experiment" | |
run init "always" | |
run about_this_template "always" | |
run block_loop "always" | |
run repeat_msg "always" | |
run repeat_loop "always" | |
define sequence trial_sequence | |
set flush_keyboard "yes" | |
set description "A single trial" | |
run get_repeat "always" | |
run text_display "[skip_trial] = no" | |
run keyboard_response "[skip_trial] = no" | |
run logger "[skip_trial] = no" | |
run set_repeat "[skip_trial] = no" | |
define keyboard_response keyboard_response | |
set description "Collects keyboard responses" | |
set timeout "infinite" | |
set flush "yes" | |
define logger logger | |
set description "Logs experimental data" | |
define inline_script set_repeat | |
___run__ | |
# A list of your conditions | |
my_conditions = ['my_condition1', 'my_condition2'] | |
# Some criterion for when the trial should be repeated | |
if self.get('response') == 'r': | |
# Store all conditions of the current trial and add | |
# them to the correction_trials list | |
d = {} | |
for cond in my_conditions: | |
d[cond] = self.experiment.get(cond) | |
print 'Adding %s' % d | |
self.experiment.correction_trials.append(d) | |
__end__ | |
set _prepare "" | |
set description "Executes Python code" | |
define text_display text_display | |
set foreground "white" | |
set font_size "18" | |
set description "Presents a display consisting of text" | |
set maxchar "50" | |
set align "center" | |
__content__ | |
TRIAL [count_trial_sequence] | |
my_condition1 = [my_condition1] | |
my_condition2 = [my_condition2] | |
is_repeat = [is_repeat] | |
Press 'r' to repeat this trial and | |
another key to continue. | |
__end__ | |
set background "black" | |
set duration "0" | |
set font_family "mono" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment