Project E: The eight-channel EMG armband
Eight electrodes around the forearm, a classifier, and hand gestures recognized from muscle activity. The wristband idea, and the most dependable 'control something with your nervous system' demo there is.
You are skimming: the title, the first figure, and the short version. Switch to Read in the header for the full page, or Deep to open every deep dive.
One EMG channel gave you a servo that follows a clench. Eight channels in a ring around the forearm give you a pattern: each gesture activates the muscles under some electrodes and not others, and a classifier can learn the patterns. Rest, fist, open hand, wrist flexion, wrist extension, pinch: six gestures, recognized in real time from a fabric band. This is what the commercial gesture wristbands do, it is the control principle of multi-grip prosthetic hands, and it is the gentlest possible introduction to the classification you will do on EEG in Phase 3, because EMGElectromyography (EMG)Recording the electrical activity of muscles, hundreds of microvolts to millivolts, much larger than EEG. Glossary entry is large, clean, and cooperative.
A classifier trained on your gestures today gets 95 percent. You put the band on tomorrow, slightly rotated. What happens?
Drops a lot. Rotating the band by one electrode moves every muscle’s signal to a different channel, and a classifier that learned “fist means channels 2 and 3” has no idea. This is the single biggest problem in wearable EMG and it is why every commercial band has a calibration gesture. You will meet the same problem, worse, with EEG in Phase 3.
Parts
| Part | Where | Qty | Approx. |
|---|---|---|---|
| Disposable snap ECG electrodes, pack of 50, and snap leads For EMG and as a quick ground/reference. Snap leads with alligator or 3.5 mm ends. | Amazon | 1 | $12 |
| ESP32 DevKit (or Raspberry Pi Pico) For streaming from the ADS1299 board over USB later. Either board works; pick one ecosystem and learn it. | Adafruit, SparkFun, Amazon | 1 | $8 |
| 3D printing access (campus makerspace) or a Bambu A1 Mini Free on campus after the safety certification. Buying your own is ~$250 and is worth it by Phase 2 if you use it weekly. | Marriott Library or Lassonde makerspace; Bambu Lab if buying | 1 | free |
| Eight dry EMG electrode pads or snap electrodes and a fabric armband | Amazon | 1 | $20 |
| Total (prices drift; treat as a ceiling) | $40 | ||
The band
Eight electrodes evenly spaced around the thickest part of the forearm, a hand’s width below the elbow, held by a stretchy fabric band with the electrodes sewn or snapped in. Bipolar pairs work best (each channel measures between two adjacent electrodes along the arm), but a monopolar arrangement referenced to an electrode on the elbow is simpler and adequate. The bias electrode goes on the wrist bone.
Configure the amplifier for EMG: sample at 1000 per second, gain 12 or so (EMG is bigger than EEG), high-pass at 20 Hz and low-pass at 450 Hz in software.
Features, not raw samples
A classifier does not want a thousand samples a second per channel. It wants a handful of numbers that summarize a short window. The classic EMG features, computed on each channel over a 200 millisecond window: root mean square amplitude, waveform length (the sum of absolute differences between successive samples), zero-crossing count, and slope-sign-change count. Eight channels times four features is a 32-number description of what your hand is doing right now.
Collect, then train, then test honestly
Record each gesture for five seconds, rest for three, repeat five times per gesture. Label the windows. Train a linear discriminant analysisLinear discriminant analysis (LDA)A simple, robust classifier that draws a straight boundary between classes; the workhorse of EEG decoding for two decades. Glossary entry classifier with scikit-learn; it is the standard for EMG, it is fast, and it is very hard to overfit.
Then test it the honest way. Do not shuffle all the windows and hold out 20 percent; that puts windows from the same five-second recording into both training and test and gives you a number you cannot trust. Hold out whole repetitions: train on repetitions one to four, test on five. Then, the real test, take the band off, put it back on, record a fresh set, and test on that. Write down all three numbers. The gap between them is the most important thing you will learn in this project.
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.model_selection import GroupKFold, cross_val_score
clf = LinearDiscriminantAnalysis()
# X: windows × 32 features, y: gesture labels, groups: repetition index
scores = cross_val_score(clf, X, y, groups=groups, cv=GroupKFold(n_splits=5))
print(scores.mean()) # within-session, honest split by repetition
Close the loop
Stream windows, compute features, predict, and show the predicted gesture on screen with a 300 millisecond majority vote to stop it flickering. Then map gestures to something: a robot hand, a game, the volume on your laptop. Latency should be under half a second or it feels wrong.
- Build the band and confirm eight clean channels on the plotter: rest is flat, fist lights up the channels on the inside of the arm.
- Write the feature extractor and check it on a single clench: RMS rises, zero crossings fall.
- Record the six gestures, five repetitions each, with labels.
- Train LDA. Report accuracy three ways: shuffled windows (the wrong way, for comparison), grouped by repetition, and on a fresh session after re-donning the band.
- Run it live with a majority vote. Time the latency.
- Save the confusion matrix and the three accuracies. Note which gestures confuse each other and why (wrist extension and open hand share muscles).
Where this leads
Every idea here reappears in Phase 3 with EEG, where the signals are a thousand times smaller and the cross-session problem is worse. Read classification done honestly next; you have just felt every one of its warnings. In Phase 5 this band becomes a controller for a real user or the front end of a silent speech interface.