In Head Trip, PopSci explores the relationship between our brains, our senses, and the strange things that happen in between.

I STILL REMEMBER what my great-grandmother smells like. Even though she passed more than a decade ago, I know her favorite perfume just as well as I recall every contour of her face. Her scent came back to me recently when my boyfriend came over after spending several hours sitting in a room where incense was burning. The smoky aromatic blend fused with his clothing, and memories of my great-grandmother flooded in when I hugged him. I felt warm, loved, and safe.

This experience is not unlike the familiar story of someone walking through a department store’s perfume aisle and remembering an ex-lover, or getting a sniff of hair spritz or oil that evokes flashbacks of getting their scalp greased by a trusted elder as a child. It’s similar to the shared fondness my boyfriend and I have for the smell of freshly flat-ironed tresses—a peculiar odor that comforts us because it spurs the memory of watching our respective mothers press their hair when we were children.

Smell, alongside taste, is one of the oldest of the five human senses, and it plays a critical role in helping us assess the safety of our environment. Humans have approximately 400 cell receptors for detecting smells, compared to the 35 taste receptors used to sense flavors.This primitive, protective adaptation is deeply intertwined with our emotional and cultural experiences due to its direct connection to the amygdala-hippocampal complex. That immediate neurological throughline to the emotional epicenter of our brain is part of why our retention of smells first encountered in childhood is so strong.

That direct physiological connection between our noses and our brain’s emotional processing center is one reason we categorize aromas using the same terminology we use to describe sentiments, such as comforting, heavy, pleasant, or nauseating. It also explains why anosmia, a condition that leads to a weak or nonexistent sense of smell, can result in mental trauma. “For a lot of people, the loss of food pleasure is absolutely devastating,” says John Hayes, director of the Sensory Evaluation Center at Penn State, noting that smell plays a significant role in how food tastes. “But for other people, the loss of that emotional connection to smell can lead to feeling isolated.”

Experiences that occur between the ages of 3 and 11 have a profound effect on a child’s emotional intelligence. So developing a poignant association with a particular smell is likely part of the imprinting process nearly all humans go through, says Mike McBeath, a cognitive psychologist at Arizona State University.

“You want to remember smells when you first encounter them as a kid to learn the structure of the world around you,” he explains. “These associations might be something that helps us recognize where home is.” Children are also still learning to control their emotions, which means they might experience extremes. When such a feeling is tied to scent exposure, it might ingrain the connection deeper in a child’s memory. While newborns can recognize only a few odors, a child’s sense of smell will sharpen up until age 8. Then it levels out until about 20 years of age, when it starts a slow decline that continues to intensify with age.

While individual experiences with scent vary wildly, the process for the memory association is by and large the same. The olfactory nerve is the shortest cranial nerve, with only two synapses separating it from the amygdala, the emotion-processing area of the brain, says McBeath. From there, a smell has to hop only three synapses to the hippocampus, the brain’s working memory region. Aromas hit the backs of our brains more quickly than visual or auditory sensations, which require more processing in the prefrontal cortex before reaching the hippocampus.

Your initial experiences of smelling your grandmother’s perfume or the grease rubbed into your scalp remain stored in your brain so you know how to react if you whiff that substance again. Though there is no concrete evidence, an imprinted memory of smells is thought to be evolutionarily advantageous. According to experts interviewed for this article, it does make sense that when you first encounter a smell, your brain identifies it as good or bad to avoid potential future dangers. “That’s one reason you can often have these very strong associations,” says Claire Cheetham, an assistant professor of neurobiology at the University of Pittsburgh.

While humans are more likely to have pleasant smell associations, this isn’t always the case. Smells can trigger negative reflexes or even symptoms of post-traumatic stress disorder. One example is spoiled food. The smell of it prevents you from wanting to put it in your mouth to begin with. Some emotional cues are hard-wired to certain smells, such as, again, the repulsive stench of toxins or the sour odor of spoiled food (because we’re born disliking the taste profile of sour food to protect us from eating it). This innate wiring, according to McBeath, is part of the reason utility companies add a rotten-egg smell to natural gas, since the sometimes-poisonous substance otherwise evades our senses. (Though the first odorization of natural gas began in the 1880s in Germany, the practice became widespread following a gas explosion caused by an undetected leak at a Texas school in 1937.)

But many smell cues are learned in a lifetime. Babies, for example, don’t inherently think poop smells terrible. Instead, they learn to be disgusted by it from the facial reactions their caregivers make while changing their diapers, explains Hayes.

“We’re always looking for these novel cues in the environment,” which is why a lot of our childhood memories are based on first smells, he says. “Our brain pairs that new novel sensory experience with whatever was happening at the time. Our body is trying to protect us by helping us learn how to navigate through the world.”

Read more PopSci+ stories.