Skip to content
Music×EEG
Dataset 1N = 50 · FP1 · 512 Hz · ADC counts

NeuroSky MindWave: one forehead electrode, fifty people

A historical single-channel dataset of unpaced mental arithmetic, re-engineered end-to-end in ten phases: raw audit, boundary-safe filtering, artifact screening, 33-feature extraction, statistics and leak-free machine learning — ending in a function that can score a live headset.

This dataset contains zero music conditions.

Rest (eyes closed) vs Medium vs Hard arithmetic (eyes open) — no audio, no music files, no music condition. It cannot test whether music improves cognition; it is a methodological baseline for single-channel DSP, leak-free validation and the eyelid confound.

50
complete 3-task subjects
9,074
clean 1-s chunks (v2)
33
base features per chunk
73.03%
best Rest vs Math BalAcc (LOSO XGBoost)

Phase 2 · Data integrity

A hardware audit before any modelling

The raw CSV (8,249 rows, SHA-256 verified) was audited row by row. Four anomalies shape every later decision.

Raw recording rows

8,249

across 51 unique participant IDs, 151 subject-task files

Complete 3-task subjects

50

1911019 completed Task 1 only (61 rows) and is excluded

Repeated-measures cohort

N = 48

2104041 and 2311026 lost 100% of Task 3 to detachment

Task order

Fixed

100% of subjects ran Task 1 → Task 2 → Task 3; never counterbalanced

1911017

3× sample-and-hold upsampling

100% of 540 rows flagged; adjacent repetition 67.23% ± 0.35%; nominal row length 1,536 samples; effective rate ≈ 170.67 Hz.

1911018

2× sample-and-hold upsampling

100% of 428 rows flagged; adjacent repetition 50.72% ± 0.44%; nominal row length 1,024 samples; effective rate 256 Hz. Decimated with polyphase anti-aliasing in preprocessing.

Task 3

Sensor detachment only during Hard Math

All 157 poor_signal == 200 rows (1.90%) occurred in Task 3. 2104041 (58/58 rows) and 2311026 (57/57 rows) lost the entire task.

is_correct

Behavioural label is invariant

is_correct is constant within 100% of 151 recordings — a broadcast session outcome, not trial-level performance. Missing in 18.57% of Task 2 and 33.20% of Task 3 rows.

TGAM signal-quality byte (all raw rows)
poor_signal == 07,858 rows (95.26%)
poor_signal 25–107234 rows (2.84%)
poor_signal == 200157 rows (1.90%)

Behaviour can't be predicted from this EEG

Across 32 subjects with paired data, Medium Math accuracy was 87.5% vs Hard81.25% — McNemar χ² = 0.2353, p = 0.6276 (exact binomial p =0.6291). EEG–is_correct correlations: 0 significant (all Holm-adjusted p = 1.000).

Source: reports/full_data_audit.md · §1–4

Phases 4–6 · Signal processing

Zero-phase filtering, 33 features, one ceiling

Pipeline v2

  1. 1

    Stream reconstruction & segmentation

    • · Segment breaks on any poor-signal row (neuro_poor_signal_strength > 0)
    • · Segment breaks on any irregular row length (≠ 512 standard; ≠ 256/512/768 upsampled)
    • · Zero-phase filtering applied strictly within segment boundaries (never across)

    · 1911017 / 1911018 decimated with anti-aliasing to their true bandwidth.

  2. 2

    Bandpass

    4th-order zero-phase Butterworth bandpass, 1.0–40.0 Hz, SOS + sosfiltfilt

  3. 3

    Artifact screening

    Ceiling ptp ≤ 2000 ADC counts; flatline rejection std ≥ 1.

  4. 4

    Feature extraction v2 — 33 base features

    Relative & absolute band powers:
    delta, theta, alpha, beta, gamma, total
    Power ratios:
    theta_beta, alpha_beta, theta_alpha, theta_alpha_beta
    Information metrics:
    spectral entropy, sample entropy
    Waveform morphology:
    Hjorth mobility & complexity, log activity, SEF90, peak alpha frequency
    Time-domain moments:
    std, mean |x|, skewness, kurtosis, zero-crossing rate, line length

Deliberately not applicable

ERP processing: No time-locked trial event markers or stimulus triggers exist in this dataset.

Frontal alpha asymmetry: Single unilateral electrode (FP1); no bilateral homologous channel.

Source: reports/preprocessing_parameters.json

Amplitude-ceiling sensitivity (RF, 5-fold GroupKFold, Rest vs Math)
Ceiling1-s chunksAccBalAccData loss
1,000 counts7,60685.58%68.47%17.5% rejected
1,500 counts8,76780.57%71.32%4.9% rejected
2,000 counts (selected)9,07478.92%71.78%1.6% rejected
3,000 counts9,21978.45%71.40%0.0% rejected

2,000 counts keeps > 98.4% of usable chunks across all 50 subjects and gives the highest balanced accuracy. Lower ceilings discard genuine high-amplitude resting delta and distort the class balance — note how raw accuracy rises at 1,000 counts while balanced accuracy falls.

Source: reports/full_data_audit.md · §5

Phase 7 · Neurophysiology (N = 48 repeated measures)

Theta rises. Alpha only drops when the eyes open.

Subject-by-task means, Wilcoxon signed-rank tests with Holm correction and paired Cohen's dz. Two subjects lost all Hard-Math data to detachment, leaving N = 48 for three-condition tests.

Frontal midline theta

dz = 1.388

rel_theta 0.182 → 0.305 from Rest to Medium Math (Δ = +0.123, W = 39.0, Holm p = 4.85 × 10⁻¹⁰). theta_beta 1.385 → 7.256 (dz = 0.953).

Eyes-closed alpha confound

Rest → Medium

−0.1886

dz = -1.378

Medium → Hard

−0.0029

p = 0.2553 (n.s.)

Relative alpha falls 51.0% at eye opening, then changes only 1.6% between difficulty levels (Holm p = 0.4702). This negative control isolates the alpha drop to eyelid state.

Hjorth complexity scales

1.544 → 1.945 → 2.204

Rest → Medium dz = 0.691; Medium → Hard dz = 0.627 (Holm p = 2.54 × 10⁻⁵) — one of the few features that keeps rising when eyes are open in both conditions.

Friedman omnibus tests across Rest / Medium / Hard (N = 48, Holm across 12 features) — selected rows
FeatureRestMediumHardχ²(2)Holm pKendall W
theta_alpha0.9652.4532.80763.8751.62 × 10⁻¹³0.665
theta_beta1.3857.2568.20463.1672.11 × 10⁻¹³0.658
hjorth_complexity1.5441.9452.20455.5428.70 × 10⁻¹²0.579
rel_theta0.1820.3050.33054.8759.71 × 10⁻¹²0.572
rel_alpha0.3700.1810.17848.7921.78 × 10⁻¹⁰0.508
alpha_beta2.6902.2092.4240.5421.00000.006

Source: reports/statistical_analysis.md · §2–4

Phase 8 · Machine learning (57 configurations)

Leak-free benchmarks: broad state yes, fine load no

Every generalised model is validated with participant-grouped 5-fold GroupKFold or leave-one-subject-out (LOSO). 95% CIs: 1,000 bootstrap resamples of per-subject balanced accuracy.

Rest vs Math · 9,074 chunks · majority baseline 67.49%
ModelCVAccBalAcc95% CI
Random Forest (300 trees)5-Fold GroupKFold78.92%71.78%70.52–78.07
Logistic Regression5-Fold GroupKFold78.64%71.69%69.90–77.50
Linear SVM5-Fold GroupKFold78.70%71.51%69.55–77.22
XGBoost (100 trees)5-Fold GroupKFold78.14%71.27%69.37–77.32
Random Forest (300 trees)LOSO (50 folds)79.53%72.34%71.27–78.70
Logistic RegressionLOSO (50 folds)79.46%72.33%70.68–78.08
Linear SVMLOSO (50 folds)79.59%72.19%70.40–77.85
XGBoost (100 trees)LOSO (50 folds)80.06%73.03%71.66–79.24
Medium vs Hard · 6,124 chunks · majority baseline 56.99%
ModelCVAccBalAcc95% CI
Random Forest5-Fold GroupKFold55.68%52.98%50.06–58.01
Logistic Regression5-Fold GroupKFold55.26%52.67%51.99–59.26
Linear SVM5-Fold GroupKFold55.47%52.73%51.95–59.17
XGBoost5-Fold GroupKFold55.08%52.28%50.76–58.99
Random ForestLOSO (50 folds)56.01%53.29%50.46–57.92
Logistic RegressionLOSO (50 folds)54.80%52.01%51.43–58.51
Linear SVMLOSO (50 folds)55.06%52.09%51.57–58.83
XGBoostLOSO (50 folds)55.21%52.14%50.79–58.70

Every Medium-vs-Hard model's raw accuracy is below the 56.99% majority baseline — the classes are inseparable from 1-s single-channel EEG.

Source: reports/modeling_results.md · Exp. 8.1

Exp. 8.4 · Alpha ablation

Remove alpha, keep the signal

SubsetnBalAccΔ
All features3371.78%Reference
Without alpha features2672.16%+0.38 pp
Band power only1670.83%−0.95 pp
Ratios only468.93%−2.85 pp
Hjorth & complexity only561.32%−10.46 pp
Time-domain only655.28%−16.50 pp

Removed: rel_alpha, theta_alpha, alpha_beta, theta_alpha_beta, abs_alpha, log_alpha, peak_alpha_freq.

Exp. 8.8 · Leakage demonstration

+11.33 pp of fake accuracy

Leaked vs honest cross-validation, balanced accuracy
ConditionValue (%)Spread
RF · random KFold83.12—
RF · GroupKFold71.78—
LogReg · random KFold76.37—
LogReg · GroupKFold71.69—
50% chanceerror bar = reported SD or 95% CI

Random chunk-level splitting puts temporally autocorrelated windows from the same person in train and test, so the model memorises subject morphology. RF inflates by +11.33 pp; LogReg by +4.68 pp.

Exp. 8.6 · Permutation test

p = 0.0050

Observed BalAcc
71.31%
Null mean ± SD
50.84% ± 0.39
Null 95th pct.
51.45%
Permutations
200

Within-subject label shuffles; empirical p = (0 + 1) / (200 + 1).

Exp. 8.5 · Personal calibration

Needs k ≥ 40 s per task

k (s)SubjectsGenericCalibratedΔ pp
05071.24%71.24%+0.00
55071.20%57.59%−13.61
104771.89%63.15%−8.73
204171.18%68.81%−2.37
403763.64%66.02%+2.39

First k contiguous chunks calibrate; evaluation strictly on chunk index ≥ k, so the evaluated set shrinks as k grows.

Source: reports/ml_results.csv

Curated figures

MindWave diagnostics

Click any figure for the full-resolution viewer (← / → to step, Esc to close). All 11 MindWave figures →

MindWaveSignal Processing & Quality

Butterworth 1–40 Hz filter response

Magnitude (dB) and phase across 0–60 Hz for the 4th-order zero-phase SOS bandpass. −3 dB cut-offs at 1 Hz and 40 Hz; DC drift suppressed by > 40 dB at 0.2 Hz and mains harmonics by > 30 dB at 50/60 Hz. Identical relative bandwidth at 512 Hz and the decimated 256 Hz rate.

MindWaveNeurophysiology & Behavior

Mean power spectrum per task

Grand-average PSDs (thick) over individual spectra (thin) from 1–45 Hz. Rest shows an 8–12 Hz alpha peak from eyes-closed idling; both math tasks show alpha suppression and elevated theta/beta power.

MindWaveNeurophysiology & Behavior

The eyes-closed alpha confound

Panel A: relative alpha collapses from eyes-closed Rest to eyes-open Medium Math (Δ = −0.1886, d_z = −1.378) and then flatlines between Medium and Hard (Δ = −0.0029, p = 0.2553). Panel B: non-alpha markers (rel_theta, hjorth_complexity) rise progressively with demand.

MindWaveMachine Learning & Ablation

Data-leakage demonstration

Random chunk-level KFold (leaked) vs subject-grouped GroupKFold (honest). Leakage inflates RF balanced accuracy from 71.78% to 83.12% (+11.33 pp) and LogReg from 71.69% to 76.37% (+4.68 pp).

MindWaveMachine Learning & Ablation

Within-subject permutation null

200 within-subject label permutations: null mean 0.5084 (SD 0.0039, 95th percentile 0.5145) vs observed 0.7131. Empirical p = 1/201 = 0.0050.

Phases 9–10 · Headset pilot bridge

From benchmark to a live headset

The trained pipeline is serialised and exposed as one function, with five gatekeeper checks before any prediction is trusted.

src/predict.pyPython
def predict_from_raw(raw_512_samples, fs=512) -> dict:
    # raw_512_samples: 512 raw integer ADC counts
    # (1 s from the MindWave; do NOT convert to µV)
    ...
    return {
        'high_load_probability': float | None,
        'prediction': 0 | 1 | None,  # 0 Rest, 1 High load
        'quality_ok': bool,
        'quality_reason': str,
        'features': dict | None,
    }

Inside predict_from_raw(raw_512_samples, fs=512)

  1. 1. Validation — length 512, finite, std ≥ 1.0, ptp ≤ 2000; otherwise quality_ok = False
  2. 2. Bandpass — zero-phase 4th-order Butterworth 1–40 Hz (sosfiltfilt)
  3. 3. Features — the same 33 base features as the training matrix (Welch PSD, ratios, entropy, Hjorth, moments)
  4. 4. Inference — Random Forest predict_proba → P(high load) ∈ [0, 1] plus a signal-quality flag

Model artifact: models/best_pipeline.joblib (git-ignored)

  1. 1

    Buffer length

    exactly 512 samples

    else DISCARD
  2. 2

    Contact byte

    poor_signal == 0

    else DISCARD
  3. 3

    Repeated samples

    dup_fraction ≤ 0.20

    else BUFFER UNDERRUN
  4. 4

    Flatline

    std ≥ 1.0 and ptp ≥ 2.0 counts

    else SENSOR DISCONNECT
  5. 5

    Rail saturation

    ptp ≤ 2000 counts

    else GROSS MOVEMENT

Units warning

Pass raw integer ADC counts. The model was trained on unscaled counts; converting to µV shrinks band powers by ≈ 0.0484× and causes severe misclassification.

What the pilot can and can't tell you

It estimates broad rest-vs-task state. It cannot grade task difficulty (Medium vs Hard ≈ chance) and — on its own — says nothing about music.

Source: docs/pilot_integration.md