From 82754893f552d6bc30128c1df0c600454a7fff2b Mon Sep 17 00:00:00 2001 From: Ben Pettit Date: Sun, 10 Nov 2024 15:37:46 +1000 Subject: [PATCH] removed unnecessary trial parameter and fixed aob experiment to run on windows again --- eegnb/experiments/Experiment.py | 4 ++-- eegnb/experiments/auditory_oddball/aob.py | 10 +++++++--- eegnb/experiments/visual_n170/n170.py | 2 +- eegnb/experiments/visual_p300/p300.py | 2 +- eegnb/experiments/visual_ssvep/ssvep.py | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/eegnb/experiments/Experiment.py b/eegnb/experiments/Experiment.py index 963a9aa3..0fbf71bd 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' @@ -185,7 +185,7 @@ 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)) + self.__draw(lambda: self.present_stimulus(current_trial)) rendering_trial = current_trial else: self.__draw(lambda: self.window.flip()) diff --git a/eegnb/experiments/auditory_oddball/aob.py b/eegnb/experiments/auditory_oddball/aob.py index 607b2df8..a53d583a 100644 --- a/eegnb/experiments/auditory_oddball/aob.py +++ b/eegnb/experiments/auditory_oddball/aob.py @@ -1,8 +1,12 @@ import numpy as np from pandas import DataFrame from psychopy import prefs + # PTB does not yet support macOS Apple Silicon, need to fall back to sounddevice. -prefs.hardware['audioLib'] = ['sounddevice'] +import sys +if sys.platform == 'darwin': + prefs.hardware['audioLib'] = ['sounddevice'] + from psychopy import visual, core, event, sound from time import time @@ -72,11 +76,11 @@ def load_stimulus(self): return - def present_stimulus(self, idx : int, trial): + def present_stimulus(self, idx: int): """ Presents the Stimulus """ # Select and play sound - ind = int(trial["sound_ind"]) + ind = int(self.trials["sound_ind"].iloc[idx]) self.auds[ind].stop() self.auds[ind].play() diff --git a/eegnb/experiments/visual_n170/n170.py b/eegnb/experiments/visual_n170/n170.py index 4cf42aad..6c41fbba 100644 --- a/eegnb/experiments/visual_n170/n170.py +++ b/eegnb/experiments/visual_n170/n170.py @@ -41,7 +41,7 @@ def load_stimulus(self): # Return the list of images as a stimulus object return [self.houses, self.faces] - def present_stimulus(self, idx : int, trial): + def present_stimulus(self, idx: int): # Get the label of the trial label = self.trials["parameter"].iloc[idx] diff --git a/eegnb/experiments/visual_p300/p300.py b/eegnb/experiments/visual_p300/p300.py index 08560d1a..d6a8a1df 100644 --- a/eegnb/experiments/visual_p300/p300.py +++ b/eegnb/experiments/visual_p300/p300.py @@ -35,7 +35,7 @@ def load_stimulus(self): return [self.nontargets, self.targets] - def present_stimulus(self, idx:int, trial): + def present_stimulus(self, idx: int): label = self.trials["parameter"].iloc[idx] image = choice(self.targets if label == 1 else self.nontargets) diff --git a/eegnb/experiments/visual_ssvep/ssvep.py b/eegnb/experiments/visual_ssvep/ssvep.py index 46119f55..94ae9121 100644 --- a/eegnb/experiments/visual_ssvep/ssvep.py +++ b/eegnb/experiments/visual_ssvep/ssvep.py @@ -91,8 +91,8 @@ def init_flicker_stim(frame_rate, cycle, soa): init_flicker_stim(frame_rate, 3, self.soa), ] - def present_stimulus(self, idx, trial): - + def present_stimulus(self, idx: int): + # Select stimulus frequency ind = self.trials["parameter"].iloc[idx]