One day several years ago Valorie Salimpoor took a drive that would change the course of her life. She was at the peak of what she now calls her “quarter-life crisis,” not knowing what kind of career she wanted or how she might use her undergraduate neuroscience training. Hoping an outing might clear her head, that day she jumped in her car and switched on the radio. She heard the charging tempo and jaunty, teasing violin of Johannes Brahms’s Hungarian Dance No. 5.

“This piece of music came on, and something just happened,” Salimpoor recalls. “I just felt this rush of emotion come through me. It was so intense.” She pulled over to the side of the street so she could concentrate on the song and the pleasure it gave her.

When the song was over, Salimpoor’s mind raced with questions. “I was thinking, wow, what just happened? A few minutes ago I was so depressed, and now I’m euphoric,” she says. “I decided that I had to figure out how this happened — that that’s what I’m going to do with the rest of my life.”

Music moves people of all cultures, in a way that doesn’t seem to happen with other animals. Nobody really understands why listening to music — which, unlike sex or food, has no intrinsic value — can trigger such profoundly rewarding experiences. Salimpoor and other neuroscientists are trying to figure it out with the help of brain scanners.

Yesterday, for example, researchers from Stanford reported that when listening to a new piece of classical music, different people show the same patterns of synchronized activity in several brain areas, suggesting some level of universal experience. But obviously no one’s experience is exactly the same. In today’s issue of Science, Salimpoor’s group reports that when you listen to a song for the first time, the strength of certain neural connections can predict how much you like the music, and that these preferences are guided by what you’ve heard and enjoyed in the past.

After Salimpoor had the car epiphany, she rushed home to her computer and Googled “music and the brain.” That led her to graduate school at McGill University, working in the lab of neuroscientist Robert Zatorre.

A few years ago, Salimpoor and Zatorre performed another type of brain scanning experiment in which participants listened to music that gave them goosebumps or chills. The researchers then injected them with a radioactive tracer that binds to the receptors of dopamine, a chemical that’s involved in motivation and reward. With this technique, called positron emission tomography or PET, the researchers showed that 15 minutes after participants listened to their favorite song, their brains flooded with dopamine.

The dopamine system is old, evolutionarily speaking, and is active in many animals during sex and eating. “But animals don’t get intense pleasures to music,” Salimpoor says. “So we knew there had to be a lot more to it.”

In the new experiment, the researchers used functional magnetic resonance imaging (fMRI) to track real-time brain activity as participants listened to the first 30 seconds of 60 unfamiliar songs. To quantify how much they liked the music, participants were given the chance to buy the full version of each song — with their own money! — using a computer program resembling iTunes. The program was set up like an auction, so participants would choose how much they were willing to spend on the song, with bids ranging from $0 to $2.

You can imagine how tricky it was to design this experiment. All of the participants had to listen to the same set of never-heard-before songs, and yet, in order to get enough useable data, there had to be a reasonable chance that they would like some of the songs enough to buy them.

Salimpoor began by giving 126 volunteers comprehensive surveys about their musical preferences. “We asked them to list all of the music they listen to, everything they like, everything they’ve ever bought,” Salimpoor says. She ultimately scanned 19 volunteers who had indicated similar preferences, mostly electronic and indie music. “In Montreal there’s a big indie scene,” she says.

To create the list of unfamiliar songs, Salimpoor first looked at songs and artists that showed up on many of the volunteers’ surveys. She plugged those choices into musical recommendation programs, such as Pandora and iTunes, to find similar but less well-known selections. She also asked people who worked at local music stores what new songs they’d recommend in those genres.

Here’s a sampling of 3 songs from the final list of 60:

The brain scans highlighted the nucleus accumbens, often referred to as the brain’s ‘pleasure center’, a deep region of the brain that connects to dopamine neurons and is activated during eating, gambling and sex. It turns out that connections between the nucleus accumbens and several other brain areas could predict how much a participant was willing to spend on a given song. Those areas included the amygdala, which is involved in processing emotion, the hippocampus, which is important for learning and memory, and the ventromedial prefrontal cortex, which is involved in decision-making.

The data are “compelling,” especially because the study objectively quantified the participants’ preferences, notes Thalia Wheatley, a psychology professor at Dartmouth College who has studied links between music, motion and emotion. The emphasis on connectivity between regions, rather than any particular region by itself, is also intriguing, she says. “Cortical activity alone does not predict bid value. Hooking up the temporal and evaluative processing in the cortex with the (more primitive) reward areas appears to be the key.”

So why is it that one person might spend $2 on a song while another pans it? Salimpoor says it all depends on past musical experiences. “Depending on what styles youre used to — Eastern, Western, jazz, heavy metal, pop — all of these have very different rules they follow, and they’re all implicitly recorded in your brain,” she says. “Whether you realize it or not, every time you’re listening to music, you’re constantly activating these templates that you have.”

Using those musical memory templates, the nucleus accumbens then acts as a prediction machine, she says. It predicts the reward that you’ll feel from a given piece of music based on similar types of music you’ve heard before. If you like it better than predicted, it registers as intense pleasure. If you feel worse than predicted, you feel bored or disappointed.

“New music is presumably rewarding not only because it fits implicitly learned patterns but because it deviates from those patterns, however slightly,” Wheatley says. But this finding leads to new questions. “It just made me wonder whether people have different preferences or tolerances for how much a new song deviates from the well-worn path of previously heard music structures.”

There are lots of other questions for future studies to probe. How does our brain make those musical templates? How long do we have to listen to a song before we know whether we like it? Why did my sister and I have such drastically different musical tastes growing up, even though our exposures were pretty much the same?

But for now the study has given Salimpoor a new way to think about what happened to her that day in the car. “That day, it all seemed like such a big mystery — what the heck is happening in my brain?” she says. But if she heard the song again today, she’d be able to tell a reasonable story of her mind’s workings.

“I’d be like, oh my god I just released dopamine, and my nucleus accumbens is now communicating with the superior temporal gyrus, and that’s pulling up some other memories of when I was 12 and playing the violin,” she says, laughing. “And then that’s linking it to my visual centers, so I can imagine this perfect synchronized orchestra and me playing a violin in there. And I’d be predicting the next sounds from each instrument in the orchestra, and the whole orchestra, so it’s a local and global prediciton going on at the same time.”