A tiny part of the brain can keep track of your expectations about negative experiences—and predict when you will react to an event—researchers at University College London say.

The brain structure, known as the habenula, activates in response to negative events such as electric shocks, and they may help people learn from bad experiences.

The findings, published in Proceedings of the National Academy of Sciences, marks the first time this association has been proven in humans. Earlier studies showed that the habenula causes animals to avoid negative stimuli by suppressing dopamine, a brain chemical that drives motivation.

In this study, investigators showed 23 people random sequences of pictures followed by a set of good or bad outcomes (an electric shock, losing money, winning money, or neutral). The volunteers were asked to occasionally press a button to show they were paying attention, and researchers scanned their brains for habenula activity using a functional magnetic resonance imaging (fMRI) scanner. Images were taken at high resolution because the habenula is so small—half the size of a pea.

When people saw pictures associated with painful electric shocks, the habenula activated, while it did not for pictures that predicted winning money.

“Fascinatingly, people were slower to press the button when the picture was associated with getting shocked, even though their response had no bearing on the outcome,” lead author Rebecca Lawson from the University College London Institute of Cognitive Neuroscience, said in a statement. “Furthermore, the slower people responded, the more reliably their habenula tracked associations with shocks. This demonstrates a crucial link between the habenula and motivated behavior, which may be the result of dopamine suppression.”

The study also showed that the habenula responds more the worse an experience is predicted to be. For example, researchers said the habenula responds much more strongly when an electric shock is certain than when it is unlikely to happen. This means that your brain can tell how bad an event will be before it occurs.

The habenula has been linked to depression, and this study shows how it could play a part in symptoms such low motivation, focusing on negative experiences and pessimism in general. Researchers said that understanding the habenula could potentially help them develop new ways of treating depression.

Contact us at letters@time.com.