示例#1
0
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)
    # prepare stimulus
    scr.clear()
    scr.draw_image(IMAGES[trialnr])
    # start recording eye movements
    tracker.drift_correction()
示例#2
0
import highscores
from constants import *

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)
示例#3
0
from pygaze import eyetracker
from pygaze import liblog
from pygaze.libinput import Keyboard
from Functions import *
from heatmap import *
from threads import *
from voicerecognition import *
import threading
import queue
kb = Keyboard(keylist=['space', '1', '2', '3', '4', '5', 'escape'], timeout=1)
date = timeanddate()
musiccommands(music)
disp = libscreen.Display()
tracker = eyetracker.EyeTracker(disp)
importimages(imgs)
scrsttart = startscreen()
disp.fill(scrsttart)
disp.show()
musicpath(os.path.join(SOUNDDIR, 'Start.wav')).play()
time.sleep(2.8)
e = threading.Event()
e.set()
thread1 = threading.Thread(target=voicerec, args=("start", e))
thread1.start()
spacepass(kb, e)
thread1.join()
scrsttart.clear()
for images in range(len(imgs)):
    print "e"
    img = resizeimagefunction(imgs[images], calcresolution())
    a = imagescreen(img)
示例#4
0
import highscores
from constants import *

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)
示例#5
0
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()
    LOGFILE = os.path.join(director,LOGFILENAME)
    
    FGC = cst.FGC
    BGC = cst.BGC
if not os.path.exists(session_folder_path):
    os.mkdir(session_folder_path)
if not os.path.exists(fmri_folder_path):
    os.mkdir(fmri_folder_path)
if not os.path.exists(debug_folder_path):
    os.mkdir(debug_folder_path)
if withTracker and not os.path.exists(tracker_folder_path):
    os.mkdir(tracker_folder_path)

while os.path.exists(os.path.join(debug_folder_path, basename + '_debug.log')):
    basename += '+'

# In[Initiate PyGaze Objects]:

if inScanner:
    kb = Keyboard()

# In[Initiate PsychoPy Objects]:

psychopy.event.clearEvents()

win = psychopy.visual.Window(size=[res[0], res[1]],
                             units="pix",
                             fullscr=True,
                             waitBlanking=True)

timg = psychopy.visual.ImageStim(win=pygaze.expdisplay,
                                 image="right.png",
                                 units="pix",
                                 pos=(base_dist_pix, 0),
                                 opacity=1)
示例#7
0
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
instfile = open(INSTFILE)
instructions = instfile.read()
instfile.close()
MESSAGE = "AFK; BRB"

# import stuff
import random
from pygaze.defaults import *
from pygaze import libtime
from pygaze.libscreen import Display, Screen
from pygaze.libinput import Keyboard

# start timing
libtime.expstart()

# objects
disp = Display()
scr = Screen()
kb = Keyboard(keylist=['space'], timeout=1)

# run annoying message
while kb.get_key()[0] == None:
    # colour
    col = (random.randint(0, 255), random.randint(0,
                                                  255), random.randint(0, 255))
    # position
    pos = (random.randint(0, DISPSIZE[0]), random.randint(0, DISPSIZE[1]))
    # text
    scr.draw_text(text=MESSAGE, colour=col, pos=pos, fontsize=84)
    # display
    disp.fill(scr)
    disp.show()
    # reset screen
    scr.clear()
示例#9
0
#
# E.S. Dalmaijer, 2013

# your message
MESSAGE = "AFK; BRB"

# import stuff
import random
from pygaze.defaults import *
from pygaze.libscreen import Display, Screen
from pygaze.libinput import Keyboard

# objects
disp = Display()
scr = Screen()
kb = Keyboard(keylist=['space'],timeout=1)

# run annoying message
while kb.get_key()[0] == None:
	# colour
	col = (random.randint(0,255), random.randint(0,255), random.randint(0,255))
	# position
	pos = (random.randint(0,DISPSIZE[0]), random.randint(0,DISPSIZE[1]))
	# text
	scr.draw_text(text=MESSAGE, colour=col, pos=pos, fontsize=84)
	# display
	disp.fill(scr)
	disp.show()
	# reset screen
	scr.clear()
	
示例#10
0
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()
示例#11
0
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
tracker.calibrate()

# make the sets of images
image_set = generate()
#shuffle our image sets
shuffle(image_set)
示例#12
0
import pygaze.libtime as timer

from constants import *
from client import *
from utilities import *

# # # # #
# SETUP


# visuals

scr = Screen()

# input
kb = Keyboard()

# output
log = Logfile()
log.write(["trialnr", "image", "imgtime"])
# # # # #
# PREPARE

# load instructions from file
instfile = open(INSTFILE)
instructions = instfile.read()
instfile.close()

# read all image names
images = os.listdir(IMGDIR)
示例#13
0
文件: camtest.py 项目: AA33/PyGaze
try:
	from pygaze import libwebcam
# if importing from PyGaze fails, we try to import from the current directory
except:
	import libwebcam


# # # # #
# preparation

# visual
disp = Display()
scr = Screen()

# input
kb = Keyboard()

# webcam
camlist = libwebcam.available_devices()
cam = libwebcam.Camera(dev=camlist[0], devtype=DEVTYPE, resolution=CAMRES, verflip=VFLIP, horflip=HFLIP)


# # # # #
# run camera display

# some variables
stopped = False

# loop until a key is pressed
while not stopped:
	# get new image
示例#14
0
#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,
                      diameter=30)
screen2 = Screen()
#screen1.draw_image(base_path, pos=(center_of_screen[0]-300,center_of_screen[1]), scale=None) #need screen width
#screen2.draw_image(base_path1, pos=(center_of_screen[0]+300,center_of_screen[1]), scale=None) #need screen width
screen3 = Screen()
示例#15
0
# first, we try to import libwebcam from PyGaze
try:
    from pygaze import libwebcam
# if importing from PyGaze fails, we try to import from the current directory
except:
    import libwebcam

# # # # #
# preparation

# visual
disp = Display()
scr = Screen()

# input
kb = Keyboard()

# webcam
camlist = libwebcam.available_devices()
cam = libwebcam.Camera(dev=camlist[0],
                       devtype=DEVTYPE,
                       resolution=CAMRES,
                       verflip=VFLIP,
                       horflip=HFLIP)

# # # # #
# run camera display

# some variables
stopped = False