Chapter 8 — Connect It Back to Dreamento
Think of it like this: you've built a go-kart engine (Chapter 6) in your own garage. This chapter is popping the hood of the real car (Dreamento) and finding exactly which socket your engine would need to bolt into — what shape, what voltage, what connector. Not swapping it in yet. Just mapping the socket.
What's Actually in the Repository
Four things to go read, straight from the real Dreamento repository:
model.py— defines a realTinySleepNetclass. This is the one from Chapter 6, at full scale, written in old TensorFlow 1.x.nn.py— the low-level building blocks (lrelu,fc, and similar helper layers) thatmodel.py's TinySleepNet is built from.realTimeAutoScoring.py— the actual real-time entry point. Its own docstring says it plainly: "Main model is based on tinysleepnet."DreamentoScorer/— the folder holding the model that's actually active today: scikit-learn.savfiles and aclf_eeg_lgb_0.4.0.joblib— LightGBM, confirming Chapter 4's classical approach is what's really running in production right now, not a neural network.
The Real Numbers, Verified Straight From the Code
Open realTimeAutoScoring.py and you'll find a real config dictionary with exact values — not estimates, the literal numbers the live system expects:
sampling_rate: 256.0— ZMax samples at 256 Hz.input_size: 7680— and 256 × 30 = 7680 exactly. That's one 30-second epoch, the same convention this entire course has used since Chapter 2.n_rnn_layers: 1,n_rnn_units: 256— a single LSTM layer, just like Chapter 6's lab, except with a far larger hidden size (256 versus the lab's deliberately tiny 32).- Real training settings also live here: 300 training epochs, Adam optimizer, early stopping after 50 rounds without improvement — the genuine, full-scale version of the 15-round demo from Chapter 6.
The channel naming confirms the ZMax dual-channel format too: the code expects a signal_req (EEG L) and a signal_ref (EEG R), matching the EEG L.edf / EEG R.edf files ZMax actually produces.
THE DOOR IS DELIBERATELY LEFT OPEN
Dreamento's own README says this about real-time autoscoring: "open to any algorithm (is not ideal yet, still under development)." That's not a guess about where your Chapter 6 model might fit — it's the project's own maintainers saying, in writing, that this exact piece is unfinished and welcomes a better model. This is a real, acknowledged opportunity, not a reach.
About Actually Running It
The original learning path suggests running offline Dreamento on a sample recording. Worth knowing up front: Dreamento is a desktop GUI application (PyQt5, installed via Anaconda or pip per its own README), not something that runs inside Colab. Installing and running it locally is genuinely useful if you want hands-on experience with the real tool, but it's optional for finishing this chapter — the actual deliverable below doesn't require it.
Write It Down: Your Integration Plan
Same approach as Chapter 7 — answer these directly, a few sentences each, grounded in what you just read:
- Chapter 6's lab used 1 EEG channel, 256-sample windows resampled by MNE, and sequences of 10 epochs. Dreamento's real config expects 7680-sample windows (256 Hz × 30s) and different sequence handling. What exactly would need to change in your Chapter 6 code to match?
realTimeAutoScoring.pyimportsTinySleepNetstraight frommodel.py. If your own trained model needed to plug in here, what format would it need to be saved in, and what would the loading code need to call?DreamentoScorer(LightGBM) is what's actually running today, not a neural network. What would have to be true — in terms of accuracy, speed, or reliability — before swapping in a neural model would actually be worth doing?- Name one concrete, scoped-down first step you could realistically take toward this integration, short of rewriting the whole real-time pipeline.
DONE WHEN
You have a concrete written integration plan — not code yet, just where a trained model goes and exactly what format conversion would be needed to get there.
That's Part 2 complete — the full machine learning pipeline, from a classical baseline through a real trained CNN+LSTM to a genuine, code-verified integration plan. Part 3 turns to lucid dreaming specifically: sleep staging tells you when someone is in REM, but not whether they're lucid — a separate, harder, and far less settled question.