Commit 557470ce by Laura Rodríguez

6jun

parent b27c8826
costo =100
impuesto=16
def calcular_total(costo, impuesto):
total = costo + impuesto
return total
\ No newline at end of file
......@@ -2,6 +2,7 @@ import sys
import random
import time
from matplotlib.pyplot import margins
from numpy import disp
import pygame
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLabel, QMessageBox
from PyQt6.QtCore import Qt
......@@ -20,8 +21,10 @@ from PyQt6.QtWidgets import (
from PyQt6.QtGui import QFont
from PyQt6.QtCore import Qt
# ============ FUNCIÓN DE CALIBRACIÓN ============
def calibrate_tobii(self):
try:
print("Buscando dispositivo...")
found_eyes = tr.find_all_eyetrackers()
......@@ -45,17 +48,19 @@ def calibrate_tobii(self):
print("Calibración completada.")
# self.tracker.close()
# disp.close()
self.disp.close() #cierro display
return True
except Exception as e:
print(f"Error durante calibración: {e}")
return False
# ============ TEST GO/NOGO ======================
def run_gonogo_test(self):
pygame.init()
# self.disp = libscreen.Display(bgcolor=(0, 0, 0))
# self.test_window.disp = self.disp
self.disp = libscreen.Display(bgcolor=(0, 0, 0))#abro display de nuevo
# self.tracker = eyetracker.EyeTracker(self.disp)
log = liblog.Logfile()
log.write(["trialnr", "trialtype", "targetside", "gaze_endpos", "latency", "correct"])
......@@ -178,14 +183,7 @@ def run_gonogo_test(self):
# try:
t1, startpos = self.tracker.wait_for_saccade_start()
endtime, startpos, endpos = self.tracker.wait_for_saccade_end()
# except Exception:
# print("La estoy liando")
# t1 = pygame.time.get_ticks()
# endtime = pygame.time.get_ticks()
# endpos = constants.DISPSIZE[0]/2 # o (SCREEN_WIDTH//2, SCREEN_HEIGHT//2), posición central para 'NoGo'
latency = (t1 - t0) / 1000
self.tracker.stop_recording()
......@@ -197,22 +195,32 @@ def run_gonogo_test(self):
if trialtype == 'PS':
correct = int(
(targetside == 'left' and endpos[0] <= constants.DISPSIZE[0]/2) or
(targetside == 'right' and endpos[0] >= constants.DISPSIZE[0]/2)
(targetside == 'left' and endpos[0] <= constants.DISPSIZE[0] / 2) or
(targetside == 'right' and endpos[0] >= constants.DISPSIZE[0] / 2)
)
print(correct)
elif trialtype == 'AS':
correct = int(
(targetside == 'left' and endpos[0] >= constants.DISPSIZE[0]/2) or
(targetside == 'right' and endpos[0] <= constants.DISPSIZE[0]/2)
(targetside == 'left' and endpos[0] >= constants.DISPSIZE[0] / 2) or
(targetside == 'right' and endpos[0] <= constants.DISPSIZE[0] / 2)
)
print(correct)
elif trialtype == 'NoGo':
correct = int(constants.DISPSIZE[0]/2 < endpos[0] <= constants.DISPSIZE[0]/2)
if correct >= 0:
dualstim_screen.clear(colour=(0, 0, 0))
self.disp.show()
# En NoGo no debe haber movimiento ocular (sacada)
try:
# Espera hasta 900 ms para detectar el inicio de una sacada
t1, _ = self.tracker.wait_for_saccade_start(latency=200)
correct = 0 # Si hay una sacada, se considera incorrecto
latency = (t1 - t0) / 1000 # Calcula la latencia en segundos
print("Incorrecto")
except Exception:
# Si no se detecta ninguna sacada en ese tiempo, se considera correcto
correct = 1
latency = 0 # No hay latencia porque no hubo movimiento
print("Correcto")
self.disp.fill(feedbackscreens[correct])
self.disp.show()
......@@ -326,4 +334,4 @@ if __name__ == "__main__":
app = QApplication(sys.argv)
window = EyeTrackingApp()
window.show()
sys.exit(app.exec())
\ No newline at end of file
sys.exit(app.exec())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment