Skip to content

Commit

Permalink
bugfix: pass down trial parameter to subclass as was previously done …
Browse files Browse the repository at this point in the history
…before VR code modified rendering logic.

Also fixed baseclass 'present_stimulus' method signature to match arguments as expected for subclass to implement.
  • Loading branch information
pellet committed Oct 2, 2024
1 parent a74046f commit 4c0673a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions eegnb/experiments/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

from abc import abstractmethod
from typing import Callable
from typing import Callable, Any
from psychopy import prefs
#change the pref libraty to PTB and set the latency mode to high precision
prefs.hardware['audioLib'] = 'PTB'
Expand Down Expand Up @@ -61,14 +61,15 @@ def load_stimulus(self):
raise NotImplementedError

@abstractmethod
def present_stimulus(self, idx : int):
def present_stimulus(self, idx: int, trial: Any):
"""
Method that presents the stimulus for the specific experiment, overwritten by the specific experiment
Displays the stimulus on the screen
Pushes EEG Sample if EEG is enabled
Throws error if not overwritten in the specific experiment
idx : Trial index for the current trial
trial : Current trial(parameter, timestamp)
"""
raise NotImplementedError

Expand Down Expand Up @@ -169,6 +170,8 @@ def iti_with_jitter():

# Current trial being rendered
rendering_trial = -1
# Iterate through the events
iterate_events = self.trials.iterrows()
while len(event.getKeys()) == 0 and (time() - start) < self.record_duration:

current_experiment_seconds = time() - start
Expand All @@ -185,7 +188,8 @@ def iti_with_jitter():
if rendering_trial < current_trial:
# Some form of presenting the stimulus - sometimes order changed in lower files like ssvep
# Stimulus presentation overwritten by specific experiment
self.__draw(lambda: self.present_stimulus(current_trial, current_trial))
ii, trial = next(iterate_events)
self.__draw(lambda: self.present_stimulus(ii, trial))
rendering_trial = current_trial
else:
self.__draw(lambda: self.window.flip())
Expand Down

0 comments on commit 4c0673a

Please sign in to comment.