# initialize an EyeTracker tracker = EyeTracker(disp) # initialize a keyboard kb = Keyboard(keylist=['space'], timeout=None) # initialize a sound snd = Sound(soundfile=soundfile) # initialize a Timer timer = Time() # create a new logfile log = Logfile(filename="test") log.write(["test", "time"]) # # # # # # welcome scr.draw_text("Welcome to the PyGaze Supertest!\n\nYou're going to be testing \ your PyGaze installation today, using this interactive tool. Press Space \ to start!\n\n\nP.S. If you see this, the following functions work: \ \n- Screen.draw_text \ \n- Disp.fill \ \n- Disp.show \ \nAwesome!") disp.fill(scr) t1 = disp.show() log.write(["welcome", t1]) kb.get_key()
# Initialise the basic input devices. kb = Keyboard(keylist=None, timeout=None) mouse = Mouse(mousebuttonlist=None, timeout=None) # Initialise a log. log = Logfile() header = ['trialnr', 'nstim', 'fixonset', 'stimonset', 'maintenanceonset', \ 'probeonset', 'RT', 'response'] for i in range(max(NSTIM)): header.extend(['stimx%d' % (i), 'stimy%d' % (i), 'stimori%d' % (i), \ 'stimerror%d' % (i)]) header.extend(['E', 'X', 'T']) for i in range(max(NSTIM)-1): header.append('NT%d' % i) log.write(header) # Initialise a blank Screen for ad-hoc drawing. scr = Screen() # Initialise a blank Screen. blankscr = Screen() # Initialise a fixation Screen. fixscr = Screen() fixscr.draw_fixation(fixtype=FIXTYPE, diameter=FIXSIZE, pw=FIXPW) # Initialise stimulus and probe Screens. stimscr = {} probescr = {} for nstim in NSTIM:
# INITIALISE # ############## # Initialise a new Display instance. disp = Display() # Present a start-up screen. scr = Screen() scr.draw_text("Loading, please wait...", fontsize=24) disp.fill(scr) disp.show() # Open a new log file. log = Logfile() # TODO: Write header. log.write(["trialnr", "block", "run","stim", "keypress", "go_nogo", "face_onset", "signal_onset","resp_onset", "RT", "accuracy", "respmap", "block_type"]) # Open a new log file to log events. event_log = Logfile(filename=EVENT_LOG) event_log.write(["time", "event"]) # Initialise the eye tracker. tracker = EyeTracker(disp) # Create a new Keyboard instance to process key presses. kb = Keyboard(keylist=None, timeout=5000) mouse = Mouse() # intitliase the MEG interface NI box if MRI: trigbox = MRITriggerBox()
# Start a new Display instance to be able to show things on the monitor. # The important parameters will automatically be loaded from the constants. disp = Display() # Initialise a Keyboard instance to detect key presses. Again, important # parameters will be loaded from the constants. kb = Keyboard() # Initialise the EyeTracker and let it know which Display instance to use by # passing it to the EyeTracker. tracker = EyeTracker(disp) # Create a Logfile instance that keeps track of when videos start. log = Logfile() # Write a header to the log file. log.write(['date', 'time', 'trialnr', 'video', 'timestamp']) # # # # # # SCREENS # Create a screen to show instructions on. textscr = Screen() textscr.draw_text("Press any key to start the next video.", fontsize=24) # Create a screen to show images on. This will be the screen that we will use # to display each video frame. stimscr = Screen() # # # # # # PLAY VIDEOS
# initialize a sound snd = Sound(osc='sine', freq=4400, length=3000) sounds = { 'a sine wave (slightly oscillating)':Sound(osc='sine', freq=440, length=5000, attack=1000, decay=1000), 'a saw wave':Sound(osc='saw', freq=880, length=5000, attack=0, decay=0), 'a square wave':Sound(osc='square', freq=1760, length=5000, attack=0, decay=0), 'white noise':Sound(osc='whitenoise'), 'soundfile':Sound(soundfile=soundfile) } # initialize a Timer timer = Time() # create a new logfile log = Logfile(filename="test") log.write(["test", "time"]) # # # # # # welcome scr.draw_text("Welcome to the PyGaze Supertest!\n\nYou're going to be testing \ your PyGaze installation today, using this interactive tool. Press Space \ to start!\n\n\nP.S. If you see this, the following functions work: \ \n- Screen.draw_text \ \n- Disp.fill \ \n- Disp.show \ \nAwesome!") disp.fill(scr) t1 = disp.show() log.write(["welcome", t1])
# initialize a screen scr = Screen() # initialize an EyeTracker tracker = EyeTracker(disp) # initialize a keyboard kb = Keyboard(keylist=['space'],timeout=None) # initialize a Timer timer = Time() # create a new logfile log = Logfile(filename="test") log.write(["x_pos","y_pos", "time"]) # # # # # # test gaze contingency # UI test scr.clear() scr.draw_image(image_file) x = (DISPSIZE[0] - IMGSIZE[0]) / 2 # centre minus half of the image width y = (DISPSIZE[1] - IMGSIZE[1]) / 2 # centre minus half of the image height aoi = AOI('rectangle', (x,y), IMGSIZE) disp.fill(scr) t1 = disp.show() key = None tracker.start_recording() while key != 'space':
disp = Display() # Present a start-up screen. scr = Screen() scr.draw_text("Loading, please wait...", fontsize=MAIN_FONTSIZE) disp.fill(scr) disp.show() # Open a new log file. log = Logfile(filename = LOGFILE) log_det = Logfile(filename = DETAILED_LOGFILE) log_events = Logfile(filename = EVENT_LOGFILE) # TODO: Write header. log.write(["trialnr","left_ang","right_ang", "cue_dir", "targ", "targ_ang", "resp_ang", "perc_diff", "resp_onset", "resp_duration", "iti", "iti_onset", "stim_onset","delay_onset", "cue_onset", "postcue_onset","probe_onset", "prac"]) log_det.write(["trialnr", "timestamp", "angle", "event", "targ_ang", "cue_dir"]) log_events.write(["Trigger", "Timestamp"]) # Initialise the eye tracker. tracker = EyeTracker(disp) # Create a new Keyboard instance to process key presses. kb = Keyboard(keylist=None, timeout=5000) mouse = Mouse() mouse.set_visible(visible=False) # intitliase the MEG interface NI box if MEG: trigbox = MEGTriggerBox() # initialise a function
############## # Initialise a new Display instance. disp = Display() # Present a start-up screen. scr = Screen() scr.draw_text("Loading, please wait...", fontsize=24) disp.fill(scr) disp.show() # Open a new log file. log = Logfile() # TODO: Write header. log.write([ "trialnr", "block", "run", "stim", "keypress", "go_nogo", "face_onset", "signal_onset", "resp_onset", "RT", "accuracy", "respmap", "block_type" ]) # Open a new log file to log events. event_log = Logfile(filename=EVENT_LOG) event_log.write(["time", "event"]) # Initialise the eye tracker. tracker = EyeTracker(disp) # Create a new Keyboard instance to process key presses. kb = Keyboard(keylist=None, timeout=5000) mouse = Mouse() # intitliase the MEG interface NI box if MRI:
validity = 0 ''' Apresentar o feedback ''' disp.fill(fbscr[correct]) disp.show() timer.pause(FEEDBACKTIME) # Construindo o arquivo de Logfile dos dados # Definindo um cabeçalho header = ['fixonset', 'cueonset', 'cueoffset', \ 'taronset', 'cueside', 'tarside', 'valid', \ 'soa', 'target', 'response', 'correct', 'RT'] # Adicionar o cabeçalho ao logfile log.write(header) # Iniciar o armazenamento de todos os logs dos ensaios realizados: log.write([fixonset, cueonset, cueoffset, taronset,\ trial['cueside'], trial['tarside'], validity,\ trial['soa'], trial['target'], response, \ correct, RT]) # Fechar o logfile log.close() # Fechar o experimento disp.close()
timer = Time() # initialize the display for stimuli disp = Display(disptype="psychopy", dispsize=c.TOBII_DISPSIZE, screennr=0, bgc="grey") # initialize a tobiitracker tracker = InfantTobiiTracker(disp, logfilepath) # create a new logfile (for TESTing purposes only) eventlog = Logfile(filename="{0}\subj{1}_caliblog_{2}".format( logfolderpath, subjectNumber, datenow)) eventlog.write([ "\nDate and time of experiment: {0}".format( datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) ]) eventlog.write(["Subject number: {0}".format(subjectNumber)]) eventlog.write([ "Test positions: 1. interesting: {0}, 2. interesting: {1}".format( test_shelves[0], test_shelves[1]) ]) eventlog.write(["Subject code: {0}".format(newSubject.subject_code)]) eventlog.write([ "Subject's age: {0} months and {1} days\n".format( newSubject.subject_age[:2], newSubject.subject_age[2:]) ]) eventlog.write(["\nEVENT", "TIME"]) ### calibration print("\n\tInfant calibration module.\n\t-> Press 'space' to start!\n")
# initialize an EyeTracker tracker = EyeTracker(disp) # initialize a keyboard kb = Keyboard(keylist=['space'],timeout=None) # initialize a sound snd = Sound(soundfile=soundfile) # initialize a Timer timer = Time() # create a new logfile log = Logfile(filename="test") log.write(["test", "time"]) # # # # # # welcome scr.draw_text("Welcome to the PyGaze Supertest!\n\nYou're going to be testing \ your PyGaze installation today, using this interactive tool. Press Space \ to start!\n\n\nP.S. If you see this, the following functions work: \ \n- Screen.draw_text \ \n- Disp.fill \ \n- Disp.show \ \nAwesome!") disp.fill(scr) t1 = disp.show() log.write(["welcome", t1])
from pygaze.screen import Screen from pygaze.sound import Sound from pygaze.keyboard import Keyboard from pygaze.logfile import Logfile import pygaze.libtime as timer # Create a new Display instance. disp = Display() # Create a new Keyboard instance. kb = Keyboard() # Create a new Logfile instance. log = Logfile() log.write(["trialnr", "trial_type", "stimulus", \ "fix_onset", "stim_onset", "response", "RT", \ "correct"]) # Create a BAD sound. bad_sound = Sound(osc="whitenoise", length=200) bad_sound.set_volume(1) good_sound = Sound(osc="sine", freq=440, length=200) good_sound.set_volume(0.5) # Create a new Screen instance. scr = Screen() scr.draw_text("Welcome!", fontsize=100, \ colour=(255,100,100)) # Pass the screen to the display. disp.fill(scr)
# Create a logfile now that we know the client number logpath = os.path.join(DATADIR, '%d_%s' % (clientnr, LOGFILENAME)) log = Logfile(filename=logpath+'_beh') # Write a header to the log header = ['trialnr', \ 'nstim', 'rewtype', 'rewamount', 'reward', 'total', \ 'fixonset', 'stimonset', 'maintenanceonset', 'probeonset', 't1', 'rewardonset', \ 'RT', 'nfixself', 'nfixother', 'probedstim', 'response'] for stimnr in range(max(NSTIM)): header.extend(['self_fixated%d' % stimnr, 'other_fixated%s' % stimnr, \ 'rewarded%d' % stimnr, 'ori%d' % stimnr, 'XYloc%d' % stimnr, \ 'error%d' % stimnr]) header.extend(['E', 'X', 'T']) for i in range(max(NSTIM)-1): header.append('NT%d' % i) log.write(header) # Initialise the eye tracker. _print("Initialising EyeTracker.") tracker = EyeTracker(disp, logfile=logpath+'_eye') #tracker.calibrate() # # # # # # RUN TRIALS _print("Starting experiment. Clientnr=%d.\n" % (clientnr)) # Run until the server stops the experiment. ntrials = 0 running = True