Earlier this year Alaska became the first state to pass a law requiring the consideration of pets’ well being in custody disputes. Seeing that pets, especially dogs, are commonly treated as family members, this may seem like a long overdue change. But it raises the difficult question of determining what’s best for an animal: How do we know what a pet wants?

In 2013 Shannon Travis and Trisha Murray appeared in the New York State Supreme Court. The couple had been married for less than a year when they decided to divorce. While Travis was away on business, Murray moved out of their New York City apartment. She took some furniture—and she took Joey, their dachshund.

According to court records, Travis believed Joey belonged to her because she was the one who bought him from a pet store. Murray disagreed, arguing Joey belonged to her because, among other reasons, it was in the dog’s best interests. She gave the example that Joey slept next to her side of the bed. With little precedent to go on, the court had to decide whether it made sense to hold a custody hearing for a dog.

Joey was granted his hearing.

It is one thing to adjudicate the division of property but it is an entirely different matter to consider the interests of a dog. If a dog is property, as the law at the time said, then it could have its own interests no more than a piece of furniture could. That would be like saying a chair cared about which room it was placed in. To figure out what is in the best interests of a dog, you would have to know what it’s like to be a dog.

Forty years ago the philosopher Thomas Nagel said this was impossible because animals are just too different from us. (Specifically, he was talking about a bat, but the problem is the same.) His real target, though, was neuroscience. He argued that knowledge of how an animal’s brain worked wouldn’t get us any closer to what it was like to be that animal. His essay cast a long shadow over neuroscience.

When Nagel wrote his essay, the tools of modern neuroscience did not exist. Indeed, the only way we had access to mental states was by observing behavior or, in the case of humans, asking what a person was thinking or experiencing. Both are obviously imperfect measures of mental states. The human primacy of language had caused many researchers to abandon the possibility of knowing what an animal experienced and focus instead on observable behavior. Because a dog can’t say to himself, “I’m scared,” some scientists had even taken to redefining the most-studied animal emotion— fear—as a behavioral program that an animal implemented to avoid something painful. But this was a step backward toward a Cartesian view of animals as automatons—a view that closed off any possibility of determining what was in a dog’s best interest as the Alaskan law now required.

But our understanding of the brain has advanced a great deal since Nagel’s essay. Tools like optogenetics, in which researchers can control neurons with light, and noninvasive technologies like MRI, my preferred instrument, have begun to connect the dots between brain structure and function and how this relates to mental experiences. If these techniques work for humans, there is no reason why similar approaches couldn’t be used to decode animal states of mind.

So, five years ago my colleagues and I began a project to train dogs to willingly and happily go inside an MRI scanner so we could better understand how their brains worked. What started with two dogs, including my adopted terrier, Callie, eventually grew to a cohort of 90 “MRI-dogs” that have participated in a dozen different experiments.

Now, after hundreds of scan sessions, I have to disagree with the Cartesians and the Nagelians. Not only can we have a pretty good idea of what it’s like to be a dog, we can use this technology to know what a dog really wants— sometimes better than we can by observing their behavior.

In one of our recent experiments we set out to determine whether dogs’ apparent love of their humans was driven entirely by the provision of food or whether dogs valued the relationship for purely social reasons. While they were in the MRI we presented the dogs with two objects, which served as visual cues. One object meant they would receive a piece of food on the end of a stick, the other telegraphed that their human would pop into view and say something like, “Yay, good girl!”

We focused on an area of the brain called the caudate nucleus. In humans the caudate is particularly active during the anticipation of something pleasurable. More generally, the caudate links motivational states to motor systems so animals can get what they want. In dozens of studies, human caudate activity has been correlated with individual preferences.

We did the same thing with dogs, using their caudates to measure their relative preference for food or praise. In the 15 dogs who participated we found a range of responses. Measured by their brain activity, two dogs really liked food whereas four preferred human praise and attention. (One was appropriately named Velcro.) But most of the dogs liked both—at least their brains did.

We also measured the dogs’ preferences by offering them a choice outside the scanner. In a large room we set up a “V”-maze with the owner at the end of one arm and a food bowl at the end of the other. The dogs ran the maze 20 times, and we analyzed the sequence of their choices. Dogs whose brains were more active to praise tended to repeatedly go to their owners whereas food-loving dogs’ brains stuck with the chow. But most interesting were the dogs whose brains like both food and praise. These dogs tended to sample back and forth between food and owner in the maze.

This is the problem with relying solely on behavior to intuit what a dog wants. Like people, they may have competing preferences. Placed in a situation and forced to choose one or the other, they may adopt any number of strategies that have nothing to do with their true preferences. They may go to the largest thing; they may always go left or right; or they may just stick with the first thing they chose even if the other option might be better. The MRI data opened a window into the dogs’ minds without forcing them to make a choice.

For all of these reasons, judges faced with determining pet custody should resist the temptation to simply let the dog choose. One can easily imagine a dog choosing an abusive owner out of fear or going to the person with brighter clothing. In Travis v. Murray the court was aware of the potential of dog-MRI but did not think it practical. But now, after having trained almost a hundred dogs, we see it is not so hard for many dogs to go in an MRI scanner, and the window into their brains tells us things that their behavior does not.

If this had been Joey’s brain, and instead of food versus praise it had been his two owners, his brain might have preferred joint custody. Alas, he never had his day in court. The humans settled his situation before his hearing.