Kladyk via Getty Images Many artists have used hypnagogia, the state between sleep and wakefulness, to tap into their deepest creativity.

We're all familiar with the two basic states of consciousness: sleep and wakefulness. But what about what happens in between those states?

In the borderlands between wakefulness and rest is a strange and fascinating state of consciousness characterized by dream-like visions and strange sensory occurrences. Psychologists call this stage "hypnagogia," but centuries before they created a term for it, artists were using the hypnagogic state to tap into some of their best ideas.

Surrealist artist Salvador Dali called hypnagogia "the slumber with a key," and he used it as creative inspiration for many of his imaginative paintings.

"You must resolve the problem of ‘sleeping without sleeping,’ which is the essence of the dialectics of the dream, since it is a repose which walks in equilibrium on the taut and invisible wire which separates sleeping from waking," Dali wrote in the book 50 Secrets of Magic Craftsmanship.

Mary Shelley, too, said she got the inspiration for Frankenstein from a "waking dream" in the wee hours of the morning, writing, "I saw with eyes shut, but acute mental vision," according to The Guardian.

During this state, the mind is "fluid and hyperassociative," giving rise to images that can "express layers of memories and sensations," dream researcher Michelle Carr explained in a Psychology Today blog.

You experience some phenomena of sleep while you are still able to be awake and remember them." Neurologist Dr. Milena Pavlova

Similar to REM sleep -- the state of deep sleep when our dreams occur -- the mind is cycling through thoughts, ideas, memories and emotions, making free and often distant associations between diverse concepts. But unlike REM, during hypnagogia you're conscious enough to be at least partially aware of what's going on.

"There can be fragments of rapid eye movement sleep occurring in a non-REM state when the individual is not yet fully asleep," Dr. Milena Pavlova, a neurologist studying sleep and circadian disorder at Brigham and Women’s Hospital in Boston, told The Huffington Post.

There's a good chance you've experienced hypnagogia before, even though you may not have known exactly what was going on. Little research has been conducted on hypnagogia, but here's a look at what we know about its mysterious workings.

Between Sleeping And Waking

The term hypnagogia comes from the Greek words for "sleep" and "guide," suggesting the period of being led into slumber.

In this state, which lasts a few minutes at most, you're essentially in limbo between two states of consciousness. You experience some elements of sleep mixed with some aspects of wakefulness, explains Pavlova.

"You wind up in the state somewhere between sleep and wakefulness, and you experience some phenomena of sleep while you are still able to be awake and remember them," she told The Huffington Post.

What's going on in the brain to create this trippy state of consciousness? Scientists have observed the presence of both alpha brain waves -- which are the dominant brain wave mode when we are conscious but relaxed, for instance when daydreaming or meditating -- and theta brain waves, which are associated with restorative sleep, during hypnagogia. Typically, these brain waves occur only separately, and it may be the unique combination that gives rise to unusual visions and sensations.

The state is also marked by reduced activity in the prefrontal cortex of the brain, which is involved in planning, decision-making and social behavior.

In some ways, hypnagogia is the best of both worlds. You get the free flow of ideas and associations that occurs during REM sleep -- when the brain reviews and processes memories, thoughts and feelings -- but you're still awake enough to be somewhat conscious of what's going on.

For this reason, some artists have found hypnagogia to be a rich source of ideas and inspiration.

Vivid Visions

St. Louis Post-Dispatch via Getty Images A Dali-style dreamscape of tired, rundown bodies created by The St. Louis Post-Dispatch's Tom Borgman in 2004.

Hypnagogia is trippy, and can give rise to some bizarre visual and perceptual hallucinations. It's common for people to experience dream-like visions, sounds, flashes of color, insights, sensations and barely formed thoughts.

“Typically, there is a lot of visual imagery,” Deirdre Barrett, a clinical psychologist at Harvard Medical School, told ScienceLine. ”Sometimes static images, sometimes short-moving segments and occasionally longer narratives more like REM sleep dreams. Sounds also accompany this state sometimes.”

When these images are too vivid or disturbing, however, they can be indications of something more serious -- a sleep disorder called hypnagogic hallucinations. These types of highly realistic visions are also common in narcolepsy.

"That means seeing things that are not there upon falling asleep," Pavlova said. "That's the disordered function of this."

What's happening is that the switches in your brain are turning from wakefulness to sleep, but haven't fully synchronized.

"Part of your brain is still in the waking world and part of it is not, and so you see this that are not there," she explains. "It's very similar to the dreaming stages of sleep."

For those without sleep disorders, hypnagogia can be used to generate creative insights, as it provides a clear path to the subconscious, intuitive mind that is the source of "aha!" moments that arise seemingly out of nowhere when the rational mind is occupied elsewhere.

“Hypnagogia is the shortest path for communication from our subconscious," Sirley Marques Bonham, a consciousness researcher at the University of Texas at Austin, told ScienceLine. "Your subconscious mind might send you solutions through imagery or other sensations.”

Also on The Huffington Post:

PHOTO GALLERY 17 Gadgets To Help You Sleep