Back to research
Independent collaboration with a Meta AI researcher · 2026

Can brainwaves explain a brain scan?

EEG hears the brain's electricity a thousand times a second. fMRI watches its blood, slowly. I built a pipeline to test whether one could explain the other, with one rule above everything else: it had to be able to tell me no.

It did. Here is why.

120
clean fMRI snapshots
6
possible timings, none provable
4
cleaning strategies, all blocked
0
models fitted, on purpose
Live toy EEG, 1 channel recording

Eyes closed, inside the magnet. The idle rhythm is loud, and the heartbeat is still louder.

The 30-second version
Dotted words are tappable.
1The question

Does the brain's explain second-to-second changes in the , beyond what "eyes open or closed" already explains?

2What worked

The fMRI. 120 clean snapshots, almost no head movement, good signal quality.

3What broke

Two separate things. Nobody recorded which 5 of 125 snapshots were thrown away, so the timing has six possible answers. And nothing could scrub out the without mangling the brain signal underneath.

4So

I stopped before fitting a single model. That is a bounded negative result, not a verdict on the data, and the tooling carries over to the next dataset.

01Background

Two cameras on one brain.

EEG and fMRI are good at opposite things. Record them at the same time and you can ask which parts of the brain follow a mental state, like relaxing or closing your eyes, from one second to the next. It has to be simultaneous, because that state never plays out the same way twice.
One burst of brain activity, two cameras
EEG: 1,000 readings a secondfMRI: one snapshot every 2 sneurons fireblood peaks, about 5 s later0s2s4s6s8s10s12s14s16s

The dots are all fMRI ever sees. To compare the two, the EEG has to be delayed and smeared by the same curve, then read off at the exact moment of each dot. That last step needs the dots' timestamps. Hold that thought.

EEGelectricity, from the scalp
Measures
Tiny voltages when big groups of neurons fire in sync
Speed
1,000 readings a second in this dataset
Weak at
Where. And inside an MRI it picks up huge noise from the scanner and the heart
Here
32 electrodes plus one heart (ECG) channel
fMRIblood, from inside
Measures
How oxygenated the blood is, cube by cube
Speed
One snapshot every 2 s. The response peaks about 5 s after the activity
Strong at
Where, down to 4 mm cubes
Here
A 64 x 64 x 35 grid, 120 snapshots
02What I was actually testing

Does EEG add anything the eyes don't already tell you?

This was an encoding question: how much of the blood signal can EEG describe? Not a causal one. The trick is the word "beyond." The gets louder when eyes close, so a model that already knows when the eyes are closed might gain nothing from EEG at all. Build it up one layer at a time:
The blood-oxygen signal, wobble by wobble100%
?
unexplained

Slice sizes are made up to show the idea. The real ones were never computed.

Add the idle rhythm, delayed to match the blood response. The whole project is the size of this last slice, measured on data the model never trained on.

= (Model 2) minus (Model 1), scored on stretches of time the model never saw. Near zero would read as "no evidence EEG adds anything," which is not the same as "EEG and blood are unrelated."

Before anything new

Weigh a known 1 kg first.

You don't trust a scale until it reads a known weight correctly. My known weight: when the idle rhythm rises, blood oxygen in visual cortex tends to fall (Goldman et al., 2002; Laufs et al., 2003). That was the , called Q0. If the pipeline couldn't find it, nothing it said about theta or beta would count.

idle rhythmvisual cortex blood signal
The expected pattern, sketched
Held-out testing

Five contiguous test blocks, with 3 snapshots (6 s) dropped from training on each side, so the model never trains on the immediate neighbours of what it is tested on. That is .

A fair chance baseline

Slide the EEG in time against the blood signal, 200 times, and rerun. That breaks the real alignment but keeps the EEG's own smoothness, which gives an honest .

Shrinkage

Ridge regression, a linear model with a penalty that stops it overfitting correlated inputs. The penalty is picked from 0.1, 1, 10, or 100 using training data only.

All of this was built and tested on simulated data. None of it was ever pointed at real EEG and blood data, for reasons chapters 04 and 05 explain.

03How not to fool yourself

The rules I set before touching the data.

