def main(): parser = argparse.ArgumentParser() parser.add_argument('image1', type=str, help='Required: Filename for image 1') parser.add_argument('image2', type=str, help='Required: Filename for image 2') parser.add_argument('--n_iters', type=int, default=10, help='Number of iterations [default=10]') parser.add_argument('--timing', default=1000, help='Duration displayed for each image in millis.') parser.add_argument('--displaynumber', default=1, type=int, help='Monitor to show the task.') parser.add_argument('--resolution', default='1920 1080', type=str, help='The dimensions of the display in pixels e.g. 1920 1080') parser.add_argument('--testing', action='store_true', default=False) app = QtGui.QApplication(sys.argv) a = ArgparseUi(parser, use_save_load_button=True, window_title='Run Image Flash Task' ) a.show() app.exec_() args = a.parse_args() resolution = [int(x) for x in args.resolution.split()] display = Display(disptype='psychopy', dispsize=resolution, screennr=args.displaynumber) screen_params = dict(disptype='psychopy', dispsize=resolution, screennr=args.displaynumber ) images = [] images.append(args.image1) images.append(args.image2) try: open_images = [Image.open(x) for x in images] except Exception: err_msg = "The image(s) %s and %s do not appear to be the correct filename or path" % tuple(images) window = tkinter.Tk() window.wm_withdraw() tkMessageBox.showinfo(title="ERROR: Unable to open images", message=err_msg) window.destroy() sys.exit() if args.testing: tobii = FakeEyeTracker() print("Using FakeEyeTracker.") else: tobii = EyeTracker(display, trackertype='tobii') print("Using real EyeTracker") task = Task(screen_params, display, open_images, delta_t=args.timing, n_iters=args.n_iters, eyetracker=tobii) task.start() display.close()
#!/usr/bin/env python # from psychopy import * import game import pygame import avalgame import text_input from pygaze.eyetracker import EyeTracker from pygaze.libscreen import Screen, Display from pygame.display import list_modes print list_modes() pygame.init() disp = Display() clock = pygame.time.Clock() ### Definitions ###### Resolution #win_size = pygame.display.Info() #windowSize = pygame.display.set_mode((win_size.current_w, win_size.current_h), pygame.FULLSCREEN) # Change as you want (MUST RESPECT DISPLAY DIMENSIONS) windowSize = pygame.display.set_mode((1024, 768), pygame.FULLSCREEN) running = True version = "v1.00" avalgame = avalgame.Avalgame() class GameSettings(pygame.font.Font): def __init__(self, screen, display, bg_color=(0, 0, 0), font='media/fonts/arial.ttf',
from pygaze import libtime from pygaze.libscreen import Display, Screen from pygaze.libinput import Keyboard from pygaze.eyetracker import EyeTracker import random # # # # # # prep # create keyboard object keyboard = Keyboard() # display object disp = Display() # screen objects screen = Screen() blankscreen = Screen() hitscreen = Screen() hitscreen.clear(colour=(0,255,0)) misscreen = Screen() misscreen.clear(colour=(255,0,0)) # create eyelink objecy eyetracker = EyeTracker(disp) # eyelink calibration eyetracker.calibrate()
from constants import * from pygaze import libtime from pygaze.libscreen import Display, Screen from pygaze.eyetracker import EyeTracker from pygaze.libinput import Keyboard from pygaze.liblog import Logfile from pygaze.libgazecon import FRL # timing and initialization libtime.expstart() # visuals disp = Display() scr = Screen() # eye tracking tracker = EyeTracker(disp, trackertype='dummy') frl = FRL(pos='center', dist=125, size=200) # input collection and storage kb = Keyboard(keylist=['escape', 'space'], timeout=None) log = Logfile() log.write(["trialnr", "trialstart", "trialend", "duration", "image"]) # run trials tracker.calibrate() for trialnr in range(0, len(IMAGES)): # blank display disp.fill() disp.show() libtime.pause(1000)
withTracker = cst.TRACKER run = r.RUN DISPSIZE = (res[0],res[1]) #find interstimulus distance, based on resolution and view distance, for #4' viewing angle; since PsychoPy calculates distance on centerpoint, adding #128 (half of stimulus width) base_dist = (2 * dist * math.tan(math.radians(4)/2)) base_dist_half = base_dist / 2 pixpcm = res[0] / res[2] base_dist_pix = int(base_dist_half * pixpcm) + 128 # In[Initiate PyGaze Objects]: disp = Display(disptype='psychopy') scr = Screen(disptype='psychopy') if inScanner or withTracker: kb = Keyboard() if withTracker: tracker = EyeTracker(disp) DISPSIZE = cst.DISPSIZE fps_str = str(flicker).replace('.','_') basename = "{}_{}".format(subid, fps_str) LOGFILENAME = basename + '_eyetracker' director = os.getcwd()
import os import random # PyGaze from constants import * from pygaze.libscreen import Display, Screen from pygaze.libinput import Keyboard from pygaze.eyetracker import EyeTracker from pygaze.liblog import Logfile import pygaze.libtime as timer from pygaze.plugins.aoi import AOI # # # # # # SETUP # visuals disp = Display() scr = Screen() # input kb = Keyboard() tracker = EyeTracker(disp) # output log = Logfile(filename="fs_test") log_sub = Logfile(filename="fs_test_sub") log.write(["ntrials", "image", "gaze_pos_x", "gaze_pos_y", "gaze_time"]) log_sub.write(["ntrials", "image", "is_found", "search_time"]) # # # # # # PREPARE # load instructions from file
from pygaze.libscreen import Display, Screen from pygaze.libinput import Keyboard from libmpdev import * import time import math import matplotlib.pyplot as plt # create a Display to interact with the monitor disp = Display() # create a Screen to draw text on later scr = Screen() # create a Keyboard to catch key presses kb = Keyboard(keylist=['escape'], timeout=1) # create a MPy150 to communicate with a BIOPAC MP150 mp = MP150() Y=[0]; t1 = time.time(); T=[0]; # set a starting value for key key = None # loop until a key is pressed while key == None: # get a new sample from the MP150 sample = mp.sample()
from constants import * #from image_set_generation1 import make_image_set from generate_image_sets_with_circles_squares import generate import numpy as np from pygaze.libgazecon import AOI from faceconstants import * from swap_images import swap import random import pygame import time center_of_screen = (DISPSIZE[0] / 2, DISPSIZE[1] / 2) image_HW = 326 # create display object disp = Display() # create eyetracker object tracker = eyetracker.EyeTracker(disp) # create keyboard object keyboard = Keyboard(keylist=['space', "q", "escape"], timeout=1) # create logfile (txt file that is tab seperated, I think) our_log = liblog.Logfile() # write "headlines" to log file our_log.write( ["trialnr", "trialstart", "trialend", "disengagementtime", "imagepair"]) # fill in with the neccecary headlines # calibrate the eye-tracker
#can check for shuffle #for image in all_image_set: #print(image) # In[3]: #DUMMYMODE = True # set in constants.py # To use your code with the new Tobii Pro SDK, # set the TRACKERTYPE to 'tobii' # start timing libtime.expstart() # create display object disp = Display() # create eyetracker object tracker = eyetracker.EyeTracker(disp) # create keyboard object keyboard = Keyboard(keylist=['space', "q"], timeout=1) center_of_screen = (DISPSIZE[0] / 2, DISPSIZE[1] / 2) # create screen to draw things on screen1 = Screen() screen1.draw_fixation(fixtype='cross', pos=center_of_screen, colour=(255, 255, 255), pw=5,
import random # PyGaze from constants import * from pygaze.libscreen import Display, Screen from pygaze.libinput import Keyboard from pygaze.eyetracker import EyeTracker from pygaze.liblog import Logfile import pygaze.libtime as timer # # # # # # SETUP # visuals disp = Display() scr = Screen() # input kb = Keyboard() tracker = EyeTracker(disp) # output log = Logfile() log.write(["trialnr","image","imgtime"]) # # # # # # PREPARE # load instructions from file