예제 #1
0
    
    FGC = cst.FGC
    BGC = cst.BGC
    SACCVELTHRESH = cst.SACCVELTHRESH
    SACCACCTHRESH = cst.SACCACCTHRESH
    TRACKERTYPE = cst.TRACKERTYPE
    
# In[Tracker - Calibrate]:

if withTracker and run == 0:
    
    scr.draw_text(text='tracker instructions')
    disp.fill(scr)
    disp.show()
    
    kb.get_key(keylist = None, timeout = None, flush = True)
    
    if TRACKERTYPE != 'dummy':
        tracker.calibrate()
    
    scr.clear()
    
elif withTracker:
    scr.clear()

# In[Initiate PsychoPy Objects]:

psychopy.event.clearEvents()

#win = psychopy.visual.Window(
#    size=[res[0], res[1]], 
예제 #2
0
	
	# start eye tracking
	eyetracker.start_recording()
	eyetracker.log("start_trial %d" % trialnr)
	trialstart = libtime.get_time()

	# run game
	points = 0
	stimpos = STIMPOS
	t0 = libtime.get_time()
	tstim = libtime.get_time()
	while libtime.get_time() - t0 < GAMEDURATION:
		# get gaze position
		gazepos = eyetracker.sample()
		# get keypress
		key, presstime = keyboard.get_key()
		# handle input
		if key:
			if key == 'escape':
				break
			if ((gazepos[0]-stimpos[0])**2 + (gazepos[1]-stimpos[1])**2)**0.5 < STIMSIZE/2:
				screen.copy(hitscreen)
				points += PPH
			else:
				screen.copy(misscreen)
				points += PPM
		else:
			screen.copy(blankscreen)
		# draw stimulus
		screen.draw_circle(colour=STIMCOL, pos=stimpos, r=STIMSIZE/2, fill=True)
		# draw crosshair
예제 #3
0
instfile = open(INSTFILE_DC)
instruction_dc = instfile.read()
instfile.close()
# read all image names
images = os.listdir(IMGDIR)
image_size = (555, 987)

# display instructions
scr.draw_text(text="Press any key to start the calibration.",
              fontsize=TEXTSIZE_L)
disp.fill(scr)
disp.show()

# wait for a keypress
kb.get_key(keylist=None, timeout=None, flush=True)

# calibrate the eye tracker
tracker.calibrate()

# # # # #
# RUN

# display task instructions
scr.clear()
scr.draw_text(text=instructions, fontsize=TEXTSIZE_M)

disp.fill(scr)
disp.show()

# wait for a keypress
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()

# stop the madness
disp.close()
예제 #5
0
# 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()
	
# stop the madness
disp.close()
예제 #6
0
    elif red > 255:
        red = 255
    # The other colour values will be 0
    green = 0
    blue = 0
    # Now set the background colour to the new colour.
    bgc = (red, green, blue)

    # Fill the Screen with the new background colour...
    scr.clear(colour=bgc)
    # ...and write the new sample text (white letters).
    scr.draw_text(text=sampletext, colour=(255,255,255), fontsize=100)

    # Now fill the Display with the updated Screen...
    disp.fill(scr)
    # ...and update the monitor!
    disp.show()

    # Don't forget to check if there is a keypress.
    key, presstime = kb.get_key()


# Close the connection with the MP150.
mp.close()
 
# End the experiment.
disp.close()
plt.plot(T,Y);
plt.show();
#print Y
예제 #7
0
AOI_right = AOI(aoitype="rectangle",
                pos=(center_of_screen[0] + 300 - 163,
                     center_of_screen[1] - 163),
                size=[326, 326])

pressed_key = None

# give trial instuctions first
instruction_screen = Screen()
instruction_screen.draw_text(
    text=
    "The practice trials will now begin. \n You will see a white cross followed by a white number. Please say the number out loud. \n You will see a pair of faces. Please watch them naturally. \n You may see a square of circle appear around an image. If you see either, please look at the image with the shape. \n Left click if it is a sqaure. Right click if it is a circle",
    pos=center_of_screen,
    colour=(255, 255, 255),
    fontsize=22)
while keyboard.get_key()[0] != "space":
    disp.fill(instruction_screen)
    disp.show()

instruction_screen.clear()
pygame.display.update()
from accl import acclimation

acclimation(center_of_screen, tracker, disp, keyboard, AOI_left, AOI_right)

#from vidtest import video
#vid_screen = Screen()
#vid_screen.draw_image(video('neutral.mp4'), pos=(center_of_screen[0]-300,center_of_screen[1]), scale=None)
#disp.fill(vid_screen)
#disp.show()
#import pygame
예제 #8
0
tracker.calibrate()

# make the sets of images
image_set = generate()
#shuffle our image sets
shuffle(image_set)

# give instuctions first
instruction_screen = Screen()
instruction_screen.draw_text(
    text=
    "You will watch a short clip. After, the trials will begin. \n Press space to continue",
    pos=center_of_screen,
    colour=(255, 255, 255),
    fontsize=22)
while keyboard.get_key()[0] != "space":
    disp.fill(instruction_screen)
    disp.show()

instruction_screen.clear()

#call movie function - will need to switch betwwen neutral and sad
#INSERT CODE HERE

# start trials
for trialnr in range(len(image_set)):
    # make trial screens
    fixation_cross_screen = Screen()
    fixation_cross_screen.draw_fixation(fixtype='cross',
                                        pos=center_of_screen,
                                        colour=(255, 255, 255),
예제 #9
0
    # start eye tracking
    eyetracker.start_recording()
    eyetracker.log("start_trial %d" % trialnr)
    trialstart = libtime.get_time()

    # run game
    points = 0
    stimpos = STIMPOS
    t0 = libtime.get_time()
    tstim = libtime.get_time()
    while libtime.get_time() - t0 < GAMEDURATION:
        # get gaze position
        gazepos = eyetracker.sample()
        # get keypress
        key, presstime = keyboard.get_key()
        # handle input
        if key:
            if key == 'escape':
                break
            if ((gazepos[0] - stimpos[0])**2 +
                (gazepos[1] - stimpos[1])**2)**0.5 < STIMSIZE / 2:
                screen.copy(hitscreen)
                points += PPH
            else:
                screen.copy(misscreen)
                points += PPM
        else:
            screen.copy(blankscreen)
        # draw stimulus
        screen.draw_circle(colour=STIMCOL,
예제 #10
0
# load instructions from file
instfile = open(INSTFILE)
instructions = instfile.read()
instfile.close()

# read all image names
images = os.listdir(IMGDIR)


# display instructions
scr.draw_text(text="Press any key to start the calibration.", fontsize=TEXTSIZE)
disp.fill(scr)
disp.show()

# wait for a keypress
kb.get_key(keylist=None, timeout=None, flush=True)

# calibrate the eye tracker
tracker.calibrate()


# # # # #
# RUN

# display task instructions
scr.clear()
scr.draw_text(text=instructions, fontsize=TEXTSIZE)
disp.fill(scr)
disp.show()

# wait for a keypress
예제 #11
0
파일: camtest.py 프로젝트: AA33/PyGaze
# 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
	img = cam.get_image()
	# draw it on the Screen
	scr.draw_image(img)
	# update Display
	disp.fill(scr)
	disp.show()
	# check input
	stopped, stoptime = kb.get_key()


# # # # #
# quit

# neatly close
cam.close()
disp.close()
예제 #12
0
    #draws image pair
    screen1.draw_image(image_pair[0],
                       pos=(center_of_screen[0] - 300, center_of_screen[1]),
                       scale=None)  #need screen width
    screen1.draw_image(image_pair[1],
                       pos=(center_of_screen[0] + 300, center_of_screen[1]),
                       scale=None)  #need screen width

    #space (replace with 3 seconds)
    #current time
    pairstart = libtime.get_time()

    if (image_pair[2] == True
        ):  # if we have the addition, wait for fixation. REPLACE THE NEXT LINE
        while keyboard.get_key(
        )[0] == None:  #Replace this with wait for fixation code
            disp.fill(screen1)
            disp.show()
    else:
        while libtime.get_time() - pairstart < 3000:
            disp.fill(screen1)
            disp.show()

    #image pair index 2 tells us if we need to draw a circle/square.
    if (image_pair[2] == True):

        neutral_image_index = 0
        if ("NE" in image_pair[1]):
            neutral_image_index = 1

        new_suffix = circle_suffix
예제 #13
0
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
    img = cam.get_image()
    # draw it on the Screen
    scr.draw_image(img)
    # update Display
    disp.fill(scr)
    disp.show()
    # check input
    stopped, stoptime = kb.get_key()

# # # # #
# quit

# neatly close
cam.close()
disp.close()