Skip to content

Commit 9b5d654

Browse files
committed
Add GUI functionality and update verbose flag
1 parent 1882e26 commit 9b5d654

File tree

2 files changed

+246
-193
lines changed

2 files changed

+246
-193
lines changed

README.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1-
## BioAmp-Tool-Python
1+
## BioAmp Tool - Python
22

3-
The BioAmp Tool is a Python script designed to interface with an Arduino-based bioamplifier, read data from it, and optionally log this data to CSV or stream it via the Lab Streaming Layer (LSL).
3+
The BioAmp Tool is a Python script designed to interface with an Arduino-based bioamplifier, read data from it, optionally log this data to CSV or stream it via the Lab Streaming Layer (LSL), and visualize it through a graphical user interface (GUI) with live plotting.
44

55
## Features
66

77
- **Automatic Arduino Detection:** Automatically detects connected Arduino devices via serial ports.
8-
- **Data Reading:** Reads ModularEEG P2 format data packets from the Arduino's serial port.
8+
- **Data Reading:** Reads and processes data packets from the Arduino.
99
- **CSV Logging:** Optionally logs data to a CSV file.
1010
- **LSL Streaming:** Optionally streams data to an LSL outlet for integration with other software.
11-
- **Verbose Output:** Provides detailed statistics and error reporting.
11+
- **Verbose Output:** Provides detailed statistics and error reporting, including sampling rate and drift.
12+
- **GUI:** Live plotting of six channels using a PyQt-based GUI.
1213

1314
## Requirements
1415

1516
- Python 3.x
1617
- `pyserial` library (for serial communication)
1718
- `pylsl` library (for LSL streaming)
1819
- `argparse`, `time`, `csv`, `datetime` (standard libraries)
20+
- `pyqtgraph` library (for GUI)
21+
- `PyQt5` library
22+
- `numpy` library
1923

2024
## Installation
2125

2226
1. Ensure you have Python 3.x installed.
2327
2. Install the required Python libraries:
24-
```bash
25-
pip install pyserial pylsl
26-
```
28+
```bash
29+
pip install pyqtgraph pyqt5 numpy pyserial pylsl
30+
```
2731

2832
## Usage
2933

30-
To use the script, you can run it from the command line with various options:
34+
To use the script, run it from the command line with various options:
3135

3236
```bash
3337
python bioamp_tool.py [options]
@@ -36,11 +40,11 @@ python bioamp_tool.py [options]
3640
### Options
3741

3842
- `-p`, `--port` <port>: Specify the serial port to use (e.g., COM5, /dev/ttyUSB0).
39-
- `-b`, `--baudrate` <baudrate>: Set the baud rate for serial communication (default is 57600).
40-
- `--csv`: Enable CSV logging. Data will be saved to a file with a timestamped name.
43+
- `-b`, `--baudrate` <baudrate>: Set the baud rate for serial communication (default is 115200).
44+
- `--csv`: Enable CSV logging. Data will be saved to a timestamped file.
4145
- `--lsl`: Enable LSL streaming. Sends data to an LSL outlet.
4246
- `-v`, `--verbose`: Enable verbose output with detailed statistics and error reporting.
43-
47+
- `--gui`: Enable the real-time data plotting GUI.
4448

4549
## Script Functions
4650

@@ -54,32 +58,36 @@ Reads and processes data from the Arduino. Writes data to CSV and/or LSL stream
5458

5559
### `start_timer()`
5660

57-
Initializes timers for 10-second and 10-minute intervals.
61+
Initializes timers for 1-second and 10-minute intervals.
5862

59-
### `log_ten_second_data(verbose=False)`
63+
### `log_one_second_data(verbose=False)`
6064

61-
Logs and resets data for the 10-second interval.
65+
Logs and resets data for the 1-second interval.
6266

6367
### `log_ten_minute_data(verbose=False)`
6468

6569
Logs data and statistics for the 10-minute interval.
6670

67-
### `parse_data(port, baudrate, lsl_flag=False, csv_flag=False, verbose=False)`
71+
### `parse_data(port, baudrate, lsl_flag=False, csv_flag=False, gui_flag=False, verbose=False)`
72+
73+
Parses data from Arduino and manages logging, streaming, and GUI updates.
74+
75+
### `init_gui()`
6876

69-
Parses data from Arduino and manages logging and streaming.
77+
Initializes and displays the GUI with six real-time plots, one for each bio-signal channel.
7078

7179
### `main()`
7280

7381
Handles command-line argument parsing and initiates data processing.
7482

7583
## Data Logging
7684

77-
- **CSV Output**: The script saves the processed data in a CSV file named `packet_data.csv`.
78-
- The CSV contains the following columns:
85+
- **CSV Output**: The script saves the processed data in a CSV file with a timestamped name.
86+
- The CSV file contains the following columns:
7987
- `Counter`: The sample counter from the Arduino.
8088
- `Channel1` to `Channel6`: The data values from each channel.
8189

82-
- **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.
90+
- **Log Intervals**: The script logs data counts every second and provides a summary every 10 minutes, including the sampling rate and drift in seconds per hour.
8391

8492
## LSL Streaming
8593

@@ -89,7 +97,7 @@ Handles command-line argument parsing and initiates data processing.
8997
- **Sampling Rate**: `250 Hz`
9098
- **Data Format**: `float32`
9199

92-
Use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
100+
If GUI is not enabled, you can use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
93101

94102
## Troubleshooting
95103

@@ -102,4 +110,3 @@ Use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data
102110
We are thankful to our awesome contributors, the list below is alphabetically sorted.
103111

104112
- [Payal Lakra](https://github.com/payallakra)
105-

0 commit comments

Comments
 (0)