Orthosomnia
Fixing my sleep made me realize how much OSA is neglected for "non-cliché" people - then it made me obsessive about it
By Aloïs
Listen to this article
AI-generated narration · English
Orthosomnia is a term used to describe a situation where a person becomes overly focused on the sleep data shown by a sleep tracking device. Instead of helping them sleep better, this concern with getting the "right" sleep score or number can make them more anxious and may even contribute to insomnia (source : https://en.wikipedia.org/wiki/Orthosomnia)
Contents
- Trying everything
- 2023 : A false negative
- 2026 : The second diagnosis
- And then I (re-entered) the world of orthosomnia.
- What I did to find my settings
- My sleep lab, device by device
- 100% vibe-coded, and a bit more than that
- What's next
- Sources
During my college studies, I became aware that something wasn't working well in my body T_T
Middle school and high school were barely ok-ish, but in college things got harder. You explore way more difficult concepts, have to organize yourself, think about waaaaaaay more things !
Almost sleeping in exams, having legit 0 mental energy, it quickly became unbearable
Over the years, this became my “personality”. I just accepted that I was the tired guy, that this was how I was. I still remember the day I asked my cousin if it was “normal” to have migraines and headaches every morning.
Of course, he answered no.
Then it really clicked, and I started trying to optimize my sleep (orthosomnia [1]). I read a ton of posts on Reddit, especially on the brainfog sub [2] (great place to find people with chronic fatigue to discuss with if you ask me)
Trying everything
I tried everything I could:
- sleeping with a mask, with earplugs
- trying mouth tape [3]
- trying anti-blue-light glasses [4]
- luminotherapy [5] in the morning
- anti-noise earplugs
- white-noise machine
- a lot of supplements (I just computed the sum of the euros wasted: we're talking about multiple thousands):
- Melatonin [6]
- Glycine [7]
- Ashwagandha [8]
- Mag bisglycinate [9]
- Relora
- GABA [10]…
But I was still waking up completely tired every other day.
For a long time, I thought I just had a hyperactive brain (I've never been able to nap) and no OSA, and that's why I tried all those GABA things, etc. But then I learned that sedatives can increase the number of apneas and their severity [11].
One thing that helped was to move to a calmer flat. I knew I had a very light sleep, so minimizing the external factors helped.
Society tries to sells too much things to desperate people :<
2023 : A false negative
In 2023, I went through a polygraphy [12] (air, HR, movement) which measured an AHI [13] of ~10.
A polygraphy is not a PSG [14]. It only looks at your breathing, oxygen and heart rate… not your brain. So it has no idea if you're actually asleep, and it misses the micro-awakenings that end a lot of hypopneas. Result: it tends to underestimate the AHI [15].
An AHI of ~10 is already mild OSA [16] (it starts at 5 per hour)… but the doctor told me I was in normal ranges.
I started to become more and more frustrated, because I couldn't understand what was going on.
I worked as a freelancer. The days were horrible; I was tired all the time. I had a lot of digestive issues. I couldn't understand why I needed twice the time to heal from my injuries, getting sick every few months…
My mood was horrible too. I was grumpy, irritable for nothing… not the best version of me, at all.
And I couldn't remember stuff. What I said to someone, a conversation I had, technical details at work, etc. etc. New information just didn't stick, it was super hard to encode anything. I was kind of “absent”: there, but not really there. And anyone who went through it knows that you cannot “escape” it.
All of this, plus personal issues, led to a burnout. I hurt some people alongside and feel bad every day for it. I think emotions, impulsivity, etc. are highly related to sleep.
I wish I had solved this earlier
2026 : The second diagnosis
3 years and a breakdown later, my psychiatrist and I noticed that I often mentioned my sleep during medical interviews. After a session with him, we agreed I had to check my sleep again.
I went to a clinic and saw a sleep specialist, who gave me the stuff for an at-home PSG [14].
LLM : [insert copyright free PSG stuff here]
I don't know why, but I had to wait 3 months between the exam and the results... which led to more frustration.
However, the AHI went from 10 to 26, and 32 during REM [17]. This time I really believed I had the answer to my fatigue !
I was prescribed a MAD [18]. When I was a child, I got braces for my teeth, and then a retainer, but I didn't like it at all and wasn't able to sleep with it.
So I mentioned the CPAP [19], and he told me it wouldn't be possible to get it because my OSA isn't severe enough.
A bit frustrated after all those years and the last 3 months waiting for the results, I just asked GPT if it was safe to use CPAP at home with my settings.
I figured out it was not so “hard” to set, unless you have a very specific condition (which I assumed wasn't my case).
Not medical advice!
And then I (re-entered) the world of orthosomnia.
I immediately looked for a second-hand CPAP on a classified ad website. I found one (ResMed AirSense 10) near where I live, instantly bought it and was able to get it that evening
Being back, I started it using LLMs [21] to put the most “generic” settings for the first night.
- First night: quite special: I had aerophagy [22], but felt I was more rested than usual.
- Second night: lowered the pressure.
- Third night: fixed the mask… and it paid ! No more headache !
I've also identified that one of the supplements I was taking interacted with my other medication, which slowed my CPAP settings exploration (be careful if you take any; I used to underestimate the effects they could introduce).
Then, from ~27 Sept., I found really good settings.
Now, my mask is a ResMed AirFit F20, with a ClimateLineAir tube.
I almost don't have any OSA anymore. A few central apneas [23], but I'm trying to reduce their number every night.
My energy levels are between 6 and 9 every day !! when before they would be between 1 and 6 on average.
We can see in the 2 following images (AutoSleep app, “quality sleep” metric) how irregular my sleep was before vs now (I got the CPAP on the 31st of August) :)
What I did to find my settings
LLMs are getting increasingly smart and I do consider that “intermediate” level digital is solved by them (not always the most efficient way but it's another problem).
As an full stack data dev I've always been interested in machine learning, deep, etc. Being able to understand how it works and what it's capable of doing is truly a strength today as :
- Everything interacts with APIs
- A lot of IoT devices expose data via BLE
- You can add SSH to your mobile devices
⇒ LLM can thus interact with everything.
Basically, I have my own set of self-hosted apps. At first I helped someone I know to have its own coaching track app: found TraceApps (worth checking out)
The “xTrace” naming staid : thus the one for sleep is named SleepTrace. :D

How the loop works
Every day, the run builds my night pages. Then I open Claude Code and ask the agent to read them: CPAP airflow, events, EEG stages, oxygen, video… everything on the same clock. It tells me what it sees, I change one setting, and the next nights tell us if it worked. Simple.

What's left? Mostly central apneas. Today I asked the agent to do a deep dive on 3 nights to investigate further the CAs.
Looks like they come in waves (one every ~38 s), mostly right after a big breath or a micro-awakening: when I fall back asleep after putting the mask back on, during REM, and sometimes when the machine climbs to 11–12 cmH₂O at the end of REM.
Though my central apnea index already went from ~14/h (mid-Sept) to ~6/h.
Next test: EPR from 2 to 1 (or off) for a week… and we'll see.
My sleep lab, device by device

ResMed AirSense 10 AutoSet · CPAP
A few hundred $, second-handUse: CPAP therapy; airflow (25 Hz), pressure, leaks and apnea flags.
Reliability: Reported apnea-count correlation with sleep-lab measurements: r = 0.87–0.95 [26]. No sleep/wake detection.


Wellue Checkme O2 Ultra · wrist oximeter
~$150Use: Blood oxygen and pulse, every second (streamed to the Pi).
Reliability: Blood oxygen precision: ±2%.

Apple Watch Ultra 2 · smartwatch
~$800Use: Sleep stages, heart rate, HRV, breathing disturbances.
Reliability: Sleep staging evaluated against PSG by Apple (white paper [28]). An independent comparison of six wearables [29] reported κ = 0.53 and underestimation of deep sleep and wake.

Tapo C100 · IR camera
~$30Use: Body movement, sound, chest movement from the video (streamed to the Pi).
Reliability: Video-analysis algorithm coded by Claude Opus 5.5 and compared with CPAP data. No formal validation.

Old Android phone on a chest belt · accelerometer + mic
~$50Use: Breathing effort, movement, sleep position and sound (recorded since 6 Oct).
Reliability: Algorithm coded by Claude Opus 5.5. Correlation with CPAP airflow: r ≈ 0.95 on one test night. No formal validation.


Old Lenovo tablet · bedside screen
Use: Displays the previous night's summary and charts at the bedside.
For the nerds: the tech stack
- Language: Python 3.13, NumPy, SciPy, Pillow and Matplotlib.
- Pipeline: bronze - silver - gold layers; each stage is cached by a fingerprint of its code and inputs, and only reruns when one of them changes.
- Orchestration: Prefect 3 flow, started by hand in the morning: the Pi keeps the data, a worker on my PC runs the heavy stages on its GPU and sends the results back.
- Streaming: the Pi records the camera's RTSP stream and the oximeter over Bluetooth, and pulls the phone's files over SSH.
- Video: FFmpeg with CUDA decoding; movement, sound and breathing effort computed with NumPy.
- CPAP: home-made parser for ResMed EDF files (25 Hz flow and pressure, events), using OSCAR [31]'s ResMed loader as a reference.
- EEG: raw Bluetooth LE packets decoded with OpenMuse; sleep stages with YASA and MNE.
- Oximeter: Viatom Bluetooth protocol, written with
bleak. - Chest belt: accelerometer and mic recorded on the phone with Termux; the sound is synced to the camera's audio.
- Night summary: Opus 5.5 and Sol 6.1 both draft it, then Opus merges the two.
- Other sources: Apple Health Auto Export JSON (sent with LocalSend) and the Home Assistant REST API.
- Front-end: static, self-contained HTML pages with vanilla JS canvas charts (synced cursor and zoom), plus phone and tablet views, published atomically as immutable releases.
100% vibe-coded, and a bit more than that
SleepTrace is 100% vibe-coded. The whole pipeline I just talked about, the sensors, the parsers, the pages… all of it. Opus 5.5 and Sol 6.1 did very well.
And as a dev, of course (I still sometimes) read through the code. It does feel quite special to watch a tool this specific to my life take shape like that :)
It makes me optimistic about the future of medicine. Being able to bring together what happens between appointments, better understand what we're going through, show up with data instead of an “I'm tired”… I feel like there's so much we can do. After all those years of not understanding, it gives me a bit of hope :)
I don't have the lifestyle you'd typically associate with OSA. I work out, eat well, don't drink, don't smoke, don't even snore… so for years, sleep apnea just wasn't on my radar.
That's the part I keep thinking about. If I'd had the tech to figure this out when I was younger, I really don't think I would have had the same life.
My studies, work, relationships… all those years where I thought being exhausted was just who I was. I can't redo them, but the idea that someone else might get an answer earlier makes me pretty optimistic :)
What's next
Still waiting for my MAD [18].
Sources
- Wikipedia: Orthosomnia
- Reddit: r/brainfog
- Wikipedia: Mouth taping
- Singh S et al. Blue-light filtering spectacle lenses for visual performance, sleep, and macular health in adults. Cochrane Database Syst Rev, 2023
- Wikipedia: Light therapy
- Wikipedia: Melatonin as a medication and supplement
- Wikipedia: Glycine
- Wikipedia: Withania somnifera
- Wikipedia: Magnesium glycinate
- Wikipedia: Gamma-Aminobutyric acid
- Wikipedia: Obstructive sleep apnea (Medication and lifestyle)
- Wikipedia: Sleep study (Home sleep test)
- Wikipedia: Apnea–hypopnea index
- Wikipedia: Polysomnography
- Kapur VK et al. Clinical Practice Guideline for Diagnostic Testing for Adult Obstructive Sleep Apnea: an AASM Clinical Practice Guideline. J Clin Sleep Med, 2017
- Wikipedia: Obstructive sleep apnea (Criteria)
- Wikipedia: Rapid eye movement sleep
- Wikipedia: Mandibular advancement splint
- Wikipedia: Continuous positive airway pressure
- Wikipedia: Obstructive sleep apnea
- Wikipedia: Large language model
- Wikipedia: Aerophagia
- Wikipedia: Central sleep apnea
- Wikipedia: API
- Wikipedia: Bluetooth Low Energy
- Comparison of ResMed AutoSet (version 3.03) with polysomnography in the diagnosis of the sleep apnoea/hypopnoea syndrome. Eur Respir J, 1997
- Lanthier M et al. Assessing the performance of a portable electroencephalographic sleep monitor against level 1 polysomnography. Sleep Advances, 2025
- Apple. Estimating Sleep Stages from Apple Watch (white paper), October 2025
- Schyvens AM et al. A performance validation of six commercial wrist-worn wearable sleep-tracking devices for sleep stage scoring compared to polysomnography. Sleep Advances, 2025
- Sensirion. SCD40 CO₂ sensor datasheet
- OSCAR: Open Source CPAP Analysis Reporter





