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
A python tool to record data from BioAmp hardware.
2
+
3
+
A python tool to record data from BioAmp hardware.This project is designed to read data from an Arduino via a serial connection, process the data, and stream it using the Lab Streaming Layer (LSL) protocol. It also logs the processed data to a CSV file for further analysis.
4
+
5
+
## Features
6
+
7
+
- Auto-detects connected Arduino devices.
8
+
- Reads and processes data packets from Arduino.
9
+
- Streams data via LSL for real-time analysis.
10
+
- Logs data to a CSV file, including counters and channel data.
11
+
- Calculates and logs sampling rate and drift.
12
+
- Handles missing samples and prints relevant errors.
13
+
14
+
## Requirements
15
+
16
+
- Python 3.7 or higher
17
+
-[pySerial](https://pypi.org/project/pyserial/)
18
+
-[pylsl](https://pypi.org/project/pylsl/)
19
+
- An Arduino device capable of sending serial data packets
1. **Connect your Arduino** to your computer via USB.
36
+
37
+
2. **Run the script** with the desired options:
38
+
```bash
39
+
python bioamptool.py --detect
40
+
```
41
+
42
+
3. **View the output** on your console, which will include minute-by-minute data counts, 10-minute summaries, sampling rate , any detected errors or drift.
43
+
44
+
## Command-line Options
45
+
46
+
- `-d, --detect`: Auto-detect the Arduino COM port.
47
+
- `-p, --port`: Specify the COM port (e.g., `COM3` on Windows or `/dev/ttyUSB0` on Linux).
48
+
- `-b, --baudrate`: Set the baud rate for serial communication (default is `57600`).
49
+
50
+
Example:
51
+
```bash
52
+
python bioamptool.py --detect
53
+
```
54
+
55
+
## Data Logging
56
+
57
+
- **CSV Output**: The script saves the processed data in a CSV file named `packet_data.csv`.
58
+
- The CSV contains the following columns:
59
+
- `Counter`: The sample counter from the Arduino.
60
+
- `Channel1` to `Channel6`: The data values from each channel.
61
+
62
+
- **Log Intervals**: The script logs data counts every minute and provides a summary every 10 minutes, including the sampling rate and drift in seconds per hour.
63
+
64
+
## LSL Streaming
65
+
66
+
- **Stream Name**: `BioAmpDataStream`
67
+
- **Stream Type**: `EXG`
68
+
- **Channel Count**: `6`
69
+
- **Sampling Rate**: `250 Hz`
70
+
- **Data Format**: `float32`
71
+
72
+
Use an LSL viewer (e.g., BrainVision Recorder) to visualize the streamed data in real-time.
73
+
74
+
## Troubleshooting
75
+
76
+
- **Arduino Not Detected**: Ensure your Arduino is properly connected and recognized by your system. Use the `--detect` option to automatically find the Arduino port.
77
+
- **Invalid Data Packets**: If you see messages about invalid data packets, check the data format and synchronization bytes being sent from the Arduino.
78
+
- **Zero LSL Stream Utilization**: If the LSL stream shows 0% utilization, verify the stream is properly set up and data is being pushed to the outlet.
79
+
80
+
## Contributors
81
+
82
+
We are thankful to our awesome contributors, the list below is alphabetically sorted.
0 commit comments