Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mulimoen/eegportcodes
Send portcodes/triggger codes from display computer to EEG recorder
https://github.com/mulimoen/eegportcodes
brainproducts eeg portcodes triggercodes
Last synced: about 1 month ago
JSON representation
Send portcodes/triggger codes from display computer to EEG recorder
- Host: GitHub
- URL: https://github.com/mulimoen/eegportcodes
- Owner: mulimoen
- License: mit
- Created: 2019-04-26T20:53:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-04-26T21:00:34.000Z (over 5 years ago)
- Last Synced: 2024-10-15T21:38:57.080Z (3 months ago)
- Topics: brainproducts, eeg, portcodes, triggercodes
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EEGportcodes
This program gives the user the possibility of sending trigger codes (portcodes) to to an EEG machine. This can be used in conjunction with for example BrainProducts EEG.
## Background
An EEG (Electroencephalogram) experiment often consists of two machines, a display computer and an EEG recorder, separated for latency reasons. The display computer must communicate with the EEG recorder to synchronise stimulus presentation and trigger codes. This communication can be done over the parallel port, which modern machines are not usually equpped with. The parallel port can be emulated over a serial port, and this program treats the serial port as a parallel port, only allowing one signal (byte) at a time.## Usage
The main program ([portcode.py](portcode.py)) can be import in a program with
```python3
import PortCodeHandlerpch = PortCodeHandler()
# Stimulus, emit code:
pch.send_portcode(2)# Do other stuff
# Signal new stimulus
pch.send_portcode(4)# Done sending portcodes, must close the handle
pch.close()
```
A testing program can executed by running portcode.py directly. BrainProducts EEG expects the portcodes to be powers of two, which gives 8 unique signals (1, 2, 4, 8, 16, 32, 64, 128). This will show up as triggers on the EEG recordings.## Dependencies
This program requires python3 and [pySerial](https://pythonhosted.org/pyserial/)## Technical details
The program spawns a background thread to read portcodes from the caller (stimulus machine) and send over the wire to the EEG recorder. Using this background thread ensures the stimulus machine does not skip a frame, while the signal will be sent properly.The program supports sending multiple codes simultaneously, and will multiplex them, by bitwise of of the input codes. If 0 is sent, this will act as a flush, waiting until all signals have been sent before processing new codes.