Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the simple-restrict domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/florentcxj/florentcaetta.fr/wp-includes/functions.php on line 6121

Notice: La fonction _load_textdomain_just_in_time a été appelée de façon incorrecte. Le chargement de la traduction pour le domaine fluida a été déclenché trop tôt. Cela indique généralement que du code dans l’extension ou le thème s’exécute trop tôt. Les traductions doivent être chargées au moment de l’action init ou plus tard. Veuillez lire Débogage dans WordPress (en) pour plus d’informations. (Ce message a été ajouté à la version 6.7.0.) in /home/florentcxj/florentcaetta.fr/wp-includes/functions.php on line 6121
The Eye Tribe & PsychoPy | Florent Caetta
Développement informatique / Psychologie cognitive
 
The Eye Tribe & PsychoPy

The Eye Tribe & PsychoPy

Je cherchais cette semaine une manière simple et rapide d’implémenter The Eye Tribe (RIP…) dans une expérience codée avec PsychoPy.

Il faut dire que malgré quelques posts sur le net, je ne n’ai pas trouvé énormément d’informations à ce sujet. Aussi je ne voulais pas passer par pyGaze, car PsychoPy possède son propre framework pour gérer un eye tracker : iohub.

Le problème est que l’aide à ce sujet est simplement absente. Je me suis dans un premier temps basé sur une démo intégrée à PsychoPy (gc_cursor_demo), mais je ne voulais pas non plus passer par la classe « ioHubExperimentRuntime » (son utilisation est tout à fait justifiée lorsque l’on monte une expé, mais dans notre cas cela nécessitait de réécrire pas mal de choses). Finalement, j’ai trouvé ceci, que j’ai adapté pour The Eye Tribe.

Voici donc ci-dessous un petit script qui consiste à contrôler la fixation d’un participant, et vous trouverez dans celui-ci comment configurer iohub pour The Eye Tribe (cf # iohub configuration). Peut être que cela vous évitera plusieurs heures de recherche!

[python]
 »’
Simple theEyeTribe using the ioHub framework to monitor for central fixation.
Based on https://github.com/psychopy/psychopy/blob/master/psychopy/demos/coder/iohub/eyetracking/simple.py
 »’
import os
from psychopy import visual,core,event,gui,data
import math
from psychopy.iohub.client import launchHubServer

#iohub configuration
iohub_tracker_class_path = ‘eyetracker.hw.theeyetribe.EyeTracker’
eyetracker_config = dict()
eyetracker_config[‘name’] = ‘tracker’
eyetracker_config[‘model_name’] = ‘TheEyeTribe’
eyetracker_config[‘runtime_settings’] = dict(enable= True,name= "tracker",monitor_event_types= "[BinocularEyeSampleEvent, ]")
io = launchHubServer(**{iohub_tracker_class_path: eyetracker_config})
tracker = io.devices.tracker
tracker.setRecordingState(True)# Start Recording Eye Data

# Psychopy Window
window = visual.Window(fullscr=True,monitor=’myScreen’,size=(1280,900),units=’pix’, allowGUI=False)

# gaze feedback
gaze_dot_green =visual.GratingStim(window,tex=None, mask="gauss",
pos=(0,0 ),size=(66,66),color=’green’,
units=’pix’)
gaze_dot_red =visual.GratingStim(window,tex=None, mask="gauss",
pos=(0,0 ),size=(366,366),color=’red’,units=’pix’)

# Fixation
fixation = visual.ShapeStim(window,
vertices=((0, -100), (0, 100), (0,0), (-100,0), (100, 0)),
lineWidth=3,
pos=(0,0 ),
closeShape=False,
lineColor=’black’
)

# text
no_gaze_data = visual.TextStim(window, text= "NO DATA", color=[-1.000,-1.000,-1.000], height=4)

# Main Loop
run_trial=True
while run_trial :
fixation.draw()
gpos=tracker.getPosition()
if type(gpos) in [tuple,list]:
dist = math.sqrt((gpos[0] – fixation.pos[0])**2 + (gpos[1] – fixation.pos[1])**2)
if dist <100:
gaze_dot_green.setPos([gpos[0],gpos[1]])
gaze_dot_green.draw()
else:
gaze_dot_red.setPos([gpos[0],gpos[1]])
gaze_dot_red.draw()
else:
no_gaze_data.draw();
window.flip()
keys=event.getKeys()
if keys !=[]:# press any keys to quit
run_trial=False

[/python]

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *