TL;DR: We wore a consumer Bluetooth EEG headset through 65 recorded sessions, labelled each second as calm, neutral or stressed, and trained classifiers on it. Tree ensembles came out on top (Extra Trees at about 0.85 weighted F1), but the plots below show why that number needs care: the class differences in the raw signal are small, and the strongest effects come from what the person is doing, not from how they feel.
The setup
The headset is a Toshiba MindTune (px3809N-1ETC). It streams NeuroSky ThinkGear packets over a Bluetooth serial port, about once a second: a signal-quality value, two 0-100 “eSense” scores called Attention and Meditation, and the power in eight frequency bands (delta, theta, low and high alpha, low and high beta, low and mid gamma).
I wrote a Tkinter collector that records the stream while an annotator presses hotkeys. One set of keys marks the participant’s emotion (calm, stressed, delighted, angry, unknown) and another marks events as they happen: speaking, a question being asked, a Q&A stretch, being scolded, being praised, and a tech issue. Every row gets the current emotion and the events that are active, and each session is saved with its markers.
For training, the emotions were folded into three classes: stressed if the annotator marked stressed, calm if they marked calm, and neutral for everything else. The merged dataset has 11,945 rows from 65 sessions.
What the data looks like
The classes are lopsided. Stressed rows (6,186) outnumber calm ones (2,097) by about three to one, with neutral in between (3,662). So the training split is stratified, and models are compared on weighted F1 rather than plain accuracy, since a model that always answered “stressed” would already be right about half the time.
The raw band powers span three to four orders of magnitude, and on a log scale each one looks roughly bell-shaped, so the raw values are close to log-normal. Delta is by far the strongest band (around 106, and skewed to the left), and the faster bands sit two orders of magnitude lower. Raw values like these are hard to compare across people and sessions, so the features use each band’s share of the total power instead.
This is the most humbling chart in the project. As shares, delta takes about 67% of the power and theta about 17%, and everything else is under 5%. The calm, neutral and stressed bars are almost the same height in every band. On average, a stressed second looks very much like a calm one.
The radar chart shows the same kind of class means with each band’s axis stretched between the lowest and the highest class, so the tiny gaps from the bar chart become visible. Read this way, calm has the most delta and the least of everything else, neutral leads on alpha, beta and low gamma, and stressed leads on theta and mid gamma. The shapes look very different, but only because of the rescaling. The bar chart above shows how small the real differences are.
The correlation matrix shows three things:
- Delta pulls against everything else (r between -0.50 and -0.71). The features are shares of a total, so when delta’s share goes up, every other band’s share has to go down.
- Neighbouring fast bands move together. High beta and low gamma correlate at 0.61, and low and high beta at 0.53. Theta/beta and the slow/fast ratio correlate at 0.70, which makes sense because both have slow activity on top and fast activity underneath.
- The label row is almost empty. No single feature correlates with the class by more than 0.09. Whatever separates calm from stressed in this data is not a simple straight-line relationship with any one band, which is part of why the tree models win later.
Attention and Meditation
The eSense scores are centred near 50 (means 49.7 and 50.2), with a spike at exactly 0. The headset reports 0 when it loses contact, so those rows are dropouts, not very relaxed or very distracted people. Across individual samples, attention and meditation are only weakly related (r = 0.23), and the per-session averages (box plots) put meditation slightly above attention. The correlation matrix above gives a much higher 0.72 for the same pair. That comes from a different notebook with different filtering, and it shows how much the choice of which rows count as “good signal” can move a statistic like this.
Split by class, the density curves lie almost on top of each other. There is a faint trend in the means: going from calm to stressed, attention rises slightly (about 47 to 50) and meditation drops slightly (about 53 to 51). It points the expected way, but it is far too weak to classify with on its own.
Events: what the person is doing
Q&A, speaking and questions each cover around 2,000 seconds. Being scolded (594) and tech issues (322) are rarer, and praise was marked for only 26 seconds in the whole dataset. Keep that 26 in mind for the next chart.
This heatmap shows how each band’s power changes, in percent, while an event is happening compared with when it isn’t. A few rows stand out:
- Praised has the largest values on the board: low gamma +106.5%, high beta +82.6%, high alpha +40.4%. They come from just 26 seconds, though, so this is a strong hint rather than a finding.
- Speaking raises low gamma by 35.5%. That is very likely partly muscle, not mind. A sensor on the forehead also picks up jaw and face muscle activity, and that shows up as high-frequency power.
- Q&A lowers every band (low alpha -20.7%, theta -14.9%).
- Tech issues raise almost everything: theta +16.6%, high beta +19.6%, mid gamma +19.0%.
The same comparison on the higher-level signals gives each event its own shape. Praise sends meditation up sharply and pulls theta/beta down. Tech issues push theta/beta and alpha/beta up the most. Attention barely moves for any event, staying within a few percent of its baseline.
This chart turns the question around: given the label, what was going on? Stressed seconds mostly happen during Q&A (56.6% of them) and while questions are being asked (48.4%). Scolding (13.4%) and tech issues (13.7%) are also clearly more common in stressed seconds than in calm ones (5.0% and 0.7%). Calm seconds are mostly speaking (51.6%), so presenting your own material seems to feel fine, and being questioned on it is when stress shows up. That fits everyday experience, and it is also the main risk in the data: event markers predict the label well, and a model that has them can learn “Q&A means stressed” without reading the brain at all.
Whole sessions
A single session shows what the averages hide. In session 0091, the eSense scores hold flat for long stretches and drop to 0 between roughly 260 and 510 seconds. That is the headset losing contact, not the person. Delta’s relative power swings between about 0.2 and 0.9 from one second to the next, while the fast bands stay low with the odd spike. The bottom panel lines the label up with the events: stressed at the start while a tech issue was active, calm through the middle, then stressed again from about 400 seconds, when speaking, questions and Q&A begin.
Session 67 kept good contact the whole way through. Attention sits mostly above meditation. The log power in theta, alpha and beta rises and falls together, so much of the second-to-second change is the overall signal getting louder or quieter (movement, contact) rather than one band changing on its own. That is the reason for using band shares and ratios. The event track shows the structure of the session: speaking early on, then questions and Q&A from about two minutes to the end, with a long scolded stretch between about 280 and 480 seconds.
The classifier
Each row’s features are the band shares, three ratios (theta/beta, alpha/beta, and slow/fast), the eSense scores, and the mean and standard deviation of the last five samples. The rolling window smooths out one-second blips, so a single cough doesn’t flip the prediction.
The models fall into clear groups. Tree ensembles lead: Extra Trees at about 0.85 and Random Forest at about 0.82, followed by a single decision tree, an MLP and k-nearest neighbours, all between 0.75 and 0.78. The linear models (logistic regression, LDA, linear SVC, SGD, ridge) are bunched around 0.61-0.63, and Gaussian Naive Bayes trails at about 0.47. That gap is what the correlation matrix predicted: no single feature separates the classes, but combinations and thresholds do.
I don’t take 0.85 at face value, though. The split is a random 80/20 over individual rows, so neighbouring seconds of the same session, which share most of a five-second window, end up in both the training and the test set. The event markers and the time into the session were also part of the features in this run. Both make the score optimistic. The live app drops the markers, because nobody presses event keys during a real reading. The honest next test is to hold out whole sessions, or whole people.
The live app
The end result is a small Tkinter app. It reads the headset over Bluetooth, buffers five packets, builds the same features and shows the predicted state in large coloured text. It uses a LightGBM model trained without the event markers. The code is on the classifier branch.
What I’d take away
- Consumer EEG works, but it is noisy. Dropouts, contact problems and muscle activity are a large part of the signal, so check signal quality before trusting any number.
- Context is a strong signal, and a trap. The events explain the labels better than the brainwaves do, so any evaluation has to make sure the model isn’t just learning the situation.
- Validate across sessions. A random row split flatters a model trained on time series.
The collector, notebooks and classifier are in mindtune-brainwave.