An EEG-fMRI analysis has dozens of knobs. Set any of them by checking which setting gives the strongest result and you will find a result whether or not one exists. Statisticians call it , or the garden of forking paths. My priority was a valid pipeline over impressive numbers, so I wrote the rules before touching the data.
  1. 01
    Stay blind

    While deciding how to process EEG and line up timing: no blood values, no eyes-open/closed effect sizes, no model results.

  2. 02
    Freeze before looking

    Every protocol and pass/fail line went into version control before any result existed. None was loosened afterwards.

  3. 03
    Calibrate somewhere else

    Methods were tuned on separate recordings, never on the one that would be analysed.

  4. 04
    Use known answers

    Where possible, test on clean data with real noise added, so the right output is known.

  5. 05
    Lock the door

    Code that touches the target checks a hashed authorization file. If calibration failed, it refuses to run.

  6. 06
    "Can't tell" is an answer

    A stage can return a bounded set of possibilities instead of forcing one.

  7. 07
    Raw data never changes

    Input files are fingerprinted (SHA-256) before and after every stage.

  8. 08
    Negatives stay negative

    Null results get reported as null. No reframing.

04Timing

The scan was fine. Its clock was not.

Good news first: the fMRI half worked. I realigned every snapshot to correct for tiny head movements (FSL's MCFLIRT) and every quality check passed.
120 / 120
snapshots survived realignment
0.113 mm
mean (max 0.373, none over 0.5)
74.7
median
20,536
voxels in the brain mask, one connected piece
identical
raw file fingerprints, before and after

Then the problem.

Normally the scanner stamps a marker into the EEG file for every , and lining the two up is trivial. This dataset stored zero markers. Zero trigger channels. No events file.

So I rebuilt the clock from the itself. It shows up as a sharp block from 96.2 to 346.4 s, pulsing every 2.0 s, with the 35 Hz slice rhythm about 2,750 times stronger inside the block than outside. Counting the pulses gave 125 complete snapshots. The saved file has 120.

Scanners usually throw away a few at the start. But they could be at the start, the end, or split between both, and nothing in the files says which. Try it:

Snapshots the scanner took
125 taken. 120 saved. Which 5 are missing?
saved dropped
95.76 sscanner running, 2 s per snapshot345.76 s
Dropped at the start
Split
0 at start, 5 at end
First saved snapshot starts
95.76 s
Off by, if the truth is 0
nothing
Nobody knows which five. Not the EEG file, not the 20 MRI headers (all say 120 with no field), not the dataset paper. Every option is physically possible and each shifts the whole alignment by another 2 s.
Stage 3C: last-ditch rescue

Four places the answer could have been hiding.

None of them involve brain signals, on purpose. I also tried spotting the save boundary as a step in per-snapshot buzz strength. There was no step.

✕
Raw minus cleaned EEG

Subtracting shows where scanner-buzz correction was applied. It covered 121 snapshot-lengths in two pieces (3 + 118), not 120 in a row, because the correction uses a five-snapshot moving template with start-up and end effects.

✕
File metadata

The EEG files have no events or correction log. All 20 MRI headers say 120 snapshots and have no warm-up field.

✕
The documentation

The dataset and its paper say hardware markers were used during correction. Not whether they skipped the warm-up snapshots.

✕
Other subjects

The same 3 + 118 split shows up across people. So it is a quirk of the correction workflow, not a marker of what was saved.

05EEG cleaning

Every heartbeat is louder than the brain.

The dataset came with the scanner buzz already removed. It did not come with the removed, and that is where three weeks went.
01
The heart beats

Each beat nudges the head and electrodes a tiny amount and pushes a pulse of blood through the scalp.

02
Inside a magnet

Moving a conductor through a strong magnetic field generates a voltage. Physics, not biology.

03
A blip every beat

Bigger than the brain signal, locked to the pulse, and overlapping the exact frequencies alpha lives in.

Here is the trap. Turn the dial.

The fair way to judge a cleaner is the : take clean EEG recorded outside the scanner, add real heartbeat noise, clean it, and see if you get the original back. Scrub too gently and the heartbeat stays. Scrub too hard and you carve into the brain signal.

The planted-signal test, as a toyToy model. Not the project's data.
What I planted (clean idle rhythm)
After adding real-style heartbeat noise
What the cleaner hands back (planted signal ghosted behind)
gentlescorched earth
Heartbeat removed45%fail
need 90%
Match to what I planted0.61fail
need 0.80

Too timid. Most of the heartbeat is still in there, drowning the rhythm.

Removing the noise is not the same as getting the signal back.
By the usual metric, my round-two hybrids looked excellent: about 96% of the heartbeat gone. Only the planted-signal test showed the brain signal underneath coming out distorted. Plenty of studies report the first number alone.

Four attempts, each narrower than the last.

Every one had its pass/fail lines frozen before it ran. Three channels were flagged as bad along the way (two of them at the back of the head, right where alpha lives) and about 14% of samples were masked out.

The idea

Find every heartbeat from the ECG channel (534 of them; two detectors agreed on 99.6% within 40 ms). Then run two textbook cleaners side by side. One unmixes the 32 channels and throws out the 3 sources that look like heartbeat. The other learns the 4 main shapes of the heartbeat blip and subtracts a fitted copy at every beat.

What happened

The unmixer cleaned too little. The template cleaned so hard it removed 57% of everything.

The numbers, against gates set in advance
CheckUnmixer (ICA)Template (OBS4)
Heartbeat blip reduced (need 25% or more)23.4% fail98.7% pass
Link to the ECG reduced11.9% warn86.0% pass
Total signal removed (must stay under 40%)19.2% pass57.2% fail
Alpha peak shifted0.5 Hz pass0.5 Hz pass
Overallfailfail

ICA missed its floor by 1.6 points. Its confidence interval was positive and most channels improved. The floor stayed at 25%.

06Results

Where every stage landed.

Every stage ends with a status from a fixed vocabulary, written to a file.
Stage 0-2
Foundation
859 files counted and fingerprinted. The modeling math checked out on fake data where the answer is known.
Done and checked
Stage 2.5
Pairing and sync
Matched the eyes-open/closed EEG to its fMRI run. Found the scanner running from 96.2 to 346.4 s. Exact start still provisional.
Mostly done
Stage 3 / 3A
fMRI cleanup
Every quality gate passed. Mean head movement 0.113 mm.
Done and checked
Stage 3B
Timing
125 snapshots taken, 120 saved. Six possible alignments kept.
Declined to guess
Stage 3C
Timing rescue
No file, header, document, or other subject says which 120 were kept.
Unanswerable
Stage 4A
Cleaning, round 1
ICA cleaned too little. OBS4 removed too much.
Blocked by a gate
Stage 4A-R
Cleaning, round 2
Heartbeat gone. Planted signal not recovered.
Blocked by a gate
Stage 4A-IFE
Alpha only
Clean outside the scanner, tangled with heartbeat inside.
Blocked by a gate
Stage 4A-SF
Channel recipe
Nothing passed tuning. Target never loaded.
Blocked by a gate
Stage 4B
The actual model
Its prerequisite, a validated EEG feature, never existed. No alignment, no regressor, no R², no ΔR².
Never started
The final readiness flags
$ cat readiness
alpha_q0_ready=false
broadband_eeg_ready=false
theta_ready=false
beta_ready=false
stage_4b=not_started
Why stopping was the right call

It doesn't rest on one borderline number. Four independent approaches failed in consistent ways, and the six-way timing problem would still be there even if one had worked. Going further meant lowering thresholds after seeing failures, or letting the eyes-open/closed labels and blood data into the method. Either one breaks the thing the project was built to protect.

The dataset's own companion paper recovered alpha reasonably well using ICA with condition-aware component picking. This doesn't contradict that. I asked a stricter question: can the signal be picked and validated without the labels or the blood data? Here, it couldn't.

What this result does not say
Not that the dataset is useless.

The fMRI, the timing forensics, and the calibration recordings all produced valid work.

Not that these cleaning methods don't work.

ICA, OBS, AAS, hybrids and spatial filters all have their uses. This result is specific to this recording, these controls, these gates.

Not that EEG and blood oxygen are unrelated.

That question never got asked. Stage 4B never started.

07Dataset 2

The two things that broke become the entrance exam.

Any replacement dataset has to clear five gates, frozen before any bulk download or any look at blood data. Fail one and it's out, no rescue campaign.
ATiming receipts

One physical scanner marker per snapshot, a table mapping one EEG sample to every saved snapshot, and clock error within about 10 ms.

Instant reject

Timing guessed from scanner buzz alone, undocumented warm-up deletion, or more than one possible alignment.

BHeartbeat-proof EEG

An ECG channel, raw data or an auditable cleaning chain, electrode positions, and heartbeat removal plus alpha preservation reproduced blind, before any blood data.

Instant reject

Cleaned-only data with no provenance, no ECG, or tuning on the target only.

CEnough data

Real alpha variation (ideally eyes open and closed), at least one continuous 6-minute run, and at least 240 saved snapshots per person.

Instant reject

Too little continuous data for honest held-out testing.

DActually open

Public and versioned, a license that allows analysis, open processing code, complete metadata.

Instant reject

A mutable archive, an unclear license, or access behind a data-use agreement.

EEnough people

At least 12 expected usable participants and 10 passing the early stages. 20+ preferred. Power target frozen in advance.

Instant reject

Fewer than 10 possible usable participants.

Candidates, desk review only

ds006040 goes first. It is a candidate for an audit, not an accepted dataset.

It keeps the original question intact: eyes open and closed, enough people, long simultaneous runs, ECG, raw EEG, public code, an open license. Two risks have to clear first. The trigger records must prove a unique snapshot mapping at the file level, and heartbeat cleaning must be shown to preserve spontaneous alpha.

OpenNeuro ds006040 v1.0.2

28 adults. Separate 6-min eyes-open and eyes-closed runs, ECG, raw and corrected EEG, CC0 license.

Trigger docs are inconsistent (4 s triggers described for a 2 s snapshot interval). Cleaning was validated on a flickering checkerboard, not alpha.

Conditional lead
NKI NATVIEW

22 adults. Eyes-open rest and movies, marker at every snapshot.

No eyes-closed. A 12 Hz checkerboard response is not spontaneous alpha.

Conditional runner-up
OpenNeuro ds007216

24 adults, 47 sessions. Eyes-open rest and an attention task.

Documented end-marker mismatches. Would need a reframed question.

Conditional secondary
ATR atr-EfP-2025

39 adults. Strong artifact instrumentation (carbon-wire loops).

Needs a data-use agreement. No eyes open/closed.

Hold / reject
Classic CWL eyes open/closed

8 adults, alternating blocks.

Too small to be the main cohort.

Benchmark only
OpenNeuro ds003768

33 adults, rest and sleep.

The eyes open/closed scan was never deposited.

Reject

The plan, front-loaded so it fails fast.

Prove timing and EEG before spending anything on full fMRI processing. The first smoke test ends after N2.

N0
Inventory

Pin version, license, fingerprints. Pick 3 pilot subjects without looking at quality.

N1
Prove the timing

A one-to-one EEG sample to trigger to snapshot table. Stop if any alternative survives.

N2
Prove the EEG

Heartbeat removal and alpha preservation against pre-set gates. Freeze one method.

smoke test ends
N3
Pilot fMRI checks

Freeze warm-up removal, slice timing, motion and exclusion rules.

N4
Freeze alpha

One alpha feature for every subject who passed N1 and N2.

N5
Line it up

Exact alignment and blood-delay design with run-aware test splits.

N6
The known 1 kg

Q0, with held-out testing, chance baselines, and replication across subjects.

N7
Theta and beta

Only if Q0 works, each with its own quality check.

Q1Is the timing unique?
Q2Is heartbeat handling credible?
Q3Is back-of-head alpha recoverable?
What carries forward

Most of the machinery survives. None of the outputs do.

The config loader, fingerprinting, report writing, blood-delay math, chance-baseline generators and plotting all move to the next dataset with their tests. The timing machinery, the EGI-specific electrode geometry and every piece of rescue code get retired into the repo history.

Every cleaned EEG file, extracted component and trained filter from these stages is explicitly forbidden from ever entering a model. Kept, not deleted, and never quietly promoted.

There is also enough here for a short negative-methods note, working title: Outcome-blind stopping in simultaneous EEG-fMRI.