↑↓ move↵ open[] previous / next lesson? all shortcuts
Appearance
Theme
Type size
Reading

Focus mode hides the sidebars. Press f to toggle it anywhere.

Keyboard shortcuts
/
Search
[ ]
Previous / next lesson
t
Jump to the table of contents
r
Review queue
f
Focus mode
?
This panel
ProjectTwo weekendsAbout $35 beyond the amplifier boardTier 2

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.

AssumesProject C: Muscle to motionProject A: The ADS1299 boardSpineAnalog / mixed-signal hardwareDecoding / signal processing / ML
On this pageTwo weekends
  1. The band
  2. Features, not raw samples
  3. Collect, then train, then test honestly
  4. Close the loop
  5. Where this leads

One 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 and not others, and a 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 in Phase 3, because is large, clean, and cooperative.

Predict before you look

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 moves every muscle’s signal to a different channel, and a that learned “fist means channels 2 and 3” has no idea. This is the single biggest problem in wearable and it is why every commercial band has a gesture. You will meet the same problem, worse, with in Phase 3.

Parts

PartWhereQtyApprox.
Disposable snap ECG electrodes, bag of 50
3M Red Dot, $11.40 for fifty. Clip the alligator leads onto the snap studs rather than buying leads; a set of four 3.5 mm snap leads is $9.99 if you want them tidy.
Amazon1$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.
Amazon, Adafruit, SparkFun1$9
3D printing access (campus makerspace) or a Bambu A1 mini
Free on campus after the safety certification, which is the right answer for almost everyone. Buying your own is $299 and is worth it by Phase 2 only if you print weekly.
Marriott Library or Lassonde makerspace; Bambu Lab if buying1free
Eight reusable snap electrode pads and a fabric armband
$7.99 for twenty reusable TENS pads with 3.5 mm snaps, plus elastic and hook-and-loop for the band. The reusable pads lose adhesion after a few dozen applications; disposable ECG electrodes give cleaner contact per session.
Amazon1$12
Total (prices drift; treat as a ceiling)$33

The band

Figure 1. Eight channels around the widest part of the forearm, a hand's width below the elbow. Each gesture lights up a different subset, which is the entire idea; the classifier is only reading which lights are on.

Eight evenly spaced around the thickest part of the forearm, a hand’s width below the elbow, held by a stretchy fabric band with the sewn or snapped in. Bipolar pairs work best (each channel measures between two adjacent along the arm), but a monopolar arrangement referenced to an on the elbow is simpler and adequate. The bias goes on the wrist bone.

Configure the amplifier for : sample at 1000 per second, 12 or so ( is bigger than ), high-pass at 20 Hz and low-pass at 450 Hz in software.

Features, not raw samples

A does not want a thousand samples a second per channel. It wants a handful of numbers that summarize a short window. The classic 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 with scikit-learn; it is the standard for , 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.

  1. 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.
  2. Write the feature extractor and check it on a single clench: RMS rises, zero crossings fall.
  3. Record the six gestures, five repetitions each, with labels.
  4. Train . Report accuracy three ways: shuffled windows (the wrong way, for comparison), grouped by repetition, and on a fresh session after re-donning the band.
  5. Run it live with a majority vote. Time the latency.
  6. 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 , 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.

Recall
Why report three accuracies for the gesture classifier?
Shuffled windows leak data between train and test and overstate accuracy; grouping by repetition is honest within a session; a fresh session after re-donning the band is the real-world number. The gaps between them are the lesson.
Recall
Why do EMG classifiers use features over windows rather than raw samples?
EMG's information is in amplitude and frequency content over tens to hundreds of milliseconds, not in individual samples. Features like RMS, waveform length, and zero crossings capture this compactly and make simple classifiers work.
Recall
What is the biggest practical problem in wearable EMG and how do commercial bands handle it?
Electrode shift between sessions (band rotation) changes which channel sees which muscle. Commercial bands run a short calibration gesture at each donning.