It used to be that what happened in your dreams was your own little secret. But today scientists report for the first time that they've successfully decoded details of people's dreams using brain scans.

Before you reach for your tin hat, you should know that the scientists managed this feat only with the full cooperation of their research subjects, and they only decoded dreams after the fact, not in real time. The thought police won't be busting you for renting bowling shoes from Saddam Hussein or whatever else you've been up to in your dreams.

All the same, the work is yet another impressive step for researchers interested in decoding mental states from brain activity, and it opens the door to a new way of studying dreaming, one of the most mysterious and fascinating aspects of the human experience.

In the first part of the new study, neuroscientist Yukiyasu Kamitani and colleagues at the Advanced Telecommunications Research Institute International in Kyoto, Japan monitored three young men as they tried to get some sleep inside an fMRI scanner while the machine monitored their brain activity. The researchers also monitored each volunteer's brain activity with EEG electrodes, and when they saw an EEG signature indicative of dreaming, they woke him up to ask what he'd been dreaming about.

Technically speaking, this is what researchers call "hypnagogic imagery," the dream-like state that occurs as people fall asleep. In the interest of saving time, Kamitani and colleagues chose to study this type of imagery rather than the dreams that tend to occur during REM sleep later in the night. They woke up each subject at least 200 times over the course of several days to build up a database of dream reports.

In the second part of the experiment, Kamitani and colleagues developed a visual imagery decoder based on machine learning algorithms. They trained the decoder to classify patterns of brain activity recorded from the same three men while they were awake and watching a video montage of hundreds of images selected from several online databases. After the decoder for each person had been trained, the researchers could input a pattern of brain activity and have the decoder predict which image was most likely to have produced that pattern of brain activity.

But that much has been done before. Where Kamitani's team went beyond previous work was in feeding the decoder patterns of brain activity collected while the subjects were dreaming. This enabled them to correctly identify objects the men had seen in their dreams, they report Apr. 4 in Science. Or rather, they could identify the type of object a subject had seen: it could predict that a man had dreamt about a car, not that he'd been cruising around in a Maserati. And the decoder only worked when the researchers gave it a pair of possible objects to chose from (whether it was a man or a chair, for example).

"Our dream decoding is still very primitive," Kamitani said.

Decoding color, action, or emotion is also still beyond the scope of the technology, Kamitani says. Also, it only seems to work for imagery that occurred – at most – about 15 seconds before waking up.

Finally, the decoder is unique to each person. To decode the dreams of another person, the team would have to train up a new decoder by having that person view hundreds of images.

Even so, it's remarkable that it works as well as it does, says neuroscientist Jack Gallant of the University of California, Berkeley and a pioneer of decoding mental states from brain scans. "It took just a huge amount of non-glamorous work to do this, and they deserve big props for that," Gallant said.

With refinements, Gallant says the method could be useful for studying the nature and function of dreams.

"There's the classic question of when you dream are you actively generating these movies in your head, or is it that when you wake up you're essentially confabulating it," Gallant said. "What this shows you is there's at least some correspondence between what the brain is doing during dreaming and what it's doing when you're awake."

Kamitani is thinking about the possibilities too. "One theory states that dreaming is for strengthening memory, but another theory states dreaming is for forgetting," he said. "We could record the frequency of decoded dream contents for each memory item and see the correlation between the frequency and the memory performance."