SAN FRANCISCO, Calif. (KRON) — When you’re in a deep sleep and your eyes are moving, you are gazing at a dream world that is important for how our brains process the real world, according to a new study released by University of California San Francisco researchers.

Massimo Scanziani, senior author on the study, found that the same parts of the brain coordinate during dreaming and wakefulness, providing further evidence that dreams help the brain integrate and process information gathered throughout the day.

The study, titled “A cognitive process occurring during sleep is revealed by rapid eye movements,” was published online Thursday. The main focus of the study looked at Rapid Eye Movement and why our eyes move during these deep sleep cycles.

Scanziani’s team of researchers recorded data on how the brain functions during REM sleep, and compared it to how the brain functions when awake.

Scientists have known that dreams occur during REM, a period of sleep marked by quick eye movements, since the 1950s. But why do our eyes move and for what purpose? That question was a matter of mystery and debate for decades.

In the second half of the 20th century, some experts hypothesized that during REM sleep our eyes were watching scenes in the dream world. But many researchers wrote off REM movements as random.

UCSF said its new study was the first to find a concrete answer. Researchers studied the brains and eyes of mice during REM sleep cycles.

“We showed that these eye movements aren’t random. They’re coordinated with what’s happening in the virtual dream world of the mouse,” Scanziani said.

“This work gives us a glimpse into the ongoing cognitive processes in the sleeping brain and at the same time solves a puzzle that’s triggered the curiosity of scientists for decades,” Scanziani said.

Scanziani and UCSF postdoctoral researcher Yuta Senzai used advanced technology to track a mouse’s brain cells that control head direction like a compass. Researchers recorded data from “compass” brain cells simultaneously with recording data from eye movements.

They discovered that the direction of eye movements and the internal “compass” were precisely aligned during REM sleep. Researchers also found that that alignment was identical compared to when a mouse was awake and walking around.

Scanziani launched the study because he is fascinated by the “generative brain,” meaning a person’s imagination and ability to make up scenarios. 

“One of our strengths as humans is this capacity to combine our real-world experiences with other things that don’t exist at the present moment and may never exist,” Scanziani said. “This generative ability of our brain is the basis of our creativity.”

Peering into the brain while its dreaming provides researchers with a chance to see how the brain functions in the complete absence of real-life sensory stimulation.

In a dream, the brain combines familiar people, places, and things with those that are unknown or impossible.

Scanziani said he had a recurring dream in which he was a young diver and able to breathe underwater. When he woke up, he realized that he couldn’t really breathe underwater. “But in the dream, you believe it’s real because there aren’t sensory inputs to bring you back to reality. It’s a perfectly harmonious fake world,” he said.  

“It’s important to understand how the brain updates itself based on accumulated experiences,” he said. “Understanding the mechanisms that allow us to coordinate so many distinct parts of the brain during sleep will give us insight into how those experiences become part of our individual models of what the world is and how it works.”