Пример #1
0

# # # # #
# 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)
	# start recording
	tracker.start_recording()
	tracker.log("VALIDATION_TRIALSTART, trialnr=%d, x=%d, y=%d" % (i,x,y))
	# show display
	disp.show()
	tracker.log("validation_point_on")
	# allow for a bit of time so the subject can fixate the target
	clock.pause(1000)
	tracker.log("validation_point_fix")
	# wait for a bit
	clock.pause(POINTTIME)
	# clear screen
	scr.clear()
	disp.fill(scr)
	disp.show()
	# stop recording
	tracker.log("validation_point_off")
	tracker.stop_recording()
Пример #2
0
# eyelink calibration
eyetracker.calibrate()

# display surface
disp.fill(screen=blankscreen)
disp.show()

# # # # #
# game

# run several rounds
for trialnr in range(0,TRIALS):
	
	# 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':
Пример #3
0
scr.draw_text(
    "We're now going to test the eyetracker module. Press Space to start!")
disp.fill(scr)
t1 = disp.show()
log.write(["EyeTracker", t1])
kb.get_key()

# tracker.calibrate
tracker.calibrate()

# tracker.sample()
scr.clear()
scr.draw_text("The dot should follow your eye movements")
disp.fill(scr)
disp.show()
tracker.log("now testing sample function")
tracker.status_msg("now testing sample function")
tracker.start_recording()
key = None
while not key == 'space':
    # get new key
    key, presstime = kb.get_key(timeout=1)
    # new states
    gazepos = tracker.sample()
    # draw to screen
    scr.clear()
    scr.draw_text("The dot should follow your eye movements")
    scr.draw_fixation(fixtype='dot', pos=gazepos, pw=3, diameter=15)
    disp.fill(scr)
    disp.show()
