Skip to content

Commit 0f92e79

Browse files
committed
Merge branch 'bio_amptool' of https://github.com/PayalLakra/BioAmp-Tool-Python into patch-1
2 parents 0ce9425 + dad0c5c commit 0f92e79

File tree

2 files changed

+278
-190
lines changed

2 files changed

+278
-190
lines changed

README.md

Lines changed: 58 additions & 18 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,14 +40,15 @@ 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

51+
<<<<<<< HEAD
4752
- `auto_detect_arduino(baudrate, timeout=1)`
4853

4954
Detects an Arduino connected via serial port. Returns the port name if detected.
@@ -53,33 +58,64 @@ Detects an Arduino connected via serial port. Returns the port name if detected.
5358
Reads and processes data from the Arduino. Writes data to CSV and/or LSL stream if enabled.
5459

5560
- `start_timer()`
61+
=======
62+
`auto_detect_arduino(baudrate, timeout=1)`
63+
64+
Detects an Arduino connected via serial port. Returns the port name if detected.
65+
66+
`read_arduino_data(ser, csv_writer=None)`
67+
68+
Reads and processes data from the Arduino. Writes data to CSV and/or LSL stream if enabled.
69+
70+
`start_timer()`
71+
>>>>>>> dad0c5ce4e301f8187a6a047dda450833539ab61
5672
57-
Initializes timers for 10-second and 10-minute intervals.
73+
Initializes timers for 1-second and 10-minute intervals.
5874
75+
<<<<<<< HEAD
5976
- `log_ten_second_data(verbose=False)`
77+
=======
78+
`log_one_second_data(verbose=False)`
79+
>>>>>>> dad0c5ce4e301f8187a6a047dda450833539ab61
6080
61-
Logs and resets data for the 10-second interval.
81+
Logs and resets data for the 1-second interval.
6282
83+
<<<<<<< HEAD
6384
- `log_ten_minute_data(verbose=False)`
6485
6586
Logs data and statistics for the 10-minute interval.
6687
6788
- `parse_data(port, baudrate, lsl_flag=False, csv_flag=False, verbose=False)`
89+
=======
90+
`log_ten_minute_data(verbose=False)`
6891
69-
Parses data from Arduino and manages logging and streaming.
92+
Logs data and statistics for the 10-minute interval.
93+
94+
`parse_data(port, baudrate, lsl_flag=False, csv_flag=False, gui_flag=False, verbose=False)`
95+
>>>>>>> dad0c5ce4e301f8187a6a047dda450833539ab61
96+
97+
Parses data from Arduino and manages logging, streaming, and GUI updates.
7098
99+
<<<<<<< HEAD
71100
- `main()`
101+
=======
102+
`init_gui()`
103+
104+
Initializes and displays the GUI with six real-time plots, one for each bio-signal channel.
105+
106+
`main()`
107+
>>>>>>> dad0c5ce4e301f8187a6a047dda450833539ab61
72108
73109
Handles command-line argument parsing and initiates data processing.
74110
75111
## Data Logging
76112
77-
- **CSV Output**: The script saves the processed data in a CSV file named `packet_data.csv`.
78-
- The CSV contains the following columns:
113+
- **CSV Output**: The script saves the processed data in a CSV file with a timestamped name.
114+
- The CSV file contains the following columns:
79115
- `Counter`: The sample counter from the Arduino.
80116
- `Channel1` to `Channel6`: The data values from each channel.
81117
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.
118+
- **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.
83119
84120
## LSL Streaming
85121
@@ -89,7 +125,7 @@ Handles command-line argument parsing and initiates data processing.
89125
- **Sampling Rate**: `250 Hz`
90126
- **Data Format**: `float32`
91127
92-
Use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
128+
If GUI is not enabled, you can use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
93129
94130
## Troubleshooting
95131
@@ -101,5 +137,9 @@ Use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data
101137
102138
We are thankful to our awesome contributors, the list below is alphabetically sorted.
103139
140+
<<<<<<< HEAD
104141
- [Payal Lakra](https://github.com/payallakra)
105142
143+
=======
144+
- [Payal Lakra](https://github.com/payallakra)
145+
>>>>>>> dad0c5ce4e301f8187a6a047dda450833539ab61

0 commit comments

Comments
 (0)