In 1978, a group of researchers in a laboratory at Queen's University in Canada clustered around a plexiglass box enclosing a treadmill … with a pigeon walking on it. The purpose behind this comical scene was to try and answer an age-old question: Why do pigeons bob their heads?

Head-bobbing is as much a feature of pigeons' identity as is their tendency to swarm us at the slightest suggestion that we might be harboring a snack. Bopping their heads as they stalk about pecking the ground for crumbs, these birds seem to be grooving to some secret beat, as if they're all attending a silent disco in the town square.

But what's the real purpose behind this seemingly ridiculous motion?

Related: Why Are There So Many Pigeons?

The 1978 treadmill experiment gave us the first crucial insights into that question. And the study overturned one major assumption in the process: Pigeons aren't actually bobbing their heads. Instead, they're pushing them forward.

When the researchers in that study reviewed slow-motion footage, they found that there were actually two main parts to a pigeon's head movement, which the scientists called a "thrust" and a "hold" phase.

"In the 'thrust' phase, the head is pushed forward, relative to the body by about 5 centimeters [2 inches]," explained Michael Land, a biologist at Sussex University in the United Kingdom who has studied eye movements in animals and humans. "This is followed by a 'hold' phase, during which the head is kept still in space, which means that it moves backwards relative to the forward-moving body."

What we see as a "bob" is actually the head sliding smoothly forward and then waiting for the body to catch up. We perceive it as a bob because the motion unfolds so rapidly.

"This happens on average five to eight times a second as a pigeon is walking," Aaron Blaisdell, a professor of psychology who studies animal cognition , including that of pigeons, at the University of California, Los Angeles, told Live Science. "That's fast enough that, for us, we don't process it as the actual event unfolds and our minds treat it like a bob."

So, all this time we've been ridiculing pigeons for their quirky gait, and it turns out we were just seeing it the wrong way. And the reason why pigeons practice this behavior, it turns out, is all about the way that these birds see the world .

Visual processing

The researchers in the landmark treadmill experiment discovered that if a pigeon's visual surroundings stayed relatively stationary around the bird as it strutted on the treadmill, the animal's head didn't bob. Through reverse logic, this led to the central discovery: Head-thrusting helps pigeons to stabilise their view of the moving world around them.

"Keeping the head still in space during the 'hold'' phases means that the image will not be blurred by motion," Land said.

In other words, a stationary head gives the bird a moment to visually process its surroundings while it waits for its moving body to catch up; it's like hitting pause on the motion for a fraction of a second. This tactic is useful because it "enables them to see potential food — and possibly, enemies," Land said.

If pigeons' heads moved at the same pace as their bodies, "they would have trouble keeping a stable image of the world on their retina," Blaisdell explained; the surrounding scene would swim by in a confusing blur.

Blaisdell also shared an endearing anecdote: During research in his own lab, when he picked up a pigeon and walked forward with it, the bird still bobbed its head, because the world was still moving around the pigeon even though the animal wasn't moving of its own accord.

Related: Pigeons Vanish in 'Birdmuda Triangle'

This visual trick isn't just a quirk of pigeon life. Humans do a version of this too, except that instead of moving our heads, we use rapid, jerky movements of our eyeballs to help fix our vision as we move through space.

"Our eyes don't move smoothly and continuously. They actually jump from one place to another," Blaisdell said. These individual movements are called saccades , "and once [the eye] reaches the end point of a saccade, it sticks for a short duration, long enough to stabilise the image of the world on the retina so that we can process it," he added.

In an extreme form, this is the flicking motion you see in someone's eyes as they watch the scene unfolding outside the window of a fast-moving train.

Pigeon's eyes can move around like ours, but the birds also have more-mobile heads than humans do, so it makes sense that they've evolved head-thrusting as a more effective vision-stabilizing tool.

Bob, bob, bobbin' along

Pigeons may be the best-known birds for this trait, but they aren't the only ones that seem to be grooving along to an internal beat. "Most ground-feeding birds do head-bob," Land said.

Chickens do it, as do birds like herons, storks and cranes. A heron lurches its head forward to pinpoint its prey, then brings its body in line with the impressively stationary head; this is the slow-motion version of what a pigeon is doing, Blaisdell said.

He also raised an interesting, and comical, idea. Birds are essentially modern-day dinosaurs, and they share much in common with their extinct dinosaur cousins. Recent discoveries have shown that many dinosaurs, even Tyrannosaurus rex , had feathers. "So, given the commonalities between modern birds and dinosaurs, I wonder if dinosaurs did head-bobbing, too?" Blaisdell said.

Of course, that's pure speculation, he cautioned. But it does leave us with the image of a T. rex, teeth bared, its head bopping wildly as it runs frantically about.