stimscr[trial['nstim']].update(stimlocs, stimoris, \ linewidth=None, stimtypes=stimtypes) # Update the probe Screen. probelw = trial['nstim'] * [STIMLINEWIDTH] probelw[probed] = PROBELINEWIDTH probeoris = trial['nstim'] * [0] probestimtypes = trial['nstim'] * ['noise'] probescr[trial['nstim']].update(stimlocs, probeoris, \ linewidth=probelw, stimtypes=probestimtypes) # RUN # Show the fixation Screen. disp.fill(fixscr) fixonset = disp.show() timer.pause(random.randint(FIXTIME[0], FIXTIME[1])) # Show the stimulus Screen. disp.fill(stimscr[trial['nstim']]) stimonset = disp.show() timer.pause(STIMTIME) # Show a blank Screen. disp.fill(blankscr) maintenanceonset = disp.show() timer.pause(MAINTENANCETIME) # Show the probe Screen. disp.fill(probescr[trial['nstim']])
# visuals disp = Display() scr = Screen() # input tracker = EyeTracker(disp) kb = Keyboard(keylist=None, timeout=None) # calibrate tracker.calibrate() # starting screen scr.clear() scr.draw_text(text="Press Space to start") disp.fill(scr) disp.show() kb.get_key(keylist=['space'], timeout=None, flush=True) # # # # # # VALIDATION # loop through points for i in range(len(CALIBPOINTS)): # get coordinate x, y = CALIBPOINTS[i] # draw calibration point scr.clear() scr.draw_fixation(fixtype='dot', pos=(x,y)) disp.fill(scr)
from constants import * from pygaze.display import Display from pygaze.screen import Screen from pygaze.eyetracker import EyeTracker disp = Display() tracker = EyeTracker(disp) scr.draw_text(text="Resetting connection to %s tracker" % (TRACKERTYPE), \ fontsize=24) disp.fill(scr) disp.show() try: tracker.stop_recording() except: print("Could not stop recording") tracker.close() disp.close()
frame = numpy.zeros((height, width, 3), dtype=float) # Now create a PsychoPy ImageStim instance to draw the frame with. stim = ImageStim(pygaze.expdisplay, image=frame, size=(width, height)) # When DISPTYPE='psychopy', a Screen instance's screen property is a list # of PsychoPy stimuli. We would like to add the ImageStim we just created # to that list, and record at what index in the list it was added. # First we get the current length of the stimscr's list of stimuli, which # will be the index at which the new ImageStim will be assigned to. stim_index = len(stimscr.screen) # Then we add the ImageStim to the stimscr. Every time you call # disp.fill(stimscr) and then disp.show(), all stimuli in stimscr # (including the ImageStim) will be drawn. stimscr.screen.append(stim) # Wait until the participant presses any key to start. disp.fill(textscr) disp.show() kb.get_key(keylist=None, timeout=None, flush=True) # Log the start of the trial. log.write([time.strftime("%y-%m-%d"), time.strftime("%H-%M-%S"), \ trialnr, vidname, timer.get_time()]) # Start eye tracking. tracker.start_recording() timer.pause(5) tracker.log("TRIALSTART") # Show a status message on the EyeLink. if TRACKERTYPE == 'eyelink': tracker.status_msg("Trial %d/%d (%s)" %
# RUN # run until a minute has passed t0 = timer.get_time() t1 = timer.get_time() text = "Test the joystick!" while t1 - t0 < 60000: # get joystick input event, value, t1 = js.get_joyinput(timeout=10) # update text if event != None: text = text="%s: %s" % (event, value) if event == 'joyaxismotion' and RUMBLE: set_vibration(0, max(0, value[2]), max(0, -value[2])) # display on screen scr.clear() scr.draw_text(text="%s\n\n(%.2f)" % (text, float(t1-t0)/1000.0), fontsize=24) # show text disp.fill(scr) disp.show() # # # # # # CLOSE # reset rumble to 0 if RUMBLE: set_vibration(0, 0, 0) # close the Display disp.close()
# -*- coding: utf-8 -*- """ Created on Thu Nov 10 13:29:48 2016 @author: adam """ from pygaze.display import Display from pygaze.screen import Screen import pygaze.libtime as timer # disp = Window(size=DISPSIZE, units='pix', fullscr=True) disp = Display() fixscreen = Screen() fixscreen.draw_fixation(fixtype='dot') imgscreen = Screen() imgscreen.draw_image('/home/adam/Desktop/experiment0/Example.png') disp.fill(fixscreen) disp.show() timer.pause(1000) disp.fill(imgscreen) disp.show() timer.pause(2000) disp.close()
import pygaze.libtime as timer from scansync.mri import MRITriggerBox ############## # 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.
# Create a new GratingStim. Using the noise array as # texture will result in visual snow. The mask is Gaussian # (to match the Gabor). noisepatch = GratingStim(pygaze.expdisplay, tex=noise, \ mask='gauss', size=200) # Initialize a new Screen instance for the noise. noisescreen = Screen() # Add the GratingStim to the Screen's screen property (as # with Gabor). noisescreen.screen.append(noisepatch) # Fill the Display with the Gabor Screen that ws prepared # earlier. disp.fill(gaborscreen) # Present the Display (Gabor will now be on the monitor). disp.show() # Wait for 1000 milliseconds (Gabor is still on the # monitor). timer.pause(1000) # Fill the Display with the noise Screen that ws prepared # earlier. disp.fill(noisescreen) # Present the Display (noise is now on the monitor). disp.show()
# 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() # # # # # # test Keyboard # test set_keylist, set_timeout and get_key scr.clear() scr.draw_text("The keylist has been set to ['1','5','e','s','left','space']; \ please confirm that you can press these keys and not any other key. Note that \ if you press Space, the test will advance to the next phase! \ \n\n\nThis tests: \ \n- Keyboard.set_keylist \
import pygaze.libtime as timer from libmeg import * #%% # # # # # # INITIALISE # Initialise a new Display instance. 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)
trial = {'cueside': cueside, \ 'tarside': tarside, \ 'target': tar, \ 'soa': soa} #alltrials.append(trial) #Adicionar a dict 'trial' dentro da lista 'alltrials' alltrials.extend(TRIALREPEATS * [trial]) #Vinculando a constante TRIALREPEATS random.shuffle(alltrials) # RANDOMIZAR A ORDEM DOS ENSAIOS ''' Apresentação das instruções o voluntário deverá apertar a barra de espaço ''' disp.fill(instscr) disp.show() kb.get_key(keylist='space', timeout=None) #timer.pause(20000) ''' Loop para realizar a tarefa N ensaiios ''' for trial in alltrials: ''' Apresentação da tela de fixação ''' disp.fill(fixscr) fixonset = disp.show() timer.pause(FIXTIME)
center=True, fontsize=30) count += 1 xcor += t_side ycor += t_side ##Set number of games played rounds = 4 tracker = EyeTracker(disp) ##Experiment choice = [] wait = True while wait == True: disp.fill(introscreen) disp.show() pressed = mse.get_pressed() if sum(pressed) > 0: event.clearEvents(eventType='mouse') wait = False pressed = [0, 0, 0] wait = True while wait == True: tryscreen = exscreen tryscreen.draw_text('Press the \n middle button', pos=(((1 - margin) / 4) * xax, ((1 - margin) / 4) * yax), fontsize=20) disp.fill(tryscreen)
"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) disp.show() timer.pause(3000) # Create a list of all trials. trials = [] # Add all the words. for word in WORDS: t = {} t["type"] = "word" t["stimulus"] = word trials.append(t) # Add all the nonwords. for word in NONWORDS: t = {} t["type"] = "nonword"
# GENERAL # Total number of points. total = 0.0 # Create a colour wheel to select colours from for the stimuli. cw = create_colourwheel(STIML, STIMR, savefile='colourwheel.png') # PYGAZE # Initialise a new Display instance disp = Display() # Initialise a Screen instance for arbitrary drawing. scr = Screen() scr.draw_text(text="Initialising the experiment...", fontsize=FONTSIZE) disp.fill(scr) disp.show() # Initialise the ka-ching sound. kaching = Sound(soundfile=KACHING) # Initialise a Keyboard and a Mouse instance for participant interaction. kb = Keyboard() mouse = Mouse() # COMMUNICATIONS timer.pause(5000) _print("Initialising Client.") # Initialise a new Client instance. client = Client(multicast_ip)