SACRAMENTO (CBS13) — A Sacramento State student had a close call after doctors found a tapeworm in his brain.

“I’m just happy that I’m here right now, because if I would’ve went in a half hour later, I definitely wouldn’t be here,” Luis Ortiz said.

His brain is still recovering after doctors performed a surgery for a diagnosis no one would have expected. He went in to see a doctor after he experienced headaches and vomiting.

“They put this camera in to see what was going on, and that’s when they found out, ‘Oh yeah you have this parasite in your head,’” he said.

The particular parasite was a tapeworm inside a cyst inside his brain.

“They’re like, ‘Hey, you have this parasite in your head. And we’re going to operate and we’re going to have to do it soon, otherwise you could probably die,’” he said.

Doctors at Napa’s Queen of the Valley Medical Center say the cyst around the worm was blocking water from Ortiz’s brain. The tapeworm may have been in contaminated food Luis ate.

“I have no idea where I got it from,” he said. “Now that it’s kind of over, it definitely gave me a new perspective on life.”

It’s an unusual survival story for a Sacramento State student whose mind is now on the mend after a worm worked its way into his brain.

“The doctors told me if I would have gotten there a little bit later I probably wouldn’t have made it,” he said.

There are six types of tapeworms known to infect humans, usually identified by the animal they come from. People typically get them from undercooked meat, or by eating food prepared by someone who is infected.

The pork tapeworm that infected Ortiz can travel to the brain. The Centers For Disease Control and Prevention says there are about 1,000 hospitalizations for brain infections caused by the pork tapeworm.