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 ...@@ -2,6 +2,7 @@ import sys
import random import random
import time import time
from matplotlib.pyplot import margins from matplotlib.pyplot import margins
from numpy import disp
import pygame import pygame
from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLabel, QMessageBox from PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLabel, QMessageBox
from PyQt6.QtCore import Qt from PyQt6.QtCore import Qt
...@@ -20,8 +21,10 @@ from PyQt6.QtWidgets import ( ...@@ -20,8 +21,10 @@ from PyQt6.QtWidgets import (
from PyQt6.QtGui import QFont from PyQt6.QtGui import QFont
from PyQt6.QtCore import Qt from PyQt6.QtCore import Qt
# ============ FUNCIÓN DE CALIBRACIÓN ============ # ============ FUNCIÓN DE CALIBRACIÓN ============
def calibrate_tobii(self): def calibrate_tobii(self):
try: try:
print("Buscando dispositivo...") print("Buscando dispositivo...")
found_eyes = tr.find_all_eyetrackers() found_eyes = tr.find_all_eyetrackers()
...@@ -45,17 +48,19 @@ def calibrate_tobii(self): ...@@ -45,17 +48,19 @@ def calibrate_tobii(self):
print("Calibración completada.") print("Calibración completada.")
# self.tracker.close() # self.tracker.close()
# disp.close() self.disp.close() #cierro display
return True return True
except Exception as e: except Exception as e:
print(f"Error durante calibración: {e}") print(f"Error durante calibración: {e}")
return False return False
# ============ TEST GO/NOGO ====================== # ============ TEST GO/NOGO ======================
def run_gonogo_test(self): def run_gonogo_test(self):
pygame.init() 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) # self.tracker = eyetracker.EyeTracker(self.disp)
log = liblog.Logfile() log = liblog.Logfile()
log.write(["trialnr", "trialtype", "targetside", "gaze_endpos", "latency", "correct"]) log.write(["trialnr", "trialtype", "targetside", "gaze_endpos", "latency", "correct"])
...@@ -178,13 +183,6 @@ def run_gonogo_test(self): ...@@ -178,13 +183,6 @@ def run_gonogo_test(self):
# try: # try:
t1, startpos = self.tracker.wait_for_saccade_start() t1, startpos = self.tracker.wait_for_saccade_start()
endtime, startpos, endpos = self.tracker.wait_for_saccade_end() 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 latency = (t1 - t0) / 1000
...@@ -197,22 +195,32 @@ def run_gonogo_test(self): ...@@ -197,22 +195,32 @@ def run_gonogo_test(self):
if trialtype == 'PS': if trialtype == 'PS':
correct = int( correct = int(
(targetside == 'left' and endpos[0] <= constants.DISPSIZE[0]/2) or (targetside == 'left' and endpos[0] <= constants.DISPSIZE[0] / 2) or
(targetside == 'right' and endpos[0] >= constants.DISPSIZE[0]/2) (targetside == 'right' and endpos[0] >= constants.DISPSIZE[0] / 2)
) )
print(correct) print(correct)
elif trialtype == 'AS': elif trialtype == 'AS':
correct = int( correct = int(
(targetside == 'left' and endpos[0] >= constants.DISPSIZE[0]/2) or (targetside == 'left' and endpos[0] >= constants.DISPSIZE[0] / 2) or
(targetside == 'right' and endpos[0] <= constants.DISPSIZE[0]/2) (targetside == 'right' and endpos[0] <= constants.DISPSIZE[0] / 2)
) )
print(correct)
elif trialtype == 'NoGo': elif trialtype == 'NoGo':
correct = int(constants.DISPSIZE[0]/2 < endpos[0] <= constants.DISPSIZE[0]/2) # 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")
if correct >= 0:
dualstim_screen.clear(colour=(0, 0, 0))
self.disp.show()
self.disp.fill(feedbackscreens[correct]) self.disp.fill(feedbackscreens[correct])
self.disp.show() self.disp.show()
......
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