Brian Thomas leaves Swansea Crown Court after the verdict
It may make for funny stories, but in reality, sleepwalking can be the stuff of nightmares. And in a few tragic cases, parasomnia - the state of being both asleep and awake at the same time - can be lethal.
In Canada in 1987, Ken Parks went to bed as usual, but ended up getting out of bed in his sleep and driving 23km to his in-laws' house, where he killed his mother-in-law and injured his father-in-law.
He was tried and acquitted through the sleepwalking defence.
In the UK, the most high profile case of a sleepwalker who has killed is that of Brian Thomas.
Brian Thomas and his wife, both frequent sleepwalkers, were on a caravanning holiday in 2008 when a group of youths made them feel uncomfortable. They decided to move and park somewhere else for the night.
While sleeping, Mr Thomas believed that the youths had broken into his caravan. He thought he was fighting them off when in fact he was strangling his wife.
When he finally realised what he was doing, it was too late - his wife was dead.
Signs of a genuine sleepwalker include not remembering what's happened, or a lot of confused behaviour when awakening.
But the signs that a sleepwalking expert looks for in someone claiming it as a defence against violence, are not that simple.
Dr Chris Idzikowski, Director, Edinburgh Sleep Centre, was called as an expert witness for the defence in the Thomas case.
Unusually, Dr Idzikowski was allowed into Swansea prison to assess Thomas - an option not always open to people accused of crimes committed in their sleep.
Idzikowski monitored multiple facets of Thomas' sleep behaviour, including his breathing, brain waves, eye movement and limb movement while videoing him.
He was looking for the tell tale signs that a sleepwalker has, such as bursts of high brain activity before settling back down to slow wave sleep.
"One can always potentially have a situation where a sleepwalker wants to commit a crime, so if they know how to replicate the kind of things I'm looking for, they can actually commit a crime and then we'd have problems," Idzikowski explains.
The reason someone who, by day is gentle and kind, suddenly becomes aggravated or aggressive in their sleep is due to specific traits of the parts of the brain which are activated during sleepwalking.
These are difficult to measure but studies into the brain show that between wake and sleep, the state of consciousness and awareness oscillates very quickly, and it's during these changes between wakefulness and sleep that switching errors occur.
While sleepwalking, the prefrontal cortex - the area of the brain crucial for moral judgement and intent - is effectively offline.
Other parts of the brain can be hyper-activated during sleep. These include the limbic system and the amygdala.
These areas are deeply seated in the emotional control of waking experience and give dreams their depth and intensity.
Brian Thomas leaves court with his daughter after being cleared
This, coupled with the shutdown of rational thinking, leads to the bizarre nature of dreams.
In the Thomas case however, it wasn't simply up to the expert witnesses to determine whether the accused was a sleepwalker.
The law dictates that someone who is using the sleepwalking defence must be shown to be in an automatistic state.
Automatism is a legal defence when used to show a lack of a guilty mind. Because their brain renders them unaware of what they are doing, a person cannot be held responsible for their actions because they had no conscious knowledge of them.
There are two types of the condition: insane automatism and non-insane automatism.
Insane automatism really means there is a disease of the mind, and being found to have carried out a crime with insane automatism puts a defendant in the position of being subject to a hospital order.
Non-insane automatism requires the cause to be external to yourself, such as a blow to the head, or alcohol consumption.
But there is a mismatch between science and the law according to Dr Paul Reading, Consultant Neurologist, who has acted as an expert witness in sleepwalking cases.
"The legal arguments usually relate back to ancient statutes
and the whole issue of whether someone is acting under an insane or so-called non-insane automatism doesn't really equate with how we see the sleepwalking state these days."
One in 50 of us sleepwalk and the vast majority cause no harm to anyone.
"Anyone who sleepwalks can kill," says Dr Michael Cramer-Bornemann, sleep specialist at the Minnesota Regional Sleep Disorders Centre.
His research has also led him to one very personal conclusion, when asked if he would think twice about having a sleep walker as his partner.
"On the complexity of the behaviour, it does make one wonder
I would think twice."
This is hardly a surprise, given that Cramer-Bornemann is exposed daily to people's stories of committing crimes in their sleep.
But the consequences of high profile cases such as Brian Thomas has now led to Idzikowski seeing more people turning up at his sleep centre - frightened of what they might be capable of during the night.
Waking Up In The Dock will be broadcast on Radio 4 at 2100 GMT, Thursday 25 March or catch up on