Horror movies aren’t just fun, they’re good for science. And they’ve just shown researchers how our brains react to fear — information that could help understand mental illnesses and human behavior.

In order to study that fear, the scientists relied on electrodes that had already been implanted in two brain regions in epilepsy patients, monitoring their brain activity through the electrodes as the nine patients watched horror movie scenes. Findings published in Nature Communications showed how the amygdala and the hippocampus interact, “with the amygdala influencing hippocampal dynamics.” The researchers from the University of California at Irvine said the two brain regions were previously implicated in fear and other emotional information and memory, but they did not know until this study how they worked together in fearful or anxiety-provoking situations.

Read: 6 Weird Things Stress Does to Your Body

“The amygdala first extracts emotional relevance and then sends this information to the hippocampus to be processed as a memory,” senior author Dr. Jack Lin said in a statement from UC Irvine.

Fear isn’t always a negative thing. The study notes that recognizing the emotion in other people’s faces, for example, gives us “signals that focus our attention towards perceptually relevant information,” which could be important for survival.

“Yet over-interpretation of fear may lead to anxiety and other mental disorders,” UC Irvine said. Therefore, understanding the process could help doctors treat psychiatric disorders that have ties to fear, such as anxiety disorders, in a more precise way.

“Our hope is that we will one day be able to target and manipulate the precise amygdala-hippocampal circuit involved in processing negative emotions while preserving positive ones,” Lin said.

Source: Lin JJ, Zheng J, Anderson KL, et al. Amygdala-hippocampal dynamics during salient information processing. Nature Communications. 2017.

See also:

Stress Hormones Stop Us From Learning

Is a Panic Attack Physical or Mental?

Here’s Why People With Schizophrenia Hallucinate