A number of questions may come to mind when picking shellfish from a menu. Is it safe to eat? How was it sourced? But not many of us would think to ask: did it die a painful death?

Perhaps we should. New research published in the Journal of Experimental Biology shows that crabs can learn to avoid electric shocks, picking a different shelter to escape harm. Study author Prof Bob Elwood from Queen's University Belfast claims this shows they are not just reacting reflexively, but are experiencing some form of pain.

The findings will fuel the debate over whether crustaceans – which include edible crabs, prawns and lobsters – feel pain.

The work with shore crabs, a species related to edible crabs, tested whether they were able to discriminate between one of two shelters and show more than just a reflex reaction to an electric shock. When 90 crabs were placed individually into a brightly lit tank they scuttled off towards one of two dark shelters at either end. The crabs naturally seek out dark crevices to avoid predators.

After making their choice, half were randomly chosen to receive a small electric shock on their legs, causing them to run back out into the light.

On the second attempt, most of the crabs, shocked or not, headed for the same shelter they had picked before. Those animals that had been shocked first time around received a second shock if they chose the same hideaway.

But on the third attempt, the majority of the shocked crabs avoided their previously preferred shelter in favour of the other, less shocking shelter. This rapid learning to discriminate between shelters to avoid harm meets Elwood's criterion for pain perception, showing that something more than just a reflex is going on.

Prof Elwood tells me he decided to do the experiment after a well known chef asked him whether crustaceans experience pain. Billions of crustaceans are prepared by the food industry each year and are often killed and prepared with no consideration given to whether or not they feel pain.

"You have the most extraordinary treatment of these animals … even if there's a slight chance they feel pain, I feel we should start attending to that now," said Elwood, highlighting the processes used by the food industry to kill the animals.

"Crabs in some fisheries around the world have their claws just torn off and the live animals are thrown back into the sea – because it's only the claws that are required by fisherman.

"You have lobsters being processed, prawns that are being processed live by the front end, the head and the thorax being torn off. And the head with the brain will carrying on being a viable nervous system and will continue to go on like that for an hour or so."

The findings add to a polarised field of research in which many have argued that animals with a simpler nervous system, as is the case with crustaceans, are unable to experience pain.

"It looks to me that the authors have demonstrated that crabs move away from a potentially damaging stimulus," said Dr Magnus Johnson, a lecturer in environmental marine biology at the University of Hull. "That doesn't necessarily mean that they sense 'pain'."

Prof Paul Hart, emeritus professor of biology at the University of Leicester agreed. "I don't think you can really say scientifically that animals, like a crab, can be aware of a sensation that we know as pain … we just don't know."

When it comes to cooking that crab for your dinner, however, it may be best to give it the benefit of the doubt.