Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion eegnb/experiments/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class BaseExperiment(ABC):

def __init__(self, exp_name, duration, eeg, save_fn, n_trials: int, iti: float, soa: float, jitter: float,
use_vr=False, use_fullscr = True, screen_num=0, stereoscopic = False):
use_vr=False, use_fullscr = True, screen_num=0, stereoscopic = False, devices = list):
""" Initializer for the Base Experiment Class

Args:
Expand All @@ -50,6 +50,7 @@ def __init__(self, exp_name, duration, eeg, save_fn, n_trials: int, iti: float,
Press spacebar to continue. \n""".format(self.exp_name)
self.duration = duration
self.eeg: EEG = eeg
self.devices = devices
self.save_fn = save_fn
self.n_trials = n_trials
self.iti = iti
Expand Down Expand Up @@ -338,6 +339,15 @@ def run(self, instructions=True):
# Closing the window
self.window.close()



def send_triggers(self, marker):
"""Send timing triggers to recording device[s]"""
for dev in self.devices:
timestamp = time()
dev.push_sample(marker=marker, timestamp=timestamp)


@property
def name(self) -> str:
""" This experiment's name """
Expand Down
20 changes: 15 additions & 5 deletions eegnb/experiments/visual_n170/n170.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@

class VisualN170(Experiment.BaseExperiment):

def __init__(self, duration=120, eeg: Optional[EEG]=None, save_fn=None,

def __init__(self, duration=120, eeg: Optional[EEG]=None, devices: Optional[list]=None,save_fn=None,
n_trials = 2010, iti = 0.4, soa = 0.3, jitter = 0.2, use_vr = False):

# Set experiment name
exp_name = "Visual N170"
# Calling the super class constructor to initialize the experiment variables
super(VisualN170, self).__init__(exp_name, duration, eeg, save_fn, n_trials, iti, soa, jitter, use_vr)
super(VisualN170, self).__init__(exp_name, duration, eeg, save_fn, n_trials, iti, soa, jitter, use_vr, devices=devices)

def load_stimulus(self):

Expand All @@ -45,13 +44,24 @@ def present_stimulus(self, idx: int):
# Draw the image
image.draw()


# Pushing the sample to the EEG
if self.eeg:
timestamp = time()

if self.eeg.backend == "muselsl":
marker = [self.markernames[label]]
else:
marker = self.markernames[label]

self.eeg.push_sample(marker=marker, timestamp=timestamp)

self.window.flip()


if self.devices:
marker = self.markernames[label]
self.send_triggers(marker)


self.window.flip()


Loading