tracker.stop_recording()
Пример #4
0
        # (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)" %
                           (trialnr, len(VIDEOS), vidname))

    # Log trial specifics to gaze data file.
    timer.pause(5)
    tracker.log("TRIALNR %d; VIDNAME %s; EXPTIME %d; PCTIME %s" % \
        (trialnr, vidname, timer.get_time(), \
        datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S.%f')))

    # Loop until the video ends.
    for framenr in range(nframes):
Пример #5
0
# 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()
    tracker.start_recording()
    tracker.status_msg("trial %d" % trialnr)
    tracker.log("start trial %d" % trialnr)
    # present stimulus
    response = None
    trialstart = libtime.get_time()
    while not response:
        gazepos = tracker.sample()
        frl.update(disp, scr, gazepos)
        response, presstime = kb.get_key(timeout=1)
    # stop tracking and process input
    tracker.stop_recording()
    tracker.log("stop trial %d" % trialnr)
    log.write([
        trialnr, trialstart, presstime, presstime - trialstart, IMAGES[trialnr]
    ])

# close experiment
Пример #6
0
# In[Wait for Pulse]:

if inScanner:
    b3T.waitForPulseKey(dev,timer,kb,pkey)
    timer.expstart()
    fmri_clock.reset()
    t0 = fmri_clock.reset()
else:
    event.waitKeys(keyList=['space'])
    timer.expstart()
    fmri_clock.reset()
    t0 = fmri_clock.reset()
    
if withTracker:
    tracker.start_recording()
    tracker.log("start trial %d" % 1)
    
# In[Tracker - Start]:
    
if withTracker:
    tracker.start_recording()
    tracker.status_msg("Pulse Received; Recording...")
    #timer.pause(waitTime) why the pause here?


# In[Initiate Trial Stimuli]:

#draw fixate point, will not change throughout experiment
fixate.size = 5
scr.clear()
scr.screen.append(fixate)
Пример #7
0
# eyelink calibration
eyetracker.calibrate()

# display surface
disp.fill(screen=blankscreen)
disp.show()

# # # # #
# game

# run several rounds
for trialnr in range(0,TRIALS):
	
	# 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':
Пример #8
0
    if 'r' in keys:
        repeatInstructions = True
        numTrialsCompleted = 0
    else:
        repeatInstructions = False

seconds_totesting = core.getTime()
print("Seconds to testing phase: ", seconds_totesting)

#main loop
curTrial = train
bl = 1
try:
    #while (curTrial + blockLen <= nT):
    while curTrial <= nT:
        tracker.log('block_' + str(bl))
        tracker.calibrate()
        tracker.start_recording()
        for trial in allTrials[curTrial:curTrial + blockLen]:
            choice, rt, cor = mainloop(win,
                                       trial,
                                       fixation,
                                       counter,
                                       tracker=tracker,
                                       trialNum=numTrialsCompleted)
            responses.append(choice)
            rts.append(rt)
            correct.append(cor)
            hands.append(hand_pattern[bl + 1])
            numTrialsCompleted += 1
        if bl < 6:
Пример #9
0
    scr.draw_image(os.path.join(IMGDIR, images[trialnr]))
    x = (DISPSIZE[0] -
         image_size[0]) / 2  # centre minus half of the image width
    y = (DISPSIZE[1] -
         image_size[1]) / 2  # centre minus half of the image height
    aoi = AOI('rectangle', (x, y), image_size)
    disp.fill(scr)

    # perform a drift check
    tracker.drift_correction()

    # RUN TRIAL
    # start tracking
    key = None
    tracker.start_recording()
    tracker.log("TRIALSTART %d" % trialnr)
    tracker.log("IMAGENAME %s" % images[trialnr])
    tracker.status_msg("trial %d/%d" % (trialnr + 1, ntrials))

    # present image
    disp.fill(scr)
    t0 = disp.show()
    tracker.log("image online at %d" % t0)

    is_found = 1
    # wait for a bit for participant viewing image
    while key != 'space':
        # check for key input
        key, presstime = kb.get_key(keylist=['space'], timeout=1)
        gaze_pos = tracker.sample()
        gaze_time = timer.get_time() - t0
Пример #10
0
    #print(trial['stim0'])
    # Rotate stimuli to orientation.
    #stimscr[0 or 1].screem[]

    stimscr[trial['stimorder']].screen[stim_index[trial['stimorder']][0]].ori = trial['stim0'] #left
    stimscr[trial['stimorder']].screen[stim_index[trial['stimorder']][1]].ori = trial['stim1'] # right 
    
    # Optional drift check.
    if (trialnr > 0) and (trialnr % DRIFT_CHECK_FREQ == 0):
        tracker.drift_correction()

    # Start eye tracking.
    tracker.start_recording()
    
    # TODO: Log trial specifics.
    tracker.log("")

    #Draw them on to the screen 

    
    # RUN
    # Inter-trial-interval.
    disp.fill(delayscr)
    iti_onset = disp.show()

    if MEG: # log 201: ITI onset 
        trigbox.set_trigger_state(201, RET_ZERO)
        log_events.write([str(trialnr), str(timer.get_time()), "0", "201", "0", "0"])

    timer.pause(trial['iti'])
    if sum(pressed) > 0:
        event.clearEvents(eventType='mouse')
        wait = False
    print(wait)

dsp = Display(dispsize=DISPSIZE, screennr=2)
tracker = EyeTracker(dsp, trackertype='eyelink')
tracker.calibrate()
tracker.close()
dsp.close()
tracker.start_recording()
######### Trials

for r in range(rounds):
    tracker.status_msg('Trial with matrix {}'.format(r))
    tracker.log('TRIALSTART')
    disp.fill(fixscr)
    disp.show()
    timer.pause(1000)
    tracker.log('fixation_onset')

    gamescreen.clear()
    ycor = cy - (side / 2)
    count = 0

    for i in range(p2):
        xcor = cx - (side / 2)
        gamescreen.draw_text("You",
                             pos=(cx, cy - (side / 2) - ((yax *
                                                          (1 - margin)) / 6)),
                             center=True,
Пример #12
0
scr.clear()
scr.draw_text("We're now going to test the eyetracker module. Press Space to start!")
disp.fill(scr)
t1 = disp.show()
log.write(["EyeTracker", t1])
kb.get_key()

# tracker.calibrate
tracker.calibrate()

# tracker.sample()
scr.clear()
scr.draw_text("The dot should follow your eye movements")
disp.fill(scr)
disp.show()
tracker.log("now testing sample function")
tracker.status_msg("now testing sample function")
tracker.start_recording()
key = None
while not key == 'space':
	# get new key
	key, presstime = kb.get_key(timeout=1)
	# new states
	gazepos = tracker.sample()
	# draw to screen
	scr.clear()
	scr.draw_text("The dot should follow your eye movements")
	scr.draw_fixation(fixtype='dot', pos=gazepos, pw=3, diameter=15)
	disp.fill(scr)
	disp.show()
tracker.stop_recording()
    stimy = numpy.array(stimy)
    # Construct the background colours.
    bgcols = trial['nstim'] * [BGC]
    
    # Update the stimulus screen.
    stimscr[trial['nstim']].update(trial['locs'], trial['oris'], \
        bgcols, linewidth=None)
    
    # Wait for the inter-trial interval minus the preparation time.
    timer.pause(ITI - (timer.get_time()-fixonset))

    
    # STIMULUS ARRAY
    # Start recording eye movements.
    tracker.start_recording()
    tracker.log("TRIALSTART")
    _print("Trial start.")

    # Show the stimulus screen.
    disp.fill(stimscr[trial['nstim']])
    stimonset = disp.show()
    tracker.log("stimulus_onset")
    _print("Stimulus onset.")
    
    # WAIT FOR FIXATIONS (both locally and from server)
    fixstim = None
    fixonset = None
    fixlist = {'self':[], 'other':[], 'all':[]}
    trialrunning = True
    fliptime = copy.deepcopy(stimonset)
    while trialrunning:
Пример #14
0
# loop through all trials
ntrials = len(images)
for trialnr in range(ntrials):
	
	# PREPARE TRIAL
	# draw the image
	scr.clear()
	scr.draw_image(os.path.join(IMGDIR,images[trialnr]))

	# perform a drift check
	tracker.drift_correction()
	
	# RUN TRIAL
	# start tracking
	tracker.start_recording()
	tracker.log("TRIALSTART %d" % trialnr)
	tracker.log("IMAGENAME %s" % images[trialnr])
	tracker.status_msg("trial %d/%d" % (trialnr+1, ntrials))
	
	# present image
	disp.fill(scr)
	t0 = disp.show()
	tracker.log("image online at %d" % t0)
	
	# wait for a bit
	timer.pause(TRIALTIME)
	
	# reset screen
	disp.fill()
	t1 = disp.show()
	tracker.log("image offline at %d" % t1)