Warning: Spoilers ahead for the end of Pixar’s new film Coco.

Pixar’s new animated movie Coco follows a boy named Miguel on an accidental journey through the Land of the Dead. He befriends a dead man named Hector who desperately wants his living daughter Coco to remember him. But Coco is very old, and her memory is fading. She spends her scenes sitting still, lost in thought, unable to identify members of her own family.

Even in a film where skeletons sing and dance in a neon afterlife, it’s a magical scene

When Miguel returns to the land of the living, he plays Coco a song her father wrote for her and sang to her often when she was a child. The music revives Coco, and she happily sings along with Miguel. She regains her ability to speak and recognize her daughter, and she speaks cogently to her gathered family about her childhood. Even in a film where skeletons sing and dance in a neon afterlife, it’s a magical scene in two ways: it’s moving and emotional, and it’s hard to accept as realistic. But while the degree of Coco’s recovery is unlikely, experts say Coco actually gets a lot of things right about memory and music.

Coco’s memory loss looks like the result of dementia, a series of brain changes that make it harder to think, remember, communicate, and function. Dementia affects 47 million people worldwide, and although the movie never names it specifically, Alzheimer’s disease is the most common cause for people over age 65. It’s a progressive disease that eats away at memory and self-identity. But there are hints that musical memories are spared, which has led to a debate about how common this is, and how music could be harnessed to help patients with dementia.

“In the healthy brain, music is a very, very vivid way of reanimating memories,” says Jason Warren, a professor of neurology at University College London. “But it’s not clear in dementia when you have a damaged system, whether it would bring back reminiscence and familiarity of the experience, or whether it would actually bring back the details.”

“If you would just start singing children’s songs with her, she would just start to sing along.”

There are hints from case reports and anecdotes that it could — like the story that inspired University of Amsterdam graduate student Joern-Henrik Jacobsen. Like Coco, the grandmother of Jacobsen’s partner had serious dementia and could barely recognize her family, Jacobsen says. But she could remember songs. “If you would just start singing children’s songs with her, she would just start to sing along,” he says.

A few small observational studies back up Jacobsen’s experience. One case report describes a piano player with Alzheimer’s who could finish a song if someone started it for him. But other “name-that-tune”-style studies designed to figure out whether Alzheimer’s patients could still remember music have had mixed results. That may be in part because the disease can make it harder for people to remember a song’s name, even if the melody is familiar.

“The Pixar plot probably has a grain of scientific truth.”

There’s another challenge, too: there are multiple types of musical memory, and not all studies investigate the same one. There’s the memory of events from your life: a kind of mental time-travel back to important moments, like a specific recital or concert. There are also more general memories that make up a person’s self-knowledge, like when Coco recalls that she used to sing that particular song with her father. And there are also motor memories about how to perform certain tasks, like, in Coco’s case, singing a song. That’s the part of Coco’s memory that Warren thinks is most likely to be restored by music. “The Pixar plot probably has a grain of scientific truth,” he says.

That’s supported by Jacobsen’s brain-imaging research, published in 2015 in the journal Brain. The study’s findings are still early and correlative, but they suggest that brain regions involved in making predictions and planning a sequence of movements are important for music memory. These regions also appear relatively functional in patients with Alzheimer’s, the study says. “That makes a lot of sense if you think about a piece of music as some sort of sequence of movements,” Jacobsen says.

Coco’s recollection that she sang the song with her father is also borderline plausible, Warren says — memories of parents are powerful. But her renewed ability to speak and recognize her family members is less so. “It’s asking an awful lot of any stimulus, including music, to repair degenerating brain tissue,” he says. “It’s up against this enormous progression of disease.”

“You can see signs, sometimes faces changing, people smiling.”

Renaud La Joie, a postdoctoral scientist at the University of California San Francisco’s Memory and Aging Center, agrees. “They’re not going to recover language,” he says. But until there’s a cure, music therapy does seem to help boost patients’ moods, a recent study of studies called a metanalysis shows. “You can see signs, sometimes faces changing, people smiling,” La Joie says.

Coco’s clear happiness to be singing with her great-grandson is something Coco got very right. But La Joie appreciated one thing about the movie that’s more important than accuracy: it showed a person with dementia approaching the end of her life with dignity and surrounded by love. “I thought it was beautiful the way it was depicted in the movie, that she was being respected by her family,” La Joie says. “This is something we don’t get to see enough in media, or the movies.”