Skip to content

Commit 8a2acb3

Browse files
Cleanup EMG tutorial: remove redundant sections and figures
- Remove preprocessing comparison section (envelope visualization is sufficient) - Remove aggregate ERP visualization, keep only all-channels ERP - Remove script sharing section - Delete unused images: emg_erp_lateralization.png, emg_preprocessed_comparison.png
1 parent af8da20 commit 8a2acb3

File tree

3 files changed

+1
-72
lines changed

3 files changed

+1
-72
lines changed
-147 KB
Binary file not shown.
-489 KB
Binary file not shown.

tutorials/misc/EEGLAB_and_EMG_data.md

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,6 @@ bad_chan_idx = find(channel_vars < mean_var - 3*std_var | ...
185185
channel_vars > mean_var + 3*std_var);
186186
```
187187

188-
### Comparison: Original vs Filtered
189-
190-
After filtering, you should see:
191-
- Reduced low-frequency drift
192-
- Cleaner baseline
193-
- Preserved event-related transients
194-
195-
![Preprocessing Comparison](/assets/images/emg_preprocessed_comparison.png)
196-
197188
## Data cleaning with clean_rawdata
198189

199190
**Important:** EMG data can have extremely noisy channels or bad segments. These must be cleaned BEFORE computing the envelope, otherwise artifacts will be preserved in the ERP.
@@ -617,46 +608,20 @@ ERP_k_right = mean(EEG_k.data(right_wristband, :, :), 3);
617608

618609
Use EEGLAB's ERP plotting functions to visualize event-related muscle activation:
619610

620-
**Option 1: Plot ERPs for all channels**
621-
622611
```matlab
623612
% Use EEGLAB menu: Plot > Channel ERPs > In rectangular array
624613
% Or from command line:
625614
figure; pop_plottopo(EEG_a, [1:16], 'EMG-ERP for key "a" (left channels)', ...
626615
0, 'ydir', 1);
627616
```
628617

629-
This displays ERPs for multiple channels in a grid layout, making it easy to compare activation patterns across the electrode array.
630-
631-
**Option 2: Plot average ERP with scalp maps** (less useful for EMG)
632-
633-
```matlab
634-
% For EMG, we typically skip topographic maps since they don't represent brain activity
635-
% Instead, plot channel ERPs directly:
636-
figure; pop_plotdata(EEG_a, 1, [1:8], 'EMG-ERP: Selected Channels');
637-
```
638-
639-
**Option 3: Overlay ERPs for specific channels**
640-
641-
```matlab
642-
% Select representative left-hand channels
643-
left_channels = [1 5 9 13]; % Sample across the array
644-
645-
% Use EEGLAB menu: Plot > Channel ERPs > With scalp maps
646-
% Or plot selected channels:
647-
figure; pop_plotdata(EEG_a, 1, left_channels, 'EMG-ERP: Left Hand Key "a"');
648-
```
649-
650-
![EMG-ERP Lateralization](/assets/images/emg_erp_lateralization.png)
651-
652-
The figure below shows individual channel ERPs, allowing you to see the variability across electrodes on each wristband:
618+
This displays ERPs for all channels, showing the variability across electrodes on each wristband:
653619

654620
![Individual Channel ERPs](/assets/images/emg_all_channels.png)
655621

656622
**Important for EMG:**
657623
- EEGLAB's topoplot (scalp maps) is NOT meaningful for EMG data
658624
- Focus on channel ERPs and time-course plots
659-
- Use `pop_plottopo()` without the topographic map option
660625
- Compare ERPs across channels on the same limb
661626

662627
## Comparing conditions with EEGLAB
@@ -698,42 +663,6 @@ For systematic comparison across multiple subjects or conditions:
698663
- **Timing differences**: Peak latency may differ between hands
699664
- **Amplitude differences**: May vary based on finger position and force
700665

701-
## Complete pipeline script
702-
703-
A complete pipeline for EMG-ERP analysis is available in the [EMG-2-BIDS repository](https://github.com/sccn/EMG-2-BIDS). The pipeline includes:
704-
705-
1. **step1_load_bids_data.m** - Import BIDS-formatted EMG data (includes sanity checks: raw data plots, events, PSD)
706-
2. **step2_preprocess_emg.m** - Bandpass filter (20-250 Hz) and check channel quality
707-
3. **step2a_clean_data.m** - Clean data with ASR and remove bad channels/segments (optional but recommended)
708-
4. **step2b_compute_envelope.m** - Compute linear envelope (CRITICAL: rectify + 20 Hz low-pass)
709-
5. **step3_epoch_and_select.m** - Extract epochs using burst-initial keystrokes (keystrokes after 500ms pause)
710-
6. **step4_compute_erp.m** - Compute and visualize EMG-ERPs with lateralization analysis
711-
712-
Run the complete pipeline:
713-
714-
```matlab
715-
% Add EEGLAB to path
716-
addpath('/path/to/eeglab');
717-
eeglab nogui;
718-
719-
% Navigate to tutorial scripts
720-
cd /path/to/EMG-2-BIDS/tutorial_scripts
721-
722-
% Run all steps
723-
run_all_steps
724-
```
725-
726-
**Critical steps:**
727-
- **step2a_clean_data.m**: Remove artifacts and bad segments (highly recommended for noisy sessions)
728-
- **step2b_compute_envelope.m**: Creates the linear envelope needed for meaningful EMG-ERP analysis
729-
730-
**Recommended workflow:**
731-
```
732-
Load → Sanity Checks → Filter (20-250 Hz) → Clean (ASR) → Envelope (20 Hz) → Epoch (burst-initial) → ERP
733-
```
734-
735-
**Note on epoching**: For rapid typing data (~5 keystrokes/second), standard epochs overlap heavily. Using "burst-initial" keystrokes (those preceded by >500ms pause) provides cleaner baselines and clearer ERPs.
736-
737666
## Key differences: EMG vs EEG
738667

739668
| Aspect | EEG | EMG |

0 commit comments

Comments
 (0)