Skip to content

Commit 1d27980

Browse files
authored
Merge pull request #8 from PayalLakra/bio_amptool
Add GUI function
2 parents e44b95b + 08e749a commit 1d27980

File tree

3 files changed

+269
-204
lines changed

3 files changed

+269
-204
lines changed

README.md

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,101 @@
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:** Read ModularEEG P2 format data packets from the Arduino's serial port.
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 -r requirements.txt
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

32-
```bash
33-
python bioamp_tool.py [options]
34-
```
36+
First Create Virtual Environment
37+
38+
```bash
39+
python -m venv venv #Create Virtual Environment
40+
.\venv\Scripts\activate #to activate environment
41+
```
42+
Then,
43+
44+
```bash
45+
python bioamp_tool.py [options]
46+
```
3547

3648
### Options
3749

3850
- `-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.
51+
- `-b`, `--baudrate` <baudrate>: Set the baud rate for serial communication (default is 115200).
52+
- `--csv`: Enable CSV logging. Data will be saved to a timestamped file.
4153
- `--lsl`: Enable LSL streaming. Sends data to an LSL outlet.
4254
- `-v`, `--verbose`: Enable verbose output with detailed statistics and error reporting.
43-
55+
- `--gui`: Enable the real-time data plotting GUI.
4456

4557
## Script Functions
4658

47-
- `auto_detect_arduino(baudrate, timeout=1)`
59+
`auto_detect_arduino(baudrate, timeout=1)`
4860

4961
Detects an Arduino connected via serial port. Returns the port name if detected.
5062

51-
- `read_arduino_data(ser, csv_writer=None)`
63+
`read_arduino_data(ser, csv_writer=None)`
5264

5365
Reads and processes data from the Arduino. Writes data to CSV and/or LSL stream if enabled.
5466

55-
- `start_timer()`
67+
`start_timer()`
5668
57-
Initializes timers for 10-second and 10-minute intervals.
69+
Initializes timers for 1-second and 10-minute intervals.
5870
59-
- `log_ten_second_data(verbose=False)`
71+
`log_one_second_data(verbose=False)`
6072
61-
Logs and resets data for the 10-second interval.
73+
Logs and resets data for the 1-second interval.
6274
63-
- `log_ten_minute_data(verbose=False)`
75+
`log_ten_minute_data(verbose=False)`
6476
6577
Logs data and statistics for the 10-minute interval.
6678
67-
- `parse_data(port, baudrate, lsl_flag=False, csv_flag=False, verbose=False)`
79+
`parse_data(port, baudrate, lsl_flag=False, csv_flag=False, gui_flag=False, verbose=False)`
80+
81+
Parses data from Arduino and manages logging, streaming, and GUI updates.
82+
83+
`init_gui()`
6884
69-
Parses data from Arduino and manages logging and streaming.
85+
Initializes and displays the GUI with six real-time plots, one for each bio-signal channel.
7086
71-
- `main()`
87+
`main()`
7288
7389
Handles command-line argument parsing and initiates data processing.
7490
7591
## Data Logging
7692
77-
- **CSV Output**: The script saves the processed data in a CSV file named `packet_data.csv`.
78-
- The CSV contains the following columns:
93+
- **CSV Output**: The script saves the processed data in a CSV file with a timestamped name.
94+
- The CSV file contains the following columns:
7995
- `Counter`: The sample counter from the Arduino.
8096
- `Channel1` to `Channel6`: The data values from each channel.
8197
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.
98+
- **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.
8399
84100
## LSL Streaming
85101
@@ -89,7 +105,7 @@ Handles command-line argument parsing and initiates data processing.
89105
- **Sampling Rate**: `250 Hz`
90106
- **Data Format**: `float32`
91107
92-
Use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
108+
If GUI is not enabled, you can use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
93109
94110
## Troubleshooting
95111
@@ -101,5 +117,4 @@ Use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data
101117
102118
We are thankful to our awesome contributors, the list below is alphabetically sorted.
103119
104-
- [Payal Lakra](https://github.com/payallakra)
105-
120+
- [Payal Lakra](https://github.com/payallakra)

0 commit comments

Comments
 (0)