When Lydia Ruffles was 19, she suffered a migraine so bad that she remembers, amid the delirium brought on by the pain, trying to drill a hole in her head with a corkscrew. The next time it happened was 10 years later, triggered by a virus she contracted while travelling in South America. This time, it wasn’t a one-off. Just before Ruffles came home, in summer 2010, she says she started to “feel weird. I put it down to living out of a backpack for four months. Within a couple of weeks, my balance totally went. Every time I got up, I felt like I was sliding off the planet. Then I started getting these incredible headaches.”

It would be five years before Ruffles would be diagnosed with vestibular migraine, a type of migraine that can cause vertigo, nausea and balance problems and can occur with or without headaches. Migraine affects about one in seven people, with varying rates of severity. It has no known cause, although it is thought to have a hereditary aspect. While many non-sufferers believe it to be simply a “bad headache”, in severe cases, it can be utterly debilitating. “The type of migraine I have, you get the severe head pain, but you also get really violent vertigo and dizziness, cognitive problems and sensory disturbances,” says Ruffles. “I get jumbled speech. For example, for some reason, I always call tunnels “sideways skyscrapers” or “sideways tubes”. My brain kind of knows what it is and reaches for an explanation.”

For Ruffles, like many sufferers, it starts with a migraine aura, which is a set of neurological symptoms that produce strange visual effects. “You can get zigzags in your vision, everything goes very surreal, sounds don’t sound like they should, they kind of echo. Smells become much more intense and sometimes unbearable. If it does turn into a headache, it’s like the most intense pain you can imagine and can last anything between three hours and a couple of days.” Sometimes the pain made her sick; all she could do was go into a dark room with some painkillers and try to sleep it off.

At the end of 2010, unable to work for several months, Ruffles had investigations – blood tests, MRI scans, x-rays – and a range of possible causes were considered, including multiple sclerosis and a brain haemorrhage. Eventually, one of her doctors concluded it was labyrinthitis, an inner-ear disorder, and she was prescribed medication to treat her balance problems. In 2014, it became worse than ever and she had to stop working. It was completely debilitating, says Ruffles. She couldn’t leave her flat and sometimes not even her bed – she recently worked out that she had spent more than 500 days in bed because of migraine.

Six months later, when she saw Dr Louisa Murdin at Guy’s hospital in London, she was finally given her diagnosis. “By that time, I had already had migraine for five years, not knowing what it was. I think I saw about 25 medical professionals – everything from a rheumatologist to ENT specialists to neurologists.”

At the worst of it, I couldn’t string a sentence together. I think writing was a rebellion against that Lydia Ruffles

Around the same time, she started writing her first book. “I think it was the relief of getting diagnosed and finally knowing what was wrong with me, but also not being well enough to go back to work, that writing became the lifeline,” she says. “I was doing it for escapism and to feel I had some kind of focus.” She had loved her job in communications and thrived on the long working hours. “To go from that to doing nothing, just sitting in my flat waiting for the next migraine or recovering from the last one, I just needed something. At the worst of it, I couldn’t string a sentence together or follow conversations and I think writing was a rebellion against that. It’s a way of closing the gap between what you’re experiencing and how other people interpret it, so it felt like taking control in some way.”

Ruffles started a creative writing course at the Faber Academy in London. “It’s not an exaggeration to say I only left my house to go to the hospital and to go to my writing class,” she says. She survived on supermarket deliveries and, financially, on sick pay from her employer, plus insurance that she had taken out. “Had it gone on any longer, I would have been in real trouble – and there are people who don’t have those measures in place, or have employers who are a lot less supportive.” Getting a book deal meant she didn’t have to go back to work in an office (the office environment, she discovered, with its artificial lighting, had triggered her migraine).

At Guy’s, she had vestibular rehabilitation therapy. “It’s basically like physiotherapy for your central nervous system and it retrains your brain to cope with information,” says Ruffles. “For example, in the basement of Guy’s, there’s a room with two disco balls in it. The idea is that you stare at the wall when the lights are going past to get used to that kind of visual stimulation.” Other exercises included going into a supermarket – brightly lit, busy – and walking up and down the aisles, turning her head from side to side. “It’s a good way to get a security guard to follow you,” she laughs.

Murdin reduced her reliance on painkillers, because the side-effects included headaches, and she was put on high doses of magnesium and riboflavin (vitamin B2). “But it was the brain rehab that got me back on my feet, literally and figuratively,” says Ruffles. She still experiences vertigo once or twice a month, but not so much head pain. “I basically had a migraine for a year, so compared with that it’s manageable.” The only medication she takes now is for dizziness. Lifestyle changes have helped – she doesn’t drink much alcohol, drinks lots of water, avoids artificial light and gets enough sleep.

Having a creative outlet has also helped, she says. The character in her first book for young adults, The Taste of Blue Light, suffered blackouts and memory loss; the protagonist of her new book, Colour Me In, has mental health problems. She is working on a third book and is about to embark on a master’s degree, which she says she wouldn’t have been able to do a few years ago.

“It’s really difficult for me to divorce my migraine from my creativity,” she says. “I think it still has a big influence on the way I use language. I often say I feel like each migraine collapses and rebuilds your reality and perception. It can make your brain feel things that you didn’t think it could feel and your mind gets sort of stretchy.” She experiences synaesthesia, the “merging” of the senses, in the migraine’s aura phase, where “words start having tastes and I can feel sounds. When I was really in the thick of it, it [happened] most of the time and it would get more pronounced, but the better I feel, the more it fades.” That, along with the creativity, is a rare welcome side-effect of a horrible condition – but she acknowledges that not everyone is able to turn migraine into an advantage. “For many people, it’s just debilitating.”

Colour Me In by Lydia Ruffles (Hodder, £12.99) is out now