You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/post/2026-01-09-EventTriggers/index.md
+110-8Lines changed: 110 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Lets start with some basics!
27
27
28
28
## What does this mean and when is this useful?
29
29
30
-
Lab streaming layer (LSL) is a system used to receive, synchronise and stream signals from multiple inputs during experiments. LSL is designed to help researchers easily compare their data across multiple technologies, as time synchrony is integral for making valid comparisons.
30
+
Lab streaming layer (LSL) is a system used to receive, synchronise and stream signals from multiple inputs during experiments. LSL is designed to help researchers easily compare their data across multiple technologies, as time synchrony is integral for making meaningful analyses.
31
31
32
32
When collecting data on stimulus response during experiments, it's important that the stimulus onset is recorded precisely, especially if this is mapped onto physiological responses as this has implications on how we interpret our data. One good example of a use case is that you have a Muse headband or any other device that can scream via LSL, and you want to precisely mark events in it.
33
33
@@ -41,15 +41,109 @@ This blog will help you understand the set-up for event triggers. For an example
41
41
42
42
## How to set up event triggers
43
43
44
-
####Requirements:
44
+
### Requirements
45
45
46
46
-**Your experiment is in-person:** In order to use these event triggers, you will need to run your experiment on a local host server, which will need to be manually set up for each trial. Therefore, this setup is intended for in-person experiments that are led by a researcher to set up the participant's screen.
47
47
48
-
-**The researcher and the participant(s) each have a computer:** The participant's computer will send the markers to the researcher's computer, which will be used to record the events (and all other signals using LSL) during the trial.
48
+
-**You have two computers, one for the participant, and for recording:** The participant's computer will display the experiment andsend the markers to the researcher's computer, which will be used to capture the LSL streams record the events.
49
+
50
+
### The LSL bridge script
51
+
52
+
The LSL bridge Python script is the one responsible for actually sending the markers to LSL- it 'listens' for messages from the browser that the participant is doing the experiment from, and converts them into 'markers' for your recording software (such as LabRecorder) will receive.
53
+
54
+
<details>
55
+
56
+
<summary>See an example of a full script</summary>
57
+
58
+
```python
59
+
from http.server import BaseHTTPRequestHandler, HTTPServer
60
+
from urllib.parse import urlparse, parse_qs
61
+
from mne_lsl.lsl import StreamInfo, StreamOutlet, local_clock
The LSL bridge will send the markers to LSL- it 'listens' for messages from the browser that the participant is doing the experiment from, and converts them into 'markers' for your recording software (such as LabRecorder) will receive.
53
147
54
148
1. Configuration
55
149
@@ -88,9 +182,9 @@ The LSL bridge will send the markers to LSL- it 'listens' for messages from the
88
182
-`run_server()`: Starts the HTTP server and prints a confirmation message that it is ready for LabRecorder.
89
183
-`threading.Thread(...)`: Runs the server in a separate thread so it doesn't block the main Python process.
90
184
91
-
#### Synchronise your event triggers in the html script:
185
+
###Configuration of the JsPsych HTML script
92
186
93
-
This is 'promise-based', meaning it is coded to wait until it receives a signal from the participant's computer. This javascript code is designed to track the exact time it is on the participant's computer and send markers precisely aligned to that time.
187
+
The code sending triggers from the browser to the LSL bridge script is written in javascript. It is 'promise-based', meaning it is coded to wait until it receives a signal from the participant's computer. This javascript code is designed to track the exact time it is on the participant's computer and send markers precisely aligned to that time.
94
188
95
189
1. Synchronisation
96
190
@@ -116,4 +210,12 @@ This is 'promise-based', meaning it is coded to wait until it receives a signal
116
210
117
211
- Send the marker name and this calculated timestamp to the python bridge: `fetch(url)`.
118
212
213
+
214
+
### Usage
215
+
216
+
1. Open the terminal...
217
+
2. Run the expe...
218
+
219
+
220
+
119
221
You are now ready to record event triggers during your experiment. For a guide on how to set this up, you can refer to the README.md file of: <https://github.com/OliverACollins/muse-athena-test>.
0 commit comments