Medical journal Epilepsy and Behaviour cites an interesting case study of a female patient who had the experience of changing sex when she had a seizure.

The patient had a small tumour, and when she had the experience of changing she also experienced other females around her transforming into men.

From MindHacks:
She experienced a sensation of dull nausea rising from the epigastrium [abdomen] with concomitant fear, sometimes also accompanied by déjà vu, in isolation, several times per week. Occasionally this developed into a complex alteration of perception, which she explained as follows: ”I’m no longer feeling to be a female. I have the impression to transform into a male. My voice, for example, sounds like a male voice that moment. One time, when I looked down to my arms during this episode, these looked like male arms including male hair growth.”

This particular kind of perceptual disturbance was not restricted to herself, but also characterized her perception of female persons nearby during the episode: “One time another woman, a friend of mine, was in the same room, I perceived also her as becoming a male person including changing sound of her voice.” After introduction of anticonvulsive treatment with carbamazepine, only the elementary simple-partial phenomena of epigastric aura and déjà vu persisted. Secondary generalized tonic–clonic seizures never occurred.

Sex change delusions like this have been reported before, but usually in longer-term psychoses in people with diagnoses like schizophrenia, rather than happening during a short-term effect of a seizure.

Even one of the most famous psychiatric patients in history - Daniel Schreber - reported sex change delusions. The 19th century German judge had written about his experience of insanity in his book Memoirs of My Nervous Illness.

Among his experiences, he describes how he believed his mind was attracting "rays" from God, giving him feminising sensations of "voluptuousness" which he noticed as female body changes.

Temporary sex change delusions have also been implanted using hypnosis in highly hypnotisable people in two studies that attempt to understand how the mind justifies a belief clearly contary to reality.

[via MindHacks]