A man who was having seizures and headaches, among other symptoms, were the result of a one-centimeter long tapeworm living in his brain, a study finds. 

"This 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," study lead author Hayley Bennett, of the Wellcome Trust Sanger Institute in the United Kingdom, said in a journal news release. 

Tapeworms typically live in the gut, although there are other species of tapeworms that can travel into the eyes, spinal cord and brain, reported U.S. News & World Report

The species that got into the man's brain is called Spirometra erinaceieuropaei, which is a rare species most commonly found in China, Japan, South Korea and Thailand. Infection from the tapeworm occurs when a person consumes undercooked frogs or snakes, uses frog meat for treating wounds, or drinks contaminated water, according to U.S. News & World Report.

The infected man was a 50-year-old British man of Chinese ethnicity.

Scientists removed the tapeworm from the man's brain during surgery. 

Their findings were published in the journal Genome Biology on Friday. Researchers suggest that this gene study could lead to an improvement in drug treatment for those who have the parasite. 

"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," Bennett said to U.S. News & World Report. "The data gave us a first look at a whole group of tapeworms that have not been sequenced before."