

Discover more from decodebytes
Night of the living brain fog dead, or how I hacked myself better thanks to open source software.
I had felt tired for such a long time, that I had normalised the whole affair.
Every night, the same routine would unfold. I would awaken multiple times for no conceivable reason, feeling irritable and restless, or my compassionate and frequently anxious wife, would rouse me with the words, "WAKE UP, YOU'RE NOT BREATHING!"
The sole respite I had was during the first two hours of each night when, utterly drained and exhausted, I would fall into a slumber within minutes of my head touching the pillow. This relief, however, was short-lived, as if orchestrated, I would find myself awake and frustrated two hours later. The remainder of the night was a drawn-out affair devoid of any deep, healing sleep.
During the day, I would cope by consuming copious amounts of coffee between 6 a.m. and 12 p.m. to sustain myself through the workday. I was akin to a high-functioning alcoholic, but my affliction was rooted in severe sleep deprivation.
I was operating on around 2-3 hours of sleep on average per night. People that know me through work will find this surprising, but that is really down to me managing the situation as best as I could. A lot of people suffering with an unresolvable condition, just learn to cope and do the best with what they can. Human’s are remarkably resilient and able to debug workarounds to their ailments. For anyone that knows me, my pastime is running multi day events like the Spine Race, where sleep deprivation, alongside adverse weather conditions, is one of the main factors that forces a withdrawal of runners from the race. I had become very accustomed to running on very little sleep.
My job is that of a software engineer, which made this whole affair even more messy. My brain is the tool of my trade and mine was blunt. Quite often I would find myself speaking at meetings, tech events or with the media, while facing a brain enshrouded in fog. I would reach inside my mind for thoughts to articulate, but all I could find was a hazy barren mindscape. I would muddle my way through with umms and ahhs, or try to look deep in thought while I waited for the miracle to happen, when my speech would find its bearing again.
I accumulated a laundry list of attempts to try and resolve the situation, including lots of sleep hygiene ‘hacks’.
Black out curtains.
No screens after 7pm and all my devices run blue light filters.
Coffee cut off at 12pm
An Army of various supplements; Magnesium Glycinate / Malate, L Theanine, Vitamin D2 / B-complex, N-Acetyl Cysteine, Lions Mane, Ashwagandha etc.
Herbal sleep teas (with valerian extract)
Full blood panel
Everything looked good with the panel. I also had no trace of heart disease, diabetes, high cholesterol etc. In the words of my Doctor I was ‘in dam good shape’.
Along with the sleep deprivation, came anxiety and depression (common allies of poor sleep) and a less than ideal immune system which made me very prone to colds and viruses. I was considering going to my Doctor to explore perhaps an anti-depressant.
Around four months back, I had a recommended video on my YouTube dashboard “The Effects of Untreated Sleep Apnea”. I figure it was offered up from my bazillions of searches around ‘sleep disorder’
The risks were clear, heart failure being the most common. Generally not good! An early death was on the cards, and a sleep deprived journey to get there.
This made me research more, rabbit hole’ing down various subreddits or old phpBoards reading the experiences of others. The same ailments were listed time and time again, waking up for no reason, incredibly poor sleep, depression and anxiety and a suppressed immune system (easily catch colds / viruses). The only differentiating factor between most sufferers and me was weight. I am quite lean through the running, while many others diagnosed with sleep apnea are obese (with some solving the issue by dropping weight).
I right away realised I needed to get tested. I bought a Withings Sleep Analyser on next day prime. These USB powered devices sit under your bed, and by means of inflated pockets of air, coupled with some diodes and sensors, tracks your movements, monitors your heartbeat and snoring
The device is also said to be very accurate at discovering sleep apnea.
The next morning after my first night being measured by the machine. I got the results:
The device measured an average AHI rate of 43 events per hour. This means 43 times and hour on average, I would cease to breath until I awoke gasping for air. I was actually happy to see this, as finally I had found out what was wrong with me. I will admit, I am bit of a stern bloke, but I shed a little tear. Now to try and fix it!
I made an appointment with a private sleep specialist. They sent me out a home test device, it resembled a watch with a finger probe. This device measures heart rate, oximetry, actigraphy, body position, snoring, and chest motion and can be quite indicative of sleep apnea diagnosis.
The results came back. I was diagnosed with severe sleep apnea. A double confirmation!
The recommendation was to purchase a device called CPAP.
CPAP (Continuous Positive Airway Pressure) is a medical device used to treat sleep apnea. It delivers a steady stream of air through a mask to keep the airway open, preventing pauses in breathing and improving sleep quality. It’s not a pretty sight to behold as the advertisements models illustrate well. A lot of younger suffers fear what potential mates might make of their night time attire, but luckily this was no issue for me. I am happily married in a ‘worts ‘n’ all’ union with my wife of 14 years. I would have gone to bed dressed in a pink gimp suit, if it meant I might I have got a decent nights kip.
“I love you darling”, “snurff meh ughhh!’
The CPAP machine records data which would then be sent to my sleep technician. I could then pay for follow up consultations while they titrate the machine to work optimally for me.
In parallel to seeing the consultant, I had started to obsessively study sleep apnea and everything about the condition. I found out that the machine the consultants had offered to sell me, ‘locked out’ the data from the user. This meant I would have no way of seeing results for myself, instead I would to pay out £150 each time to get the consultant to analyse for me.
I then did what may have seemed a stupid thing to do (medical disclaimers apply here). I went and bought my own device. I had discovered a community online where sufferers of sleep apnea had developed their own open source licensed software called OSCAR. OSCAR is capable of processing and rendering the data from a CPAP machine to allow deep insight into many metrics related to sleep. Around OSCAR, a community also helped fellow sufferers to dial in the settings and get themselves on the path to have good quality, deep healing sleep again.
Being someone FOSS orientated this struck a cord with me. I went and bought a unit (resmed, autoset 10) which was capable of exporting the right format for OSCAR and not the proprietary device which would leave me locked out and at the mercy of others.
I went for a straight CPAP variety (or APAP to use the technical term), as originally recommended by the consultant (these machines come in different types, CPAP, APAP, VPAP, BiPAP etc).
The machine along with OSCAR would also give me even more insight into my condition, as the device would measure breath volume, pressure and a whole load of other useful metrics.
My first night on the machine was absolutely miserable. The mask felt horrible, pinched my nose and air kept farting out everywhere. My wife tapped out after an hour saying its like sleeping next to a vaccum cleaner. I lasted as long as I could and then pulled the thing off and flung it across the room. To add to the discomfort of the mask, my apnea was not resolved (albeit this was only one night). I woke up feeling like death warmed up.
The results of my first night, littered with apnea events
I did get some hugely useful insight though, once I popped the SDCard into my laptop and imported the results to OSCAR. A big majority of my events were ‘Clear Airway’ with barely a single ‘Obstructive Airway’ event.
Most sleep apnea sufferers have what is termed ‘OSA’, or obstructive sleep apnea. The airway becomes blocked and the patient cannot breath, so their nervous system jerks them awake. A whole night of this leads to a frazzled state of sleep deprivation and low levels of blood oxygenation. OSA is typical in patients of the more chunky nature, where the extra weight in the neck, crushes the airway.
Another type of Apnea is ‘Central Sleep Apnea’. CSA is a type of sleep apnea where the brain fails to signal the muscles to breathe during sleep. In this condition, the body makes little or no effort to breathe for brief periods, causing interruptions in sleep. Unlike obstructive sleep apnea, which is caused by physical blockages in the airway, central sleep apnea is a neurological disorder that affects the respiratory control center in the brain. You can’t just smash through the obstruction with a CPAP, it requires a more refined approach.
Homing in on my events, you can see the pattern here;
On average, every minute I would stop and not breath for approximately 20 seconds and the machine would record a Central Apnea event.
A forum user ‘Sleeprider’ immediately spotted this:
We relented with the CPAP for another week or so, but no dice. It was totally the wrong unit. Big love to Sleeprider for walking me through everything on a single forum thread.
It was recommended I instead get a device called an “ASV”, an adaptive servo-ventilator. An ASV is used to treat central or complex sleep apnea. It works by continuously monitoring a patient's breathing patterns during sleep and delivering customized pressures to help them maintain normal breathing rates. ASV uses algorithms to adjust the air pressure and breathing to match the patient's breathing needs in real-time. You can feel it working when you deliberately hold your breath, the thing ramps up and induces you to breath again.
I then began the hunt for an ASV unit. These were not available in the UK privately, they are only available on the UK’s National Health Service, which is currently on its arse from under funding. I am in the system for NHS treatment, but things are so bad that I have not even received an inital letter with a date for a test. It would likely take up to year for the NHS to treat me.
The other option would be to buy a used unit. This to me felt risky, I am going to plumb a machine into my lungs which someone else has been using for years. I spoke with others about this and my fears were lessened. The unit pumps air out to the recipient (and not vice-versa). With a change of filter and clean up with some alcohol, all should be fine. The only other issue is the unit could fail, but the software would pick up on this.
I eventually tracked down an “ASV”. It was an older model, but in good shape and had clearly been looked after and had been refurbished and run against some testing hardware for 24 hours.
My very own ASV, circa 2016. I have named her ‘Bessy’.
The results of my first night were amazingly good!
I achieved an AHI of 1.28!
1.x is very much in the normal range! Those few events recorded were hypopnea (shallow breathing) and likely just me adjusting to the guided ASV algorithm.
Keep in mind, untreated I was +40 for an AHI.
Best of all, look at this beautiful flow rate of my breathing! oh my gosh!
This nice regular pattern means my blood oxygenation is in the healthy mid 90’s, where as before I was dropping down into the low 80’s. The result is when I wake up, I now feel dozy and warm, and not in the midst of fight or flight and full of cortisol.
It’s still early for me.. As you can see from the main dashboard, there is a big gap in the middle of the night where I took the mask off, but I am becoming conditioned to having this thing on my face. I also feel much better already, but its going to take a few months to really recover.
The morale of the story, you need to sometimes tackle your own health and take matters into your own hands. Left to the advice of professionals I would have been stuck with the wrong machine and as said the National Health System have yet to even send me a letter, while they get drained of resources by our dysfunctional government.
I am grateful I was able to afford to take the risk and pay out a thousand pounds on equipment, many are not as fortunate and that makes me sad!
The information I have gathered has also enabled me to work with my own Doctor. They are going to run some heart checks, just to make sure I am all good there. Luckily I have a Doctor who is not to arrogant to think only someone qualified can have an opinion on someones health situation.
Last of all, of course. Viva la open source and communities coming together to resolve the wrong of closed systems, while providing some good old altruism in helping their fellow humans!
Open source has not only given me a career and some wonderful friends, but also given me the insight to help prevent what could easily have been a far to immature death.
I post this now, in the hope that it might reach others suffering with undiagnosed sleep apnea.
According to estimates from the American Academy of Sleep Medicine, it's believed that around 80% of people with moderate to severe sleep apnea are undiagnosed. A systematic review and meta-analysis of studies published in the European Respiratory Journal, found an estimated prevalence of sleep apnea in Europe is approximately 17%. Of these cases, it's estimated that around 75% are undiagnosed.
Essentially millions of people are suffering, when they need not, as sleep apena is relatively easily treated.
If you’re unsure, get tested, please!
Night of the living brain fog dead, or how I hacked myself better thanks to open source software.
Nearly identical path for me last year... very tired, lots of coffee, gave up coffee and realized something wasn't right. I got a test but there was a 2mo wait for a Dr to prescribe it, 3mo after that to get a machine because supply chain. Ended up buying basically unused airsense from craigslist for same price as deductible.
Life changing, but still wonder why it triggered so late in life...
How serendipitous! I booked an appointment with my doctor to explore treatments for my sleep apnea today and I found your article on Hacker News a few hours later. I haven't been diagnosed but my wife has commented on my sleep apnea events for at least 5 years. I didn't think much of it (so I hold my breath sometimes when I sleep, so what?) but I'm 37 and I don't want this to contribute to heart problems or anything else in the future. I clicked on your article because of the "brain fog" keyword. I wouldn't say that I have severe brain fog, but I am having more difficulty remembering certain things like people's names, memories from 10+ years ago, and generally things that are not in close proximity to my day-to-day. I also have a 2yo daughter and have been very over-extended running my own business for the past few years which could be contributing to this. I suspect that I too suffer from CSA vs. OSA thanks to this article. Thanks for sharing your experience!