|
1 | 1 | # Chords - Python
|
2 | 2 |
|
3 |
| -Chords Python script is 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. |
| 3 | +Chords Python script is designed to interface with an Arduino-based bio-potential amplifier, 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. |
4 | 4 |
|
5 | 5 | > [!NOTE]
|
6 | 6 | > Flash Arduino code to your hardware from [Chords Arduino Firmware](https://github.com/upsidedownlabs/Chords-Arduino-Firmware) to use this python tool.
|
7 | 7 |
|
8 | 8 | ## Features
|
9 | 9 |
|
10 | 10 | - **Automatic Arduino Detection:** Automatically detects connected Arduino devices via serial ports.
|
11 |
| -- **Data Reading:** Read ModularEEG P2 format data packets from the Arduino's serial port. |
| 11 | +- **Data Reading:** Read data packets from the Arduino's serial port. |
12 | 12 | - **CSV Logging:** Optionally logs data to a CSV file.
|
13 | 13 | - **LSL Streaming:** Optionally streams data to an LSL outlet for integration with other software.
|
14 | 14 | - **Verbose Output:** Provides detailed statistics and error reporting, including sampling rate and drift.
|
15 | 15 | - **GUI:** Live plotting of six channels using a PyQt-based GUI.
|
| 16 | +- **Invert:** Optionally Invert the signal before streaming LSL and logging |
16 | 17 | - **Timer:** Record data for a set time period in seconds.
|
17 | 18 |
|
18 | 19 | ## Requirements
|
@@ -101,61 +102,26 @@ To use the script, run it from the command line with various options:
|
101 | 102 |
|
102 | 103 | - `python gui.py`: Enable the real-time data plotting GUI.
|
103 | 104 |
|
104 |
| -#### Script Functions |
105 |
| -
|
106 |
| -`init_gui()`: Initializes and displays the GUI with six real-time plots, one for each bio-signal channel. |
107 |
| -
|
108 |
| -`update_plots()`: Updates the plot data by pulling new samples from the LSL stream and shifting the existing buffer. |
109 |
| -
|
110 | 105 | ### FORCE BALL GAME
|
111 | 106 |
|
112 | 107 | - `python game.py`: Enable a GUI to play game using EEG Signal.
|
113 | 108 |
|
114 |
| -#### Script Functions |
115 |
| -
|
116 |
| -`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. |
117 |
| -
|
118 |
| -`eeg_data_thread(eeg_queue)`: Continuously retrieves EEG data from an LSL stream and computes power ratios for Player A and Player B. |
119 |
| -
|
120 |
| -`reset_game()`: Resets the game state and initializes the ball and player forces. |
121 |
| -
|
122 |
| -`update_ball_position(force_player1, force_player2)`: Updates the ball's position based on the net force exerted by both players. |
123 |
| -
|
124 |
| -`check_win_condition()`: Determines if either player has won based on the ball's position. |
125 |
| -
|
126 | 109 | ### HEART RATE
|
127 | 110 |
|
128 | 111 | - `python heartbeat.ecg.py`:Enable a GUI with real-time ECG and heart rate.
|
129 | 112 |
|
130 |
| -#### Script Functions |
131 |
| -
|
132 |
| -`butter_filter(cutoff, fs, order=4, btype='low')`: Designs a Butterworth filter to remove unwanted frequencies from the ECG signal. |
133 |
| -
|
134 |
| -`apply_filter(data, b, a)`: Applies the designed Butterworth filter to the ECG data for noise reduction. |
135 |
| -
|
136 |
| -`detect_heartbeats(ecg_data, sampling_rate)`: Detects heartbeats in the ECG signal using peak detection. |
137 |
| -
|
138 |
| -`run(self)`: Collects ECG data from the LSL stream, applies filtering, and emits the filtered data for real-time plotting. |
139 |
| -
|
140 |
| -`update_plot(self, ecg_data)`: Updates the plot with the latest ECG data and detects heartbeats to display on the GUI. |
141 |
| -
|
142 |
| -`update_heart_rate(self)`: Calculates and updates the heart rate based on detected R-peaks in the ECG signal. |
143 |
| -
|
144 | 113 | ### EMG ENVELOPE
|
145 | 114 |
|
146 |
| -- `python emgenvelope.py` :Enable a GUI with real-time EMG & its Envelope. |
147 |
| -
|
148 |
| -#### Script Functions |
149 |
| -
|
150 |
| - `update_plot` : Updates the plot with latest Filtered EMG Data and its Envelope. |
| 115 | +- `python emgenvelope.py`: Enable a GUI with real-time EMG & its Envelope. |
151 | 116 |
|
152 | 117 | ### EOG
|
153 | 118 |
|
154 |
| -- `python eog.py` :Enable a GUI with real-time EOG. |
| 119 | +- `python eog.py`: Enable a GUI with real-time EOG that detects the blinks and mark them with red dot. |
| 120 | +
|
| 121 | +### EEG |
155 | 122 |
|
156 |
| -#### Script Functions |
| 123 | +- `python ffteeg.py`: Enable a GUI with real-time EEG data with its FFT. |
157 | 124 |
|
158 |
| - `update_plot` : Updates the plot with latest Filtered EOG Data. |
159 | 125 |
|
160 | 126 | ## Troubleshooting
|
161 | 127 |
|
|
0 commit comments