diff --git a/eegnb/experiments/Experiment.py b/eegnb/experiments/Experiment.py index 963a9aa3..539dc396 100644 --- a/eegnb/experiments/Experiment.py +++ b/eegnb/experiments/Experiment.py @@ -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' @@ -61,7 +61,7 @@ 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 @@ -69,6 +69,7 @@ def present_stimulus(self, idx : int): Throws error if not overwritten in the specific experiment idx : Trial index for the current trial + trial : Current trial(parameter, timestamp) """ raise NotImplementedError @@ -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 @@ -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())