The accidental finding was made when a man suddenly died during a routine brain scan.

After an elderly patient died suddenly during a routine test, scientists accidentally captured unique data on the activity in his brain at the very end of his life: During the 30 seconds before and after the man’s heart stopped, his brain waves were remarkably similar to those seen during dreaming, memory recall and meditation, suggesting that people may actually see their life “flash before their eyes” when they die.

The phenomenon of replaying past memories when you die has been reported by some people who have had near-death experiences. But this is the first scientific evidence that this “flash” might be real. However, as this is the only case study, it is impossible to make further assumptions about how common the phenomenon may be or what the experience may be like.

Researchers made the startling discovery in 2016 while studying the brain activity in an 87-year-old Canadian man who had developed epilepsy. The team was performing an electroencephalogram (EEG) — a test that detects abnormalities in the electrical activity of the brain — to learn more about what was happening during his seizures. That’s when the man suffered a sudden and fatal heart attack. The patient’s unexpected death meant that the team had accidentally made the first-ever recording of a dying brain, the researchers said in a statement.

In total, the researchers recorded around 900 seconds of brain activity leading up to and immediately after the patient’s death. This allowed them to see how his neural oscillations — repetitive patterns of neural activity, also known as brain waves — changed as he was dying. They found that in the 30 seconds before and after his heart stopped, there was an unusual change in his brain wave activity.

“Just before and after the heart stopped working, we saw changes in a specific band of neural oscillations,” senior researcher Dr. Ajmal Zemmar, a neurosurgeon at the University of Toronto in Canada at the time of the man’s case, said in the statement. These specific types of oscillations are known as gamma waves, added Zemmar, who is now at the University of Louisville in Kentucky.

Neural oscillations are classified based on their frequency and amplitude. Gamma waves have a frequency between 30 and 100 hertz, the highest frequency of any oscillations, and are most commonly observed in the brain when people access their memory center, in a region called the hippocampus, during dreams.

The team also gathered data on other types of oscillations during death, including delta, theta, alpha and beta waves. But it was the gamma waves that pointed toward the man replaying memories from throughout his life in his brain — a phenomenon known as life recall.

“Through generating oscillations involved in memory retrieval, the brain may be playing a last recall of important life events just before we die, similar to the ones reported in near-death experiences,”Zemmar said in the statement.

Experiments in rats have shown that the rodents also experience similar levels of gamma oscillations around the time of death, according to the statement. Therefore, the researchers speculate that life recall may be a universal experience shared by a majority of mammal dying brains, although there is minimal evidence to back this up.

But the researchers warned that it would be premature to conclusively state that life recall is a real phenomenon. The dying man was elderly and had epilepsy, which is known to alter gamma wave activity. This could have meant his brain activity during death was different from that of someone without epilepsy. Moreover, there is no way to know if the man was actually seeing, or perceiving, his past memories or if he was just in a dream-like state brought on by his failing nervous system.

Therefore, much more research is needed to make concrete conclusions about life recall, the researchers cautioned. The report of the man’s case was not published until six years after his death because the researchers were hoping to uncover more case studies of dying brains to support their claims, but they came up empty-handed, according to the BBC.

However, the findings could provide a source of comfort to friends and family members during the “indescribably difficult” experience of losing loved ones, the researchers said. “Although our loved ones have their eyes closed and are ready to leave us to rest, their brains may be replaying some of the nicest moments they experienced in their lives,” Zemmar said in the statement.