It may sound like the setup to a bad joke, but a medical journal has published a case about a young man who went to his doctor because he suffered severe headaches every time he watched porn.

The journal Archives of Sexual Behavior reported that the 24-year-old Indian software engineer would experience intense pain across his whole forehead every time he tried to watch a sex video over a period of two years, and the pain got so bad he had to stop watching.

His headache would first develop gradually, with the fist twinges of discomfort striking just five minutes after he started watching the film and the pain would climax to its most severe point within eight to 10 minutes, according to the neurologists who treated the man, a 24-year-old single man.

In fact the intensity of his pain was so explosive that it was often accompanied with nausea, vomiting or phonophobia, the fear of loud sounds or voices.

Doctors in New Delhi treating the man were mystified because the young software engineer was a healthy single man who had no history of headaches associated either with masturbation or with other sorts of sexual activity, no family history of migraines and had never had a head injury. His physical and neurological test results were also normal.

There are two types of "primary headache associated with sexual activity," and the man may have had the rarer type of pain that builds up slowly along with heightening sexual arousal, Dr. Amy Gelfand, a neurologist at the University of California, San Francisco School of Medicine said, according to Live Science.

"The more common type is a sudden and severe headache that occurs at orgasm," Gelfand said.

Gelfand added that the more sudden headache may more common because people may be more frightened by the timing of their headache and therefore more willing to bring them to medical attention.

Researchers are still perplexed by primary sexual headaches, and no one knows what causes them. Some researchers have suggested that muscle contractions in the neck and jaw during sex may trigger the headaches and others proposed that headaches occur because blood vessels in the head are abnormally sensitive to sexual activity.

Whatever the reason, Dr. Kuljeet Singh Anand writing in the journal attributed that man's headache to changes in the pain-sensing nerves in the face and jaw and with" pain sensitivity associated with a heightened emotional state associated with viewing pornography."

Doctors advised the Indian patient with 400mg of ibuprofen and 500mg of paracetamol half an hour before watching pornography, to which the man reported significant pain relief.

Experts say that sex-associated headaches affect one in 100 people at least once at some point in their lives, with men being particularly more susceptible to the condition.

Around half of the people who have them also experience migraines but researchers are still unsure how much migraines and sex-associated headaches are related to each other.