Ever wonder what goes on in your head after you’ve nodded off? Researchers are only just beginning to figure that out, but what they do know is that the sleeping brain is one busy noggin.QUIZ: How Much Quality Sleep Are You Getting?One key role of sleep is to allow your brain to consolidate memories. That’s when your thoughts about brand new knowledge and experiences crystalize into long-term memories.Of course, you learn new things while you’re awake, but it’s when you’re deep in dreamland that new information becomes integrated with the memories stored in your brain. That’s according to a study from Gareth Gaskell, Ph.D., a professor of psychology at the University of York in England. He and his colleagues found that not only do you learn new information better if you sleep on it, but shut-eye also helps your brain organize this new material.“It seems to be putting this new knowledge in just the right place so you can make best use of it after sleep,” explains Dr. Gaskell.In the study, Gaskell and his colleagues had people learn new made-up words like “cathedruke.” They judged how well people integrated a new word with the rest of their vocabulary by seeing whether learning it slows them down when identifying similar words, like “cathedral,” now that they’re reconciling both words at once. The researchers found that this new knowledge integration correlated with sleep spindle activity—quick bursts of brain activity that happen as you transition into deeper sleep, when your hippocampus (memory storage deep in the brain) interacts with your neocortex (an area responsible for higher functions including conscious thought and language).MORE: Sleep More and Fit Into Your Skinny JeansSleep Helps Store Emotional MemoriesAs it turns out, your brain is particularly partial to storing emotional memories while you’re sleeping. When you’re awake, your memories and related emotions can dwindle with time. But research shows that feelings surrounding unpleasant memories seem to remain just as sharp after hitting the sack.Rebecca Spencer, Ph.D., a psychology professor at University of Massachusetts Amherst, was curious about how sleep helps preserve your memory of and feelings about positive and negative events.Here’s what she found: “Sleep makes something that seemed negative seem just as negative,” Dr. Spencer says. “But sleep doesn’t do that for positive memories. So if you just got married, you say, ‘Should I get a good night of sleep on my marriage night because I want to protect that happy feeling I had around my wedding day?’ Sleep might help you better store all those images from the day, but it’s not going to do anything preferential for that happy feeling you have for it.”Spencer suggests that there’s a greater evolutionary advantage to remembering the emotional tone related to bad events: to make sure they don’t happen again. Imagine a child who has put her hand near a hot stove, only to have her mom panic. “The child needs to not only remember this negative event,” Spencer explains, “but they also need to remember their own emotional reaction, because if they don’t remember those things then they won’t respond appropriately in the future.”In the case of a horrific memory of a scenario you’re unlikely to encounter again, your body has a sleep-related strategy as well. “With severe trauma,” she says, “the body’s biological response is to go through a period of insomnia.” Such lengthened wakefulness can help take away the sharpness of your recalled feelings.MORE: How to Journal Through a Traumatic EventThe Link Between Sleep and CreativityOrganizing your memories while you’re out like a light can also boost creativity. “Anything that gives you a pause from taking in so much information and lets you switch to a processing mode where you’re not only committing the information to memory but also reorganizing it, that’s where some of the creative insight comes from,” says University of Notre Dame psychology professor Jessica Payne, Ph.D.During rapid eye movement (REM) sleep, networks in your brain talk with each other in very different ways compared to when you’re awake. There’s a lot of activity in the hippocampus (which plays a role in long-term memory), the amygdala (a brain region important for emotion processing) and parts of the prefrontal cortex (the decision making area), according to Dr. Payne. “Then you’ve got this incredible de-activation of another part of the frontal lobe called the dorsolateral prefrontal cortex,” Dr. Payne adds, which is thought to be the seat of rational control.“If you think about what creativity really is, it’s about far-flung solutions to problems, it’s about seeing connections that you wouldn’t usually see, it’s about putting together the information that you already know in new and novel ways,” says Payne. “And so the processing of the brain during REM sleep might allow for that to happen.”In other words, REM sleep allows your emotion, memory and decision-making centers to ramp up without the limits of rationality usually enforced by the dorsolateral prefrontal cortex.Payne stresses that any rest you can get—even short breaks, meditation and exercise—can provide a break from absorbing information, allowing your brain time to reorganize memories and promote creativity.MORE: The Best Exercises for Finding FlowThe Importance of Quality SleepThat said, some kinds of memory consolidation need longer sustained periods of sleep. Ina Djonlagic, M.D., a neurologist at Harvard University, led a study on motor learning in people with sleep apnea. She had them learn an exercise–typing a sequence of numbers on a computer keyboard. After they had a night of sleep, she compared their memory of the movements with the memory retention of a control group who slept the same number of hours, but without disturbances. The control group performed much better at the motor memory task the following morning, while those with sleep apnea barely showed improvement.“Our research suggests that if you have more than the usual number of arousals, this will interrupt this [memory] process and interfere with the enhancement of learning while we sleep,” Dr. Djonlagic says. Arousals are small shifts in brain waves. She estimates that people need three- to five-minute periods of consistent sleep to stabilize new motor information for long-term memory storage. So if you’re sleeping restlessly, such as with sleep apnea, you’re not getting that consistent rest.MORE: The Difference Between Sleep Apnea and SnoringWant to remember all of this new information you just learned about sleep? Try hitting the sack.