Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
test_gonogo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Laura Rodríguez
test_gonogo
Commits
d5edbda4
Commit
d5edbda4
authored
Jun 19, 2025
by
Laura Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
17 jun
parent
90a360e6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
172 additions
and
1 deletions
+172
-1
ca_taaask.pye
+171
-0
test_final.py
+1
-1
No files found.
ca_taaask.pye
0 → 100644
View file @
d5edbda4
import random
import time
import pandas as pd
import pygame
import constants
from pygaze import eyetracker, libinput, libscreen, liblog
import libscreen
import libtime
def compelled_saccade_test(self):
pygame.init()
# 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"])
SCREEN_WIDTH, SCREEN_HEIGHT = constants.DISPSIZE
CENTER = (SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2)
TARGET_OFFSET = 382
left_pos = (CENTER[0] - TARGET_OFFSET, CENTER[1])
right_pos = (CENTER[0] + TARGET_OFFSET, CENTER[1])
blackscreen = libscreen.Screen()
blackscreen.clear(colour=(0, 0, 0))
inscreen = libscreen.Screen()
inscreen.clear(colour=(0, 0, 0))
ins_text = (
"Mira la cruz central y presiona 'espacio'.\n\n"
"El color indicará la acción:\n"
"- Verde: mira al círculo blanco grande)\n"
"- Naranja: NO mires a ningún estímulo (NoGo)\n\n"
"Presiona 'espacio' para comenzar.\n"
"Pulsa 'E' en cualquier momento para salir."
)
inscreen.draw_text(text=ins_text, fontsize=30, pos=CENTER, colour=(255, 255, 255), center=True)
fixscreen = libscreen.Screen()
fixscreen.clear(colour=(0, 0, 0))
fixscreen.draw_fixation(fixtype='cross', diameter=57, pos=CENTER, colour=(255, 255, 255))
signal_screens = {
'PS': libscreen.Screen(),
'AS': libscreen.Screen(),
}
for key, color in [('PS', (0, 255, 0)), ('AS', (255, 0, 0))]:
signal_screens[key].clear(colour=(0, 0, 0))
signal_screens[key].draw_circle(pos=CENTER, r=38, fill=True, colour=color)
feedbackscreens = {
1: libscreen.Screen(),
0: libscreen.Screen()
}
feedbackscreens[1].clear(colour=(0, 0, 0))
feedbackscreens[1].draw_text(text='Correcto', fontsize=30, pos=CENTER, colour=(0, 255, 0), center=True)
feedbackscreens[0].clear(colour=(0, 0, 0))
feedbackscreens[0].draw_text(text='Incorrecto', fontsize=30, pos=CENTER, colour=(255, 0, 0), center=True)
self.disp.fill(inscreen)
self.disp.show()
# waiting = True
# while waiting:
# for event in pygame.event.get():
# if event.type == pygame.KEYDOWN:
# if event.key == pygame.K_SPACE:
# waiting = False
# elif event.key == pygame.K_e:
# pygame.quit()
# return
max_blocks = 30
results = []
try:
self.tracker.start_recording()
for block in range(max_blocks):
trials = ['PS', 'AS']
fixation_duration = random.choice([1000, 2000, 3000]) # milisegundos
# trials = ['PS', 'AS']
random.shuffle(trials)
for trialnr, trialtype in enumerate(trials, start=1):
for event in pygame.event.get():
if event.type == pygame.KEYDOWN and event.key == pygame.K_e:
raise KeyboardInterrupt
# Mostrar cruz de fijación
self.disp.fill(fixscreen)
self.disp.show()
#libtime.pause(random.randint(750, 1250))
libtime.pause(fixation_duration) # Usamos la duración fija del bloque
# # Esperar que el usuario presione espacio
# waiting = T rue
# while waiting:
# for event in pygame.event.get():
# if event.type == pygame.KEYDOWN:
# if event.key == pygame.K_SPACE:
# waiting = False
# elif event.key == pygame.K_e:
# raise KeyboardInterrupt
time.sleep(0.2)
# Mostrar señal central de color
self.disp.fill(signal_screens[trialtype])
self.disp.show()
time.sleep(0.8)
# Mostrar señal central de color (verde o rojo según PS o AS)
self.disp.fill(signal_screens[trialtype])
self.disp.show()
libtime.pause(800) # Mostrar la señal durante 800 ms
# Mostrar estímulos laterales naranja (el central desaparece)
targetside = random.choice(['left', 'right'])
target_pos = left_pos if targetside == 'left' else right_pos
nontarget_pos = right_pos if targetside == 'left' else left_pos
dualstim_screen = libscreen.Screen()
dualstim_screen.clear(colour=(0, 0, 0))
dualstim_screen.draw_circle(pos=nontarget_pos, r=38, fill=True, colour=(255, 165, 0)) # Naranja
dualstim_screen.draw_circle(pos=target_pos, r=38, fill=True, colour=(255, 165, 0)) # Naranja
self.disp.fill(dualstim_screen)
self.disp.show()
t0 = pygame.time.get_ticks()
self.tracker.log(f"target {targetside}")
# Esperar sacada
t1, startpos = self.tracker.wait_for_saccade_start()
endtime, startpos, endpos = self.tracker.wait_for_saccade_end()
latency = (t1 - t0) / 1000 # en segundos
# Evaluar respuesta
if trialtype == 'PS':
correct = int(
(targetside == 'left' and endpos[0] <= constants.DISPSIZE[0] / 2) or
(targetside == 'right' and endpos[0] >= constants.DISPSIZE[0] / 2)
)
elif trialtype == 'AS':
correct = int(
(targetside == 'left' and endpos[0] >= constants.DISPSIZE[0] / 2) or
(targetside == 'right' and endpos[0] <= constants.DISPSIZE[0] / 2)
)
self.disp.fill(feedbackscreens[correct])
self.disp.show()
time.sleep(0.5)
results.append([trialnr, trialtype, targetside, endpos, round(latency, 3), correct])
self.tracker.stop_recording()
except KeyboardInterrupt:
print("Test interrumpido por el usuario con la tecla 'E'.")
finally:
log.close()
self.tracker.close()
self.disp.close()
print("Test Go/NoGo finalizado.")
df = pd.DataFrame(results, columns=["trialnr", "trialtype", "targetside", "gaze_endpos", "latency", "correct"])
df.to_excel("gonogo_results.xlsx", index=False)
print("Resultados guardados en 'gonogo_results.xlsx'.")
test_final.py
View file @
d5edbda4
...
...
@@ -1085,7 +1085,7 @@ class EyeTrackingApp(QWidget):
# Grid layout para botones (2 columnas)
grid
=
QGridLayout
()
grid
.
setHorizontalSpacing
(
30
)
# espacio horizonta
l
entre botones
grid
.
setHorizontalSpacing
(
30
)
# espacio horizonta
s
entre botones
grid
.
setVerticalSpacing
(
20
)
# espacio vertical entre botones
# Crear botones
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment