Hypnagogia

Hypnagogia is the state of mind that exists between being awake and sleep, or just after waking up.
People in this state may have experiences that resemble hallucinations, but are not. The person usually knows that it is not real, but very often nothing can be done against it. Most of these "pseudohallucinations" are visual experiences.
Other experiences that may happen are sleep paralysis and lucid dreams. All of these symptoms happen because of the changes that occur in the brain, and they are not linked to a disease.
The writings of Aristotle already talk about hypnagogia. In more recent centuries, many authors have referred to the state. Edgar Allan Poe, for example, wrote of the "fancies" he experienced "only when I am on the brink of sleep, with the consciousness that I am so".
Serious scientific inquiry began in the 19th century with Johannes Peter Müller, Jules Baillarger and Alfred Maury, and continued into the 20th century with Leroy.
With electroencephalography (EEG) in the mid 20th century, detecting such a state has become easier.