Skip to content

Commit

Permalink
update documentation and code organization
Browse files Browse the repository at this point in the history
  • Loading branch information
crewalsh committed Jul 30, 2024
1 parent a70f256 commit c817295
Show file tree
Hide file tree
Showing 9 changed files with 760 additions and 713 deletions.
18 changes: 14 additions & 4 deletions EventCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,15 @@ def update_data(self, idx, time, pupil_size, diff_fit=None):
size of pupil
diff_fit : int
last value of the search window gradient
This function updates the following attributes:
----------------------------------------------
_idx : adds to the list of event indices
_times : adds to the list of times of events
_pupil_size : adds to the list of pupil sizes
_diff_fit : adds to the gradient fit
_count : increments tally of event
"""
self._idx.append(idx-1)
self._times.append(time)
Expand All @@ -268,10 +276,12 @@ def update_data(self, idx, time, pupil_size, diff_fit=None):

def store_accepted_event(self):
"""
Store index of an accepted event
Store index of an accepted event, if identified as valid.
This function updates the following attributes:
----------------------------------------------
_accepted_event_idx : stores index of current event in list of accepted event indices
Method called if event is identified as valid. Pull the final value from the list of all
event indexes and add it to the internal tracker self._accepted_event_idx
"""
accepted_idx = self._idx[-1]
self._accepted_event_idx.append(accepted_idx)
Expand Down
15 changes: 9 additions & 6 deletions EyeLinkFunctions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pylink
import os
from EyeLinkCoreGraphicsPsychoPy import EyeLinkCoreGraphicsPsychoPy
from string import ascii_letters, digits
import numpy as np
from psychopy import core
import sys
import platform
import time
import config
import rtPupil_config

from PsychoPyFunctions import instructions_screens, terminate_task

Expand Down Expand Up @@ -109,7 +109,7 @@ def setup_eyelink(win, dummy_mode, edf_fname):
eyelink_ver = 0 # set version to 0, in case running in Dummy mode

else:
eyelink_ver = config.eyelink_ver
eyelink_ver = rtPupil_config.eyelink_ver

if not dummy_mode:
vstr = el_tracker.getTrackerVersionString()
Expand Down Expand Up @@ -165,7 +165,7 @@ def setup_eyelink(win, dummy_mode, edf_fname):

# Resolution fix for Mac retina displays
if 'Darwin' in platform.system():
if config.use_retina:
if rtPupil_config.use_retina:
scn_width = int(scn_width/2.0)
scn_height = int(scn_height/2.0)

Expand Down Expand Up @@ -226,13 +226,16 @@ def setup_eyelink(win, dummy_mode, edf_fname):
genv.setCalibrationSounds('off', 'off', 'off')

# Resolution fix for macOS retina display issues
if config.use_retina:
if rtPupil_config.use_retina:
genv.fixMacRetinaDisplay()

#if not dummy_mode:
# Request Pylink to use the PsychoPy window we opened above for calibration
pylink.openGraphicsEx(genv)

# Calibration task constants
# Set random seed
rng = np.random.default_rng()

def calibrate_eyelink(win, dummy_mode):
"""
Calibrate EyeLink eye-tracker.
Expand Down
12 changes: 6 additions & 6 deletions PsychoPyFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pylink
import sys
from psychopy import visual, logging, core, event
import config
import rtPupil_config

import numpy as np

Expand Down Expand Up @@ -31,7 +31,7 @@ def set_up_directories( behavioral_folder, eyelink_folder):
def clear_screen(win):
""" Clear window """

win.fillColor = config.bg_color
win.fillColor = rtPupil_config.bg_color
win.flip()

def terminate_task(win):
Expand Down Expand Up @@ -83,7 +83,7 @@ def abort_trial(win):
el_tracker.stopRecording()

clear_screen(win)
bgcolor_RGB = config.bg_color
bgcolor_RGB = rtPupil_config.bg_color
el_tracker.sendMessage('!V CLEAR %d %d %d' % bgcolor_RGB)
el_tracker.sendMessage('TRIAL_RESULT %d' % pylink.TRIAL_ERROR)

Expand Down Expand Up @@ -153,7 +153,7 @@ def block_trigger(win):

scn_width, scn_height = win.size
# On-screen text
onscreen_instructions = visual.TextStim(win, text='Waiting to start. Standby...', color = config.text_color, wrapWidth = scn_width/2)
onscreen_instructions = visual.TextStim(win, text='Waiting to start. Standby...', color = rtPupil_config.text_color, wrapWidth = scn_width/2)
onscreen_instructions.draw()
win.flip()

Expand Down Expand Up @@ -199,7 +199,7 @@ def instructions_screens(win, instruction:str):

scn_width, scn_height = win.size
# Setup text
task_instructions = visual.TextStim(win, instruction, color = config.text_color, wrapWidth = scn_width/2, units = 'cm')
task_instructions = visual.TextStim(win, instruction, color = rtPupil_config.text_color, wrapWidth = scn_width/2, units = 'cm')

# Clear window
clear_screen(win)
Expand Down Expand Up @@ -230,7 +230,7 @@ def general_instruction_screens(win, fixation):
instructions = "Please fixate on the fixation point at all times."

# Setup instructions
task_instructions = visual.TextStim(win, text='', color=config.text_color, pos=[0, 5], units='cm')
task_instructions = visual.TextStim(win, text='', color=rtPupil_config.text_color, pos=[0, 5], units='cm')

# Draw the text
task_instructions.setText(instructions)
Expand Down
Loading

0 comments on commit c817295

Please sign in to comment.