Odds are you don’t look forward to spending time in a magnetic resonance imager–and with good reason. The clanging, coffin-like machine seems purpose-built for sensory assault. But you’re not Ninja, a 3-year-old pit-bull mix, who trots into a lab at Emory University in Atlanta, catches a glimpse of the MRI in which she’ll spend her morning and leaps happily onto the table.

Ninja is one of the few dogs in the world that have been trained to sit utterly still in an MRI (the little bits of hot dog she gets as rewards help) so that neuroscientist Gregory Berns can peer into her brain as it works. “What’s it like to be a dog?” Berns asks, a question that is both the focus of his work and the thrust of his next book. “No one can know with certainty. But I think our dogs are experiencing things very much the way we do.”

That is what we want to believe. Our love affair with dogs has been going on for 15,000 years, and there’s no sign that it’s flagging. About 44% of families in the U.S. include at least one dog, meaning a canine population of up to 80 million.

Most of the time, we give our dogs very good lives. We fancy that they understand us, and maybe they do: come home sad and they’ll nuzzle your hand. They don’t have language, but they communicate volumes–with their eyes, with their barks, with their entire expressive bodies. “Dogs pick up on all kinds of things,” says Juliane Kaminski, director of the Dog Cognition Centre at the University of Portsmouth, in England. “A system has developed in which both species–ours and theirs–attend to each other’s cues.”

That’s something we know intuitively, but science is pushing harder to understand it empirically. Canine-research facilities have been established around the world, in Hungary, Austria, Germany, Italy, Australia and elsewhere. In the U.S. alone, there are facilities at Duke, Tufts and Yale universities. The Association for Psychological Science (APS), which typically concerns itself with the well-being of humans, recently devoted an entire issue of its journal Current Directions in Psychological Science to the canine mind. The findings were often impressive: Dogs can count–sort of–learning to look at two boards with geometric shapes attached to them and choose the one that has more. They can read human faces–understanding the importance of using gaze to communicate and to direct our attention. They can excel at what is known as object permanence–understanding that when an object is out of sight, it has not vanished from existence. It takes humans a lot longer to learn such a basic truth of the world, which is why babies who toss food or a spoon from a high chair will so often not look down at the floor to try to find it.

Dogs may be better too than 3-to-4-year-old children at learning to ignore bad instructions. In a Yale study not reported in the APS journal, dogs and small children were given a box and taught to turn a lever to open the lid and get a treat. When the lever was rigged so that it was no longer needed, the dogs learned to ignore it and simply open the box. The children continued to turn the useless thing all the same. If dogs can beat us at this one small task, what other gifts may they be hiding?

A dog’s behavioral software is ultimately determined by the power of the hardware, and that means the brain. As with all animals, one of the most important determinants of brainpower is size–specifically, the size of the brain relative to the size of the body. By this measure, the human brain is huge, about one-fiftieth the mass of the average human body.

Compared with humans and their 1:50 ratio, horses are dullards, at 1:600, and lions are little better at 1:550. Dogs are comparative scholars, weighing in at an impressive 1:125–a ratio that holds across all breeds of dog, from the Chihuahua to the English mastiff. All the same, a brain that makes you a genius in the animal world is not much in the human one. Berns keeps the preserved brain of an adult German shepherd in his lab, and it starkly makes that point: the brain is the size of a tangerine. “Dog brains just don’t have the real estate to do the things ours do,” he says.

While the sizes of the two brains differ, the structures are strikingly similar. Over the past several years, Berns and his team have used that similarity to good effect. Much of their MRI work has focused on the part of the brain known as the striatum. Rich in dopamine, the striatum mediates reward, pleasure and expectation–three pillars of a dog’s world.

During Ninja’s recent visit, the experiment involved determining how quickly she would learn to expect a food reward after being exposed to one of two smells. With the scanner running, a lab assistant released intermittent puffs of either isoamyl, a chemical that smells faintly like nail-polish remover, or hexanol, a carbon molecule that is detectable in grass clippings. After each puff of isoamyl, Ninja was given a hot-dog treat; after the hexanol, she’d get nothing.

Are you a dog or cat owner? Join PetHero to get 25% vet bill discounts, toys and treats, and more!

Over the course of the test, the MRI looked for upticks in electrical activity in the striatum that would indicate increased anticipation after smelling the isoamyl. Analytic software would have to determine the answer since the naked eye could not pick out such small fluctuations, but Ninja offered clues that she had learned fast. After hopping down from the scanner, she was presented with two cups in the middle of a room, each containing one of the two chemicals. She trotted straight to the one with isoamyl.

Associating a smell with a treat is basic stuff, but Berns has used his MRI to probe more sophisticated parts of dogs’ cognitive prowess: how they recognize the faces of humans and other dogs; how they recognize voices and words; even how they experience jealousy–when a treat was fed in pantomime to a dog mannequin. It’s those questions about a dog’s personality–does it love? does it empathize? is it loyal?–that most intrigue humans.

Investigators at the Messerli Research Institute in Vienna have recently tested the ability of dogs to behave prosocially–make an effort to help another dog when there is no reward in it for them. In the experiment, two dogs were placed in side-by-side cages, and one was trained to pull a lever that would deliver food to the other. The first dog got nothing and yet was usually happy to pull the lever all the same–provided the dog on the other side was a playmate. Unknown dogs were less likely to get the same treatment.

Studies of the many ways dogs are said to come to the aid of humans have produced less positive results. There is no end of anecdotal evidence of the phenomenon: dogs that run for help when their owners are injured, dogs that bark to alert the family to a fire, dogs that know when you’re sad and nuzzle to offer comfort.

Lovely–and maybe hooey. “Your dog may notice something’s amiss when you’re sad,” says Kaminski, “but the message they’re sending when they nuzzle may be ‘You’re acting weird, and that scares me.'” As for dogs that bark when there’s a fire in the house? “They might just have been frightened,” says developmental psychologist William Roberts of Ontario’s Western University.

In one study Roberts and a colleague conducted, an owner walked her dog across a field and then fell to the ground, feigning a heart attack. Two other humans were seated nearby, pretending to be reading. The owner lay still for six minutes, and over repeated trials with different human and animal subjects, not a single dog sought help.

Roberts does not deny the truth of occasional stories of dogs that do seek help. But he thinks they’re the exceptions. The majority of cases in which dogs do nothing “don’t get reported because they are not interesting or unexpected.”

If that’s true, it leaves dogs as little more than, well, cats: amiable freeloaders on the human gravy train. But such a conclusion shortchanges them–by a lot.

Start with what we’re learning about their intellectual octane, especially in terms of what’s known as theory of mind, the ability to understand that humans and other animals have knowledge different from their own. The ability of dogs to follow pointing, and to do so innately, has generated a lot of interested in recent years. It doesn’t seem like much of a skill, except when you consider that so many other animals make no sense of the gesture. The dog knows that the hand is used to indicate something else.

“When two humans do that, they take into account the common ground–a communicative context in which all this makes sense,” says Kaminski. The same is true between dogs and humans.

Not all canine researchers are sold on the significance of all of this. Behavioral scientist Clive Wynne of Arizona State University cites numerous species–including dolphins, elephants and even bats–that learn the meaning of pointing if they’ve had sufficient exposure to human beings. “It’s simply day-to-day experience with humans using their limbs to deliver things that matter,” he says.

The canine understanding of object permanence is less open to dispute. Dogs perform well on so-called visible-displacement tasks: when they watch an object being placed in one of several containers and are then allowed to look for it, they know which container to investigate first. Dogs also master invisible displacement, in which, say, a toy is placed in a container, the container is moved behind a screen and then brought back out, but the toy is no longer in it. Some dogs follow that chain of events, rightly concluding that if they go behind the barrier they will probably find the toy.

In a 2013 study, behavioral psychologist Thomas Zentall of the University of Kentucky also found that dogs are capable of understanding that not only is the existence of objects permanent but so are the characteristics. When a dog biscuit or other item of interest was carried behind a barrier and then carried back out, the dogs would give it a glance as it reappeared. But if it was secretly replaced by a larger or smaller version of the same object or one that had changed in color, they would stare much longer. The conclusion: a two-inch dog biscuit should remain two inches and a yellow ball should remain yellow, and dogs understand that.

What, however, does all this say about dogs’ emotional experience of the world? They exhibit what seems unmistakably to be joy–in the jumping, yipping thrill they show when family members come home after a long absence. That may even suggest that they have an awareness not just of the past and the future but also of the rate at which time passes. Closed-circuit cameras show that they seem to prepare as the time comes for humans who have been out all day to return, stirring from a nap, checking the front door, becoming restless and excited.

A sense of time as a linear thing–that the current state is not the only state–is an abstraction that human babies take a long time to learn, which partly explains tantrums. A present moment without a cookie means an eternity without cookies.

Dogs may even teach us something about a common human problem: lack of willpower. Research has attributed this to what is known as ego depletion, with self-control failing over time the same way an overworked muscle does. In studies conducted in 2010 and ’15, investigators found that self-discipline in dogs breaks down the same way ours does. In one experiment, dogs that had been required to perform a 10-minute sit-and-stay exercise were less likely to complete a puzzle task given to them next than dogs that had spent the same 10 minutes doing what they pleased.

The reason may be depletion of glucose in the prefrontal cortex. Dogs given glucose before the second task stayed with it longer after a sit-and-stay period. Dosing up on sugary drinks is not the way to improve self-discipline, but the research does show us one more thing we share with our favorite nonhuman species.

Ultimately, though, our curiosity about dogs will always be driven mostly by our love for dogs. Berns believes that it was juveniles on both sides of the human-dog divide that were responsible for initiating the interspecies bond. Wolf pups would be the ones likeliest to approach and appeal to early nomadic humans; and girls and boys–then and now–are the humans who love puppies most. Dogs are like us in their joy and empathy and inexhaustible curiosity, and we–at least when we’re in their presence–become more like them. We are both better species for our very long union.

This appears in the May 22, 2017 issue of TIME.

Write to Jeffrey Kluger at jeffrey.kluger@time.com.