Пример #1
0
def main(yaml_file, kern_file='shorter-kernels.csv'):
    try:
        parms = yaml.load(open(yaml_file))
        base = dirname(yaml_file)
        if not base:
            base = '.'
    except:
        print "Problem with the YAML file!"
        exit(1)

    kernels_in = open_and_check(kern_file, 
                     ['Item.code', 'Value', 'Description', 'Format'] )

    kernels = {}
    for code, value, desc_text, format in kernels_in:
        if format:
            desc_text = '%s [%s]' % (desc_text, format)
        kernels[code] = (value, desc_text)

    order_in = open_and_check(join(base, parms['subj_order_file']), 
                                ['Item.code', 'Condition'])

    trials = []
    for code, cond in order_in:
        value, desc_text = kernels[code]
        fname = join(base, 'trial%02d.avi' % len(trials))
        trials.append( PresentKernel(cond, value, desc_text, fname) )

    stim_control = StimController(trials, vision_egg)
    stim_control.run_trials()

    stim_control.writelog(join(base, parms['log_file']))
Пример #2
0
#box = respbox.RespBox()

###########
# Stimuli #
###########
std_params = {'anchor': 'center', # for text display objects 
              'position': (xlim/2,ylim/2), 
              'on': False} 

rest = Text(text="Press space to begin.", **std_params)
fixation = Text(text="+", font_size=55, **std_params)
blank = Text(text="", **std_params)


trial_stims = [FaceStim(f) for f in (':-)', ':-(', ':-o')]
trials = [ExpTrial(s) for s in trial_stims]
random.shuffle(trials)
# A list of trials, using a super-pythonic list comprehension
# Trials are initialized with an 'events' arg which is a list of Event instances

vision_egg.set_stimuli([rest,fixation,blank]+trial_stims, trigger=K_SPACE)
# Give set_stimuli a list of stimulus objects as well as
# the pygame keypress which you want to begin the trials
stim_control = StimController(trials, vision_egg, pause_event=Event(rest,0,0))
# pause_event begins each block after a SPACE press.
# 'rest' is the name of my text stim

stim_control.run_trials(len(trials))
stim_control.writelog(stim_control.getOutputFilename(subject,'EXPERIMENT_TEMPLATE'))
# Change the experiment name and give it the subject at the beginning
Пример #3
0
if exp_type == 't':
    trial_stims = text_stims
elif exp_type == 'c':
    trial_stims = circ_stims
elif exp_type == 'both':
    trial_stims = circ_stims + text_stims

random.shuffle(trial_stims)
trials = [ExpTrial(s) for s in trial_stims]
final_trial = Trial([Event(rest, start = 0, duration = 3)], unlogged = True) 
trials += [final_trial] 

######################
# Run the experiment #
######################

vision_egg.set_stimuli([rest,fixation,blank]+trial_stims)
# Add the voice controller here ### 
vision_egg.presentation.add_controller(None, None, voice_controller) 
stim_control = StimController(trials, vision_egg)

stim_control.run_trials('all')
stim_control.writelog(stim_control.getOutputFilename(subject, 'VT_test'))

# Save the soundfiles during resting points or after the experiment is done.
# This will prevent the hardware access from messing with the stim/response
# timing. Remember to save the soundfiles!
voice_controller.write_soundfiles()