Surgeons successfully removed a tapeworm from the brain of a British man who was suffering from headaches, seizures, memory issues and altered smell, Health24.com reported.

The 50-year-old unidentified man was suffering from an infection caused by a rare species of tapeworm called Spirometra erinaceieuropaei, which is typically found in China, Japan South Korea and Thailand, according to the report.

An infection can occur when a person eats undercooked frogs or snakes, uses frog meat for treating wounds, or drinks contaminated water.

While tape worms usually live in the gut, causing a patient to suffer weight loss and abdominal pain, some are able to travel to the eyes, spinal cord and brain.

In a study published in the journal Genome Biology, researchers sequenced the genome of the tapeworm after it was extracted from the man’s brain, and pinpointed genes that provide drug resistance in patients battling the infection.

“The infection is so rare worldwide and completely unexpected in this country that the patient was not diagnosed … until the worm was pulled out from the brain,” Hayley Bennett, lead study author said in a news release.

“By comparing the genome to other tapeworms we can see that certain gene families are expanded – these possibly underpin this worm’s success in a large variety of host species,” Bennet said. “The data gave us a first look at a whole group of tapeworms that have not been sequenced before.”

The research team believes the gene study may help improve drug treatment for patients who contract the rare infection, Health24.com reported.