LONDON — A 50-year-old man who has been suffering headaches and strange smells has finally discovered the cause of his woes: a 1 cm (0.4 inch) tapeworm in his brain.

The parasite is thought to have been burrowing through his grey matter for more than four years, moving 5 cm (2 inches) from the right side to the left.

See also: What Fruits and Vegetables Would Look Like Under an MRI Scanner

The patient, from East Anglia, started suffering headaches and seizures in 2008. He was tested for syphilis, HIV and tuberculosis, as doctors struggled to diagnose the issue. An early MRI scan showed a cluster of rings in his right medial temporal lobe, which was revealed to be moving through his brain via subsequent scans.

Surgeons discovered the worm while carrying out a biopsy at Addenbrooke's Hospital in Cambridge, removed it surgically, and sent it to parasite experts for identification. Geneticists at the Wellcome Trust Sanger Institute found the worm to be a rare species of tapeworm known as Spirometra erinaceieuropaei.

A tapeworm discovered in a man's brain.

The discovery has offered a unique opportunity to study its DNA.

"For the first time, the genome of a rarely seen tapeworm has been sequenced," the institute said in a release. "The tapeworm has been reported only 300 times worldwide since 1953, and has never been seen before in the UK."

This particular worm can cause sparganosis, an inflammation of body tissue in response to the parasite. If that happens in the brain, it can cause seizures, memory loss and headaches.

"The worm's rarity means that little is known about its complex lifecycle and biology," the institute added. "However it is thought that people may be infected by accidentally consuming tiny infected crustaceans from lakes, eating raw meat from reptiles and amphibians or by using a raw frog poultice — a Chinese remedy to calm sore eyes."

The man, who was of Chinese descent, is thought to have picked up the parasite while on a visit to China.

"We did not expect to see an infection of this kind in the UK, but global travel means that unfamiliar parasites do sometimes appear," Effrossyni Gkrania-Klotsas, study author from the Department of Infectious Disease, Addenbrooke's NHS Trust, said in a release.