instruct_text = [ "Welcome to the experiment.\nToday you'll see a lot of pictures.", "If the picture shows something a Nochmani would eat,\npress the %s button to EAT it.\n\nIf the picture shows something a Nochmani would not eat,\npress the %s button to NOT EAT it." % (APPROACH_SIDE_FIRST, WITHDRAW_SIDE_FIRST), "Please press the buttons as quickly as you can.", "Ready to start?", ] instruct_text = [s + "\n\n\nPress SPACE to continue." for s in instruct_text] instructions = [InstructTrial(s) for s in instruct_text] switch_text = ( "That was the first half of the experiment.\n For the next part, you'll do the same thing, but switch hands.\nNow, press the %s button for something a Nochmani would EAT,\nand the %s button for something a Nochmani would NOT EAT.\n\nPlease let the experimenter know when you're ready to go on." % (WITHDRAW_SIDE_FIRST, APPROACH_SIDE_FIRST) ) switch_inst = InstructTrial(switch_text) # put all the trials together w/ instructions in the right place all_trials = instructions + trials[: len(trials) / 2] + [switch_inst] + trials[len(trials) / 2 :] ############### # Run the exp # ############### exp_stimuli = [rest_screen, fixation, blank, switch_inst.stim] + [s.stim for s in instructions] + stim_list vision_egg.set_stimuli(exp_stimuli) # stim_control = StimController(all_trials, # vision_egg, pause_event = Event(rest_screen, 0, 0)) stim_control = StimController(all_trials, vision_egg) stim_control.run_trials(len(all_trials)) stim_control.writelog(stim_control.getOutputFilename(SUBJECT, "MotivHand")) print "\n\n\n\n\n\t\tThanks for participating!\n\n\n\n\n"
#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
cues = ['G','N'] fixation = dict((cue, Text(text=cue, font_size=55, position=center, anchor='center', on=False)) for cue in cues) # Note, prior to python3, need a float to avoid integer division x_positions = [xlim * frac / 6.0 for frac in range(1, 5)] trial_stims = [FilledCircle(radius=10.0, position=(xpos, ylim/2), on=False) for xpos in x_positions] # Give set_stimuli a list of stimulus objects as well as # the pygame keypress which you want to begin the trials # Setting the trigger here seems a little out of place... something to clean up # at a later date vision_egg.set_stimuli([rest]+fixation.values()+trial_stims, trigger=K_SPACE) ############# # Structure # ############# """ Events take: first, the stim used, a VisionEgg.Stimulus class instance start, duration, stop -- times in seconds since beginning of Trial log -- a dict response - a Response instance which take args: label (how the response is named in the csv) limit -- if you give it key values (e.g. ("l","m") accepts only those) buttonbox -- a parallel.respbox.RespBox instance this gives back the integer 2^x, x indexes the finger dont give it a limit if you do this"""
] instruct_text2 = [ s + "\n\nPress SPACE to continue." for s in instruct_text2 ] instructions2 = [InstructTrial(s) for s in instruct_text2] all_trials = instructions + treatment_trials + instructions2 + trials exp_stimuli = [rest_screen, fixation, mask, blank] + \ [s.stim for s in instructions] + [s.stim for s in instructions2] + flat_list else: quit('Time must be 1, 2, 3, 4') ############### # Run the exp # ############### vision_egg.set_stimuli(exp_stimuli) stim_control = StimController(all_trials, vision_egg) stim_control.run_trials(len(all_trials)) if time_point == 1: stim_control.writelog( stim_control.getOutputFilename('results/T1_' + str(SUBJECT), 'DP_LDT')) else: stim_control.writelog( stim_control.getOutputFilename( 'results/T' + str(time_point) + '_' + str(SUBJECT), 'DP_LDT')) print '\n\n\n\n\n\t\tThis section is complete. Please inform the experimenter.\n\n\n\n\n'