Skip to content

Commit d4c4287

Browse files
committed
Updated Readme according to the new changes
1 parent c5533c6 commit d4c4287

File tree

1 file changed

+61
-48
lines changed

1 file changed

+61
-48
lines changed

README.md

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,21 @@ Chords Python script is designed to interface with an Arduino-based bioamplifier
2828
## Installation
2929

3030
1. Ensure you have Python 3.x installed.
31-
2. Install the required Python libraries:
31+
2. Create Virtual Environment
32+
```bash
33+
python -m venv venv #Create Virtual Environment
34+
.\venv\Scripts\activate #to activate environment
35+
3. Install the required Python libraries:
3236
```bash
3337
pip install -r requirements.txt
3438
```
3539

3640
## Usage
3741

3842
To use the script, run it from the command line with various options:
39-
40-
First Create Virtual Environment
41-
42-
```bash
43-
python -m venv venv #Create Virtual Environment
44-
.\venv\Scripts\activate #to activate environment
45-
```
46-
Then,
47-
4843
```bash
4944
python chords.py [options]
5045
```
51-
5246
### Options
5347

5448
- `-p`, `--port` <port>: Specify the serial port to use (e.g., COM5, /dev/ttyUSB0).
@@ -58,72 +52,91 @@ Then,
5852
- `-v`, `--verbose`: Enable verbose output with detailed statistics and error reporting.
5953
- `-t` : Enable the timer to run program for a set time in seconds.
6054

61-
## Applications
55+
### Data Logging
6256

63-
### GUI
57+
- **CSV Output**: The script saves the processed data in a CSV file with a timestamped name.
58+
- The CSV file contains the following columns:
59+
- `Counter`: The sample counter from the Arduino.
60+
- `Channel1` to `Channel6`: The data values from each channel.
6461

65-
- `python gui.py`: Enable the real-time data plotting GUI.
62+
- **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.
6663

67-
### FORCE BALL GAME
64+
### LSL Streaming
6865

69-
- `python game.py`: Enable a GUI to play game using EEG Signal.
66+
- **Stream Name**: `BioAmpDataStream`
67+
- **Stream Type**: `EXG`
68+
- **Channel Count**: `6`
69+
- **Sampling Rate**: `UNO-R3 : 250 Hz` , `UNO-R4 : 500 Hz`
70+
- **Data Format**: `float32`
7071

71-
## Script Functions
7272

73-
`auto_detect_arduino(baudrate, timeout=1)`
73+
### Script Functions
7474

75-
Detects an Arduino connected via serial port. Returns the port name if detected.
75+
`auto_detect_arduino(baudrate, timeout=1)`: Detects an Arduino connected via serial port. Returns the port name if detected.
7676

77-
`read_arduino_data(ser, csv_writer=None)`
77+
`read_arduino_data(ser, csv_writer=None)`: Reads and processes data from the Arduino. Writes data to CSV and/or LSL stream if enabled.
7878

79-
Reads and processes data from the Arduino. Writes data to CSV and/or LSL stream if enabled.
79+
`start_timer()`: Initializes timers for 1-second and 10-minute intervals.
8080
81-
`start_timer()`
81+
`log_one_second_data(verbose=False)`: Logs and resets data for the 1-second interval.
8282
83-
Initializes timers for 1-second and 10-minute intervals.
83+
`log_ten_minute_data(verbose=False)`: Logs data and statistics for the 10-minute interval.
8484
85-
`log_one_second_data(verbose=False)`
85+
`parse_data(port,baudrate,lsl_flag=False,csv_flag=False,verbose=False)`: Parses data from Arduino and manages logging, streaming, and GUI updates.
8686
87-
Logs and resets data for the 1-second interval.
87+
`cleanup()`: Handles all the cleanup tasks.
8888
89-
`log_ten_minute_data(verbose=False)`
89+
`main()`: Handles command-line argument parsing and initiates data processing.
9090
91-
Logs data and statistics for the 10-minute interval.
91+
## Applications
9292
93-
`parse_data(port, baudrate, lsl_flag=False, csv_flag=False, gui_flag=False, verbose=False)`
93+
[!IMPORTANT] : Before using the below Applications make sure you are in Application folder.
9494
95-
Parses data from Arduino and manages logging, streaming, and GUI updates.
95+
### GUI
9696
97-
`init_gui()`
97+
- `python gui.py`: Enable the real-time data plotting GUI.
9898
99-
Initializes and displays the GUI with six real-time plots, one for each bio-signal channel.
99+
#### Script Functions
100100
101-
`cleanup()`
101+
`init_gui()`: Initializes and displays the GUI with six real-time plots, one for each bio-signal channel.
102102
103-
Handles all the cleanup tasks.
103+
`update_plots()`: Updates the plot data by pulling new samples from the LSL stream and shifting the existing buffer.
104104
105-
`main()`
105+
### FORCE BALL GAME
106106
107-
Handles command-line argument parsing and initiates data processing.
107+
- `python game.py`: Enable a GUI to play game using EEG Signal.
108108
109-
## Data Logging
109+
#### Script Functions
110110
111-
- **CSV Output**: The script saves the processed data in a CSV file with a timestamped name.
112-
- The CSV file contains the following columns:
113-
- `Counter`: The sample counter from the Arduino.
114-
- `Channel1` to `Channel6`: The data values from each channel.
111+
Here are the important functions from your Pygame script summarized in one line each:
115112
116-
- **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.
113+
`bandpower(data, sf, band, window_sec=None, relative=False)`: Calculates the band power of EEG data in a specified frequency band using the Welch method.
117114
118-
## LSL Streaming
115+
`eeg_data_thread(eeg_queue)`: Continuously retrieves EEG data from an LSL stream and computes power ratios for Player A and Player B.
119116
120-
- **Stream Name**: `BioAmpDataStream`
121-
- **Stream Type**: `EXG`
122-
- **Channel Count**: `6`
123-
- **Sampling Rate**: `UNO-R3 : 250 Hz` , `UNO-R4 : 500 Hz`
124-
- **Data Format**: `float32`
117+
`reset_game()`: Resets the game state and initializes the ball and player forces.
118+
119+
`update_ball_position(force_player1, force_player2)`: Updates the ball's position based on the net force exerted by both players.
120+
121+
`check_win_condition()`: Determines if either player has won based on the ball's position.
122+
123+
### Heart Rate
124+
125+
- `python heartbeat.ecg.py`:Enable a GUI with real-time ECG and heart rate
126+
127+
#### Script Functions
128+
129+
`butter_filter(cutoff, fs, order=4, btype='low')`: Designs a Butterworth filter to remove unwanted frequencies from the ECG signal.
130+
131+
`apply_filter(data, b, a)`: Applies the designed Butterworth filter to the ECG data for noise reduction.
132+
133+
`detect_heartbeats(ecg_data, sampling_rate)`: Detects heartbeats in the ECG signal using peak detection.
134+
135+
`run(self)`: Collects ECG data from the LSL stream, applies filtering, and emits the filtered data for real-time plotting.
136+
137+
`update_plot(self, ecg_data)`: Updates the plot with the latest ECG data and detects heartbeats to display on the GUI.
125138
126-
If GUI is not enabled, you can use an LSL viewer (e.g., BrainVision LSL Viewer) to visualize the streamed data in real-time.
139+
`update_heart_rate(self)`: Calculates and updates the heart rate based on detected R-peaks in the ECG signal.
127140
128141
## Troubleshooting
129142

0 commit comments

Comments
 (0)