RIIZE Insomnia — Dreams of an Insomniac Machine
Reading the lyrics of Insomnia, I wondered how to turn sleepless nights and dreams into images. How would I go about turning a dream into an image? Research on generating images from EEG suddenly came to mind.
DreamDiffusion proposes a method for generating images from EEG recorded while a person looks at images. Rather than translating EEG into sentences to use as prompts, it directly uses features extracted from EEG to condition image generation.
But EEG is noisy and varies considerably from person to person. There is also a shortage of data pairing EEG with images. In this study, the encoder is first pretrained by masking parts of EEG signals and learning to reconstruct the missing portions. Before being shown images, it learns the patterns of the signals themselves. It is then trained to bring the EEG embeddings closer to the CLIP embeddings of the images the person was viewing. These features are passed to a pretrained Stable Diffusion model to generate images. DreamDiffusion paper
More recently, researchers have reconstructed movies that mice were watching from their brain activity. A study published in 2026 measured neuronal activity in the mouse visual cortex and reconstructed ten-second movies at 30 frames per second that had not been used in training. This did not use EEG sensors placed on the scalp, however. It used two-photon calcium imaging to optically observe neuronal activity. Paper
These studies deal with images and movies viewed while awake. But what would happen if I fed EEG recorded during sleep into a generative model? I was curious.
So I bought an EEG headset. A two-photon microscope was beyond the budget of a broke graduate student.
The MindWave Mobile 2 I used records a single channel at Fp1, on the left side of the forehead. Compared with research equipment that records EEG from multiple locations, it provides limited information, and signals such as eye blinks get mixed in. I could hardly expect the performance reported in the papers, but I decided to collect my own data and connect it to a generative model.
To collect data, I built a program that displayed a sequence of different images while recording EEG. All I had to do was attach the sensor and watch the screen. It sounds simple, but the readings changed considerably with sensor contact and electrical noise in the surroundings. I readjusted the sensor and ear clip, unplugged the charger, and moved away from power outlets. Even collecting the data was less straightforward than I had expected. Being broke is rough.
Using the collected data, I trained a model to connect EEG patterns with image features. CLIP extracts an embedding from the image being viewed, and the EEG encoder learns to predict that embedding. I then fed in EEG recorded while sleeping with Insomnia playing and passed the predicted features to an open-source generative model to create new images.
At first, similar images kept appearing. The predicted features were clustered within a narrow range. Keeping the recorded EEG as the source of the values, I adjusted the distribution and variation of the embeddings to increase image diversity.
I adjusted the intervals between images to follow changes across sections of the music, and had objects and spaces transform into one another rather than simply overlap and fade away. I then stacked the video frames in chronological order. Time passing in the video became depth in space. I volume-rendered this mass using ray marching. The current image sits at the front, with earlier images remaining behind it. They become more transparent toward the back, with parts also opening up according to brightness.
I drew the recorded EEG as a scrolling waveform at the bottom of the screen. The embeddings used for image generation were projected into three dimensions using PCA and connected into a curve. I used this curve as a light source, allowing light to spread and be occluded inside the volume of stacked images.
What you are seeing, then, is the result of a machine translating EEG recorded during sleep into images. I cannot know how closely it resembles the dream I actually had. It is closer to a dream made jointly by my EEG and the images the generative model knows.
To put it romantically, perhaps it is a dream dreamed by an insomniac machine.
Okdalto
Comments