Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaczmarj/psychopy-lsl
Use LabStreamingLayer to handle triggers with PsychoPy.
https://github.com/kaczmarj/psychopy-lsl
eeg labstreaminglayer psychopy python research
Last synced: 21 days ago
JSON representation
Use LabStreamingLayer to handle triggers with PsychoPy.
- Host: GitHub
- URL: https://github.com/kaczmarj/psychopy-lsl
- Owner: kaczmarj
- Created: 2016-10-12T13:33:32.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-20T18:41:20.000Z (about 3 years ago)
- Last Synced: 2024-10-04T15:55:20.565Z (about 1 month ago)
- Topics: eeg, labstreaminglayer, psychopy, python, research
- Language: Python
- Homepage:
- Size: 212 KB
- Stars: 21
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PsychoPy event markers with LabStreamingLayer
This repository demonstrates how to send event markers in PsychoPy with [LabStreamingLayer](https://github.com/sccn/labstreaminglayer) (LSL).
See [coregui.md](/coregui.md) to learn how to receive markers in Coregui with LSL.
Example scripts
---------------- [`example_coder.py`](/example_coder.py) is a minimal PsychoPy "experiment". Two words alternate on the screen, and a marker is sent whenever a word appears. This was coded manually.
- [`example_builder.py`](/example_builder.py) behaves in the same way as `example_coder.py`, but it was created in the builder and uses stimuli and markers defined in `example_builder.csv`General steps
-------------1. Install `pylsl` (the Python interface of LSL).
1. Include code in your Python script to send markers.Install LabStreamingLayer
-------------------------See the [PyPI page](https://pypi.python.org/pypi/pylsl).
```
pip install pylsl
```In your PsychoPy code
---------------------Refer to [pylsl.py](https://github.com/labstreaminglayer/liblsl-Python/blob/master/pylsl/pylsl.py) for documentation on `pylsl` functions.
```python
# ...
from pylsl import StreamInfo, StreamOutlet
info = StreamInfo(name='my_stream_name', type='Markers', channel_count=1,
channel_format='int32', source_id='uniqueid12345')
# Initialize the stream.
outlet = StreamOutlet(info)
# ...
```
- Include markers wherever you need them.
```python
# ...
outlet.push_sample(x=[100])
# ...
```
- The example above sends a marker 100. `x` must be a list with a length equal to `channel_count` (specified in `StreamInfo`). It is easiest to use integers as markers.
- You can also include dynamic marker names (see [example script](/example_builder.py)). If you are using a trial loop in PsychoPy, include marker values in a column in the spreadsheet used for the loop. If the column header is "marker", the code would be `outlet.push_sample(x=[marker])`.