import numpy


# # # # #
# PREPARATION

# Intialise the Display.
disp = Display()

# 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()
Beispiel #2
0
# INITIALISE

# 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()

# # # # #
Beispiel #3
0
scr = Screen()

# 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])
Beispiel #4
0
# 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()
Beispiel #5
0
##############
# 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 
Beispiel #6
0
# # # # #
# 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)

# 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 
Beispiel #7
0
# 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()
Beispiel #8
0
from pygaze.display import Display
from pygaze.screen import Screen
from pygaze.keyboard import Keyboard
import pygaze.libtime as timer
from pygaze.logfile import Logfile
import random

# Criando todas as instâncias (display, screen e coleta de tecla)

# Criando display que será apresentado no monitor do PC
disp = Display()

# Criando a keyboard para coleta de respostas
kb = Keyboard()
# Após kb - Criando o logfile para armazenar e salvar os dados coletados
log = Logfile()

# Tela de instruções do experimento


instructions = 'Seja bem vindo(a)!\n' \
               'Neste experimento as letras F e J apareceraão em ambos os lados da tela.\n' \
               'Se você ver a letra F, então pressione a tecla F.\n' \
               'Se você ver a letra J, então pressione a tecla J.\n' \
               'Tente ser tão rápido e preciso quanto possível durante os ensaios.\n\n' \
                'Aperte a barra de espaço do teclado para começar.\n\n' \
               'Boa sorte!'

instscr = Screen()
instscr.draw_text(text=instructions, fontsize=22)
                                         newSubject.subject_code, datenow))

# initialize a Timer
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"])
Beispiel #10
0
scr = Screen()

# 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()
from pygaze.display import Display
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))
        linewidth=STIMLINEWIDTH, stimtypes='noise', showcolourwheel=False)

# Create a feedback Screen for showing how much people earned.
fbscr = Screen()
fbscr.draw_rect(x=DISPCENTRE[0]-FBBARW//2, y=DISPCENTRE[1]-FBBARH//2, \
    w=FBBARW, h=FBBARH, pw=FBBARPW, fill=False)

# Create Screens for the post-run questions and the frame-by-frame updated
# fill of a bar.
qscr = Screen()
barqscr = Screen()

# LOGGING
# 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.