It's likely happened to you before: You start rubbing your eyes and almost immediately begin seeing colors, specks, and swirls from behind your closed lids. So what's happening when you see these 2001-esque "stars"? Do they only occur upon rubbing? Does everyone experience them?
Before we can get to what causes the lights, we need to understand a bit about how the eyes work. Angie Wen, a cornea surgeon at New York Eye and Ear Infirmary of Mount Sinai, tells Mental Floss that the retina—the innermost layer of the eye—consists of millions of cells, or photoreceptors. These cells, she says, "are responsible for receiving information from the outside world and converting them to electrical impulses that are transmitted to the brain by the optic nerve. Then, the brain interprets them as images representing the world around us."
However, what we see doesn't just stop there. Sometimes "we see light that actually comes from inside our eyes or from electric stimulation of the brain rather than from the outside world," Wen says. "These bursts of seemingly random intense and colorful lights are called phosphenes, and appear due to electrical discharges from the cells inside our eyes that are a normal part of cellular function."
People have been writing and theorizing about phosphenes for thousands of years. Greek philosophers thought the bursts of light were the result of fire inside our heads: "The eye obviously has fire within it, for when the eye is struck fire flashes out," wrote Alcmaeon of Croton (6th–5th century BCE), a philosopher and early neuroscientist, of the swirls and specks someone sees after getting a blow to the head. A century later, Plato—who believed that a "visual current" [PDF] streamed out of the eye—wrote that "Such fire as has the property, not of burning, but of yielding a gentle light they [the Gods] contrived should become the proper body of each day."
Plato's take was still the dominant one through the Middle Ages. Eventually, Newton (1642–1727) theorized a concept that's more in line with what's believed today about these strange sparkly visions: The phenomenon is due to light that's produced and observed when pressure and motion is placed on the eyes.
Eleonora Lad, an associate professor of ophthalmology at Duke University Medical Center who has a background in neuroscience, explains exactly why eye rubbing generates these visions: "Most vision researchers believe that phosphenes result from the normal activity of the visual system after stimulation of one of its parts from some stimulus other than light," including putting external pressure on the eyes. (Interestingly, due to retinal damage, blind people can't see phosphenes caused by pressure, but they can see them when their visual cortex is electrically stimulated. In hopes of turning this phenomenon into improved vision for the blind, scientists have developed a cortical visual prosthesis, implanted in the visual cortex, that generates patterns of phosphenes. The device has been approved by the FDA for clinical trial.)
As Alcmaeon rightly pointed out, there are causes for the bursts of light beyond just rubbing your eyes: Getting hit in the eye can produce this phenomenon—as can a sneeze, a surprisingly powerful event that tends to clamp our eyes shut, Wen says.
Receiving an MRI or EEG may also trigger it. MRIs, for example, produce a changing magnetic field which can stimulate the visual cortex, making a person see these flashing lights. When it comes to an EEG, depending on the brain stimulation frequency band (Hz) used, some patients experience the phenomenon when closing their eyes, which is believed to come from retinal stimulation during the process.
And the activity doesn't only happen on Earth; astronauts in space have also been known to experience them. As reported in 2006 in the journal Vision Research, "over 80 percent of astronauts serving in today's NASA or ESA (European Space Agency) programs have perceived phosphenes at least in some missions and often over several orbits." They're mainly attributed to interactions between the eye and cosmic ray particles in space, outside the Earth's protective magnetic field.
No matter the cause, the bursts of light are perfectly normal—but that doesn't mean you should engage in excessive eye rubbing. Wen says ophthalmologists advise against rubbing your eyes or applying vigorous pressure; according to Lad, too much rubbing may be damaging to the cornea and lens or "result in a loss of fatty tissue around the eyes, causing the eyes to look deep-set."