Everyone knows about sleeping people who get up and go for a walk, but far less is heard about the rare cases of men who try to have sex in their sleep. One found himself in serious trouble, reports the BBC's Sally Abrahams.
When Sarah first met Tom at a friend's house, they immediately clicked. He was warm, chatty, with a gentle sense of humour that reminded her of her brother.
In the following weeks, they went on dates and spent more time together. Sometimes Sarah would stay over at Tom's flat. At other times, he would come to hers - writes bbc.com.
As they were getting to know each other, something happened while they were in bed one night that made Sarah feel uncomfortable. Tom began fondling her breasts, then quickly began thrusting at her groin in a crude, unsensual kind of way. It was early days in their relationship, and she decided not to say anything about it. "I guess I thought he was just being a bit frisky, so I just brushed it off. Which is probably what always happened in the past."
Gradually, they became closer, and settled into a routine of meals out, cinema and long walks together. They enjoyed each other's company and Sarah put aside her worries of that strange nocturnal episode.
But one night, after they'd been to a party, where they'd both been drinking, Sarah woke from a deep sleep to find Tom trying to penetrate her through her underwear.
It was painful and disturbing. The next day, she told him she'd had enough and wanted to end the relationship. But Tom's response surprised her. "He didn't know what I was talking about so he was quite defensive. And I was really angry having been woken up and him just completely oblivious to the whole thing," Sarah says.
Tom insisted he had no recollection at all of trying to have sex with Sarah that night. He was devastated by her account of what he had done and by the thought that he had hurt her.
Sarah didn't know what to think. Tom's crude attempt to have sex that night had been totally different from how he normally was; gentle, intimate, sensual. But she remembered something Tom had told her when they first met, before the relationship had even begun - that years ago, he had been convicted of raping his ex-partner, Karen, and sentenced to seven years in jail.
It had happened while he was on a visit to spend time with their young child. He and Karen had had a drink, watched a film and then shared a bed. Tom had fallen asleep almost immediately, but had been woken about 45 minutes later by Karen screaming and shouting at him: "What are you doing? This isn't you. This is not like you. This isn't you."
Confused, disorientated and shocked by her screaming, he grabbed his stuff and left her flat.
Between the point of drifting off to sleep and being shouted at by Karen, Tom said he had no recollection of anything at all.
Sarah wondered if Tom's behaviour then - apparently so out of character - might be related to his more recent attempt to force himself on her.
She thought back to other strange things that Tom did in his sleep - like the first time he stayed at hers. "He got up in the night, put his trousers on, told me he was leaving. No top on. Didn't remember anything about it in the morning," she says.
So Sarah encouraged Tom to see his GP. He was referred to the sleep clinic at Guy's and St Thomas' hospitals in London, where he spent a night with electrodes attached to his scalp to monitor his brain activity.
Image copyright SCIENCE PHOTO LIBRARY
What the doctors discovered was to have a dramatic impact on Tom's life.
"His brainwaves in his sleep study show something very unusual," says Dr Guy Leschziner, the consultant neurologist in charge of Tom's case.
"He appears to be awake and deeply asleep at the same time. During brief periods we can see the large slow brainwaves of deep sleep, with superimposed fast rhythms, suggesting simultaneously that he is awake."
People in this state can talk, walk, eat, cook, drive or even have sex, without clear consciousness or memoryDr Guy Leschziner, Guy's and St Thomas' hospitals
The findings of the sleep study together with Sarah's description of Tom's behaviour and his sleepwalking led Leschziner to diagnose Tom with a rare type of sleep disorder called sexsomnia.
Sexsomnia is related to sleepwalking, and to night terrors - when people exhibit nightmare-like symptoms even though they are not in the dreaming phase of sleep. All are forms of a sleep disorder known as "parasomnia", and usually occur in the first part of the night, during very deep sleep, says Prof Meir Kryger of Yale University.
"The person who sleepwalks will appear to be awake but they're really not. And we know this from monitoring their brainwaves," he says.
It's the parts of the brain controlling vision, movement and emotion that appear to be awake, says Guy Leschziner. "While areas of the brain involved in memory, decision-making and rational thinking appear to remain in deep sleep. So people in this state can talk, walk, eat, cook, drive or even have sex, without clear consciousness or memory."
So could Tom's sexsomnia diagnosis have a bearing on his rape conviction?
"Without having electrodes attached during the night of the rape, it's impossible to be sure whether it was as a result of Tom's sleep disorder," says Leschziner. "Tom was found guilty by a jury."
But in the last few years, there have been several court cases involving sleep disorders, including sexsomnia, which have resulted in acquittals. The law must decide whether someone has criminal intent or is acting as an automaton, without conscious awareness.
"There is a famous case in Toronto where a gentleman got into a car, drove a long distance and then murdered his mother-in-law and [assaulted his] father-in-law. And the jury decided that he was sleepwalking and he wasn't guilty," says Meir Kryger of Yale University.
"There was another similar case in Arizona a few years ago, where someone murdered his wife. And in that case he alleged that he was sleepwalking, but he was convicted."
Because defendants are never having their brainwaves measured when they carry out the attack it can be hard to know for sure whether they were conscious or not, says Mike Kopelman, emeritus professor of neuropsychiatry at King's College London.
"If you find evidence of conscious deliberation, motivation or of recall, that rules out it having been an automatism," he says.