Day 5: real event or artifact
In short
- Brain Atlas’s anomaly panel wasn’t closing for good — missing a toast() function. Fixed, then used the same bug report to redesign the whole challenge.
- The trace-reading challenge now zooms in, freezes the trace, pauses the rover, gives a real answer window, and explains the physiology when you’re wrong instead of just scoring you.
- New research page sourced from three real papers (LaBerge 1981, Chase & Morales 1990, Anderer et al. 1999), checked against the actual PDFs, not memory.
- The site’s top nav had grown to 10 flat items with no games section at all. Collapsed Videos/Research/Agentic Dev/Docs into one Education hub; nav is down to 7, homepage path down to 3 steps.
- Two silent failures today: a homepage edit that did nothing because the template ignores markdown content, and a new Hugo layout the dev server didn’t pick up until restarted.
- Kept, not deleted: night-drive, the prototype Brain Atlas grew out of. It could classify Wake/N1/N2/N3/REM; Brain Atlas still can’t. That gap stays open on purpose.
On this page
What started it
A bug report: the anomaly prompt in Brain Atlas (the exploded-view 3D brain, drive-to-electrode game) would come back up after you’d already answered it, or just never fully go away. The cause was small — toast(), the function that shows the little “you got it” message, didn’t exist yet; the code that called it was throwing silently and leaving the panel in a half-closed state. Added the function, confirmed the panel now closes for good.
That fix exposed the actual problem underneath it: even working correctly, the challenge gave you 4.5 seconds, scrolling the whole time, to decide “real event or artifact?” from a fast-moving three-line squiggle. Nobody was learning anything from it. They were pattern-matching against a timer.
Redesigning the challenge
The anomaly now runs in three phases instead of one:
| Phase | What happens |
|---|---|
| Lead-in (1.4s) | The trace keeps moving, letting the anomaly actually develop and become visible, same as before |
| Prompt | The trace freezes mid-anomaly, the panel zooms to the center of the screen over a dimmed backdrop, the rover and camera stop moving entirely, and you get 8 seconds — not 4.5 — to answer |
| Explain (only on a wrong answer or timeout) | No score, no toast. A plain-language explanation of what each channel actually did and why that makes it real or an artifact, with a “Got it →” button the player dismisses themselves |
The freeze is the part that matters most: driveUpdate() now checks anomalyLocked() first and, if the challenge owns the screen, skips rover movement and camera lerp entirely but keeps calling updateAnomaly() and drawTrace() — so the game genuinely pauses rather than just overlaying a dialog on a scene still running underneath it. drawTrace() stops pushing new samples into the trace buffer while frozen, so what’s on screen when you’re asked is exactly what you’re asked about, not something that scrolled off three frames ago.
Mistake today: the first version of the zoomed canvas clipped the top of the “EEG” label — the text baseline sat at y = h*0.17 - 10 ≈ 3px in a canvas with its origin at 0, so the glyph’s ascender rendered above the visible area. Invisible at the old 78px display height, obvious once the canvas was stretched to 200px for the zoom. Fixed with a floor: Math.max(9, lane.y - 10).
A sourced research page
The redesigned challenge needed somewhere to point a curious player, so /research/reading-a-sleep-trace-real-event-or-artifact/ explains the same judgment call with citations: REM’s three-channel signature (LaBerge, Nagel, Dement & Zarcone 1981; Chase & Morales 1990 on atonia), and the artifact taxonomy from Anderer et al. (1999), Artifact Processing in Computerized Analysis of Sleep EEG, Neuropsychobiology 40:150–157 — electrodermal drift from sweat, single-lead pulse artifacts, movement that can fake delta activity outright, and line noise.
Mistake today: first draft cited “Ruehland et al., Sleep 2011” from memory with a specific PMC id and page range. A search turned up a real Ruehland paper, but a different one (hypopnea scoring, not the EEG montage), at a different PMC id than what the existing site already links to. Rather than invent bibliographic details I couldn’t verify, the new page just reuses the exact citation link the site already had in eeg-and-eog-options.md, unembellished. The Anderer citation, by contrast, got checked directly: fetched the actual PDF and read the title page and the “Types of Artifacts” section before writing a single claim from it.
The website had no front door for any of this
Brain Atlas had no link anywhere except a chat message. The top nav had grown to 10 flat items — Download, Journey, Videos, Research, Learn (actually unrelated agentic-AI-development tutorials, not sleep science), Docs, Questions, Proposal, GitHub, plus whatever came next — with no grouping and nowhere that said “here’s how to approach this site.”
Three passes, each one simplifying the last:
- Added a
/games/section and linked Brain Atlas from the homepage’s “Built in public” cards. - Added a “Where to start” section to the homepage: five numbered steps (videos, research, install, the Diary Keeper’s multi-user server mode, developer docs), each a full-width row instead of a card grid — closer to a table of contents than a feature grid.
- Noticed four of those five steps were all “education” wearing different names. Pulled Videos, Research, Agentic Dev and Docs under one new
/education/hub page (same numbered-row layout, reused), collapsed the top nav from 10 items to 7, and cut the homepage path down to three real stops: Education, Install, and the backend’s early multi-user mode.
That last step also corrected an assumption: “multiple people on one server” wasn’t vaporware to label “coming soon” — backend/README.md already documents a working local-vs-server split (SQLite solo, PostgreSQL + Docker for a few people), with app/models.py carrying a real User model with roles and tests/test_account.py/test_admin.py passing. Early, not imaginary. The homepage step links straight to the backend instead of hedging.
Mistake today: the first attempt to add a homepage game link edited content/_index.md’s markdown body and changed nothing. The homepage doesn’t render through _default/single.html — it has its own layouts/index.html that never references .Content at all. The real fix was a hand-written <a class="link-card"> inside that template. Separately, the new layouts/education/list.html rendered as a blank generic list page until the Hugo dev server was restarted — new files under layouts/ didn’t trigger its watcher.
A wrong turn worth keeping
website/static/games/night-drive/ is still sitting in the repo, linked from nowhere, and it’s staying there on purpose. It was the first prototype, built before Brain Atlas: a flat hookup screen (tap each electrode site, check impedance, fix anything over 5kΩ for EEG/EOG or 10kΩ for EMG), a bio-calibration step, and then a staging game — classify the live trace into Wake, N1, N2, N3 or REM as it changes, with the actual scoring cues called out as they happen (a K-complex, a spindle, a microsleep, a dream cue during REM).
Brain Atlas took the project in a more spatial direction — a real 3D brain to explore, a rover you drive to a failing electrode, a repair minigame for impedance instead of a tap-to-fix list — and kept growing from there today into the real-event-vs-artifact challenge. What it didn’t carry over was night-drive’s actual core loop: naming the sleep stage itself. Brain Atlas can teach you to tell REM from an artifact; it still can’t ask “is this Wake, N1, N2, N3 or REM?” the way night-drive could.
That’s unfinished, not abandoned. The stage-naming mechanic belongs somewhere — maybe back into Brain Atlas as another phase of the same trace panel, maybe night-drive gets revived and connected to the same 3D scene instead of its own flat UI. Keeping the file around means that decision stays open instead of getting made by deletion.
Where things stand
website/static/games/brain-atlas/index.html— the trace-reading redesign, tested by hand through all three phases including a deliberate wrong answer and a timeout.docs/research/reading-a-sleep-trace-real-event-or-artifact.md— new, sourced.website/content/education/,website/content/games/,website/layouts/education/list.html— new site structure.website/hugo.toml,website/layouts/index.html,website/assets/css/site.css— nav and homepage changes.website/static/games/night-drive/— kept, unlinked, waiting on the Wake/N1/N2/N3/REM decision above.
