Hello Guest, Welcome to Apnea Board !
As a guest, you are limited to certain areas of the board and there are some features you can't use.
To post a message, you must create a free account using a valid email address.

or Create an Account


New Posts   Today's Posts

Analyzing CMS50E Raw Data
#1
Analyzing CMS50E Raw Data
I recently got a CMS50E pulse oximeter. As you probably know, it will record up to 24 hours of ox sat and pulse data and upload them to analysis software that comes with the device.You can also upload the data to SleepyHead.

I wanted to use the CMS50E to count desats as a way to compare the effectiveness of different sleep positions, pillows, etc. But desat counts between the CMS50E software and SleepyHead often differed by a factor of 2 or 3 even when the "trigger" settings (% decrease in sat and time criteria) were set the same. And there was poor correlation between the two - for example, on one night the CMS50E software would register more events than SleepyHead but on another night it would be the reverse. Neither CMS50E nor SleepyHead disclose the exact algorithm used to detect a desat event.

So I wanted to analyze the data myself. First, I discovered that when you upload data to the CMS50E software, it writes a .csv file to the Data folder in addition to its own .spoR binary format. (NOTE: to see them, you have to click the "Compatibility Files" button when you use Windows Explorer to view the Data folder.) The .csv file has just two columns, SpO2 and Pulse. There are no time marks. But by comparing the length of the file to the clock time you had the device recording, you can see that the sample rate is one per second. You can load and analyze the .csv file using Excel or any scripting language. I found some other scripts out there but they only process streaming data, not recorded data. They may not be aware of the existence of the .csv file.

I wrote a Python script intending to detect desat events by finding time spans where SpO2 was continuously decreasing at some minimum rate. But I found there are a lot of problems doing it that way, which probably account for the differences between the CMS50E software and SleepyHead. For example, what if there is a 1-second jog up during a long desat? Do you count it as two desats? When does the desat stop, after SpO2 stops decreasing? When it starts increasing again? When it reaches its previous maximum? When it reaches your basal SpO2? And how do you calculate the basal value? Etc. etc. Then there were issues with handling obvious data drops and zero values that get recorded after you take the device off your finger. (I often take it off at 4 or 5 am because it starts to hurt my finger, and then end up with a couple hours of zero data. The best way I found to keep the device on is to sort of loosely pull a tube sock over your hand. If it's too tight you can cut a hole for your thumb. Rubber bands hurt and often compress the device too hard on your finger and corrupt the data.)

So I changed to what I think is a more stable and meaningful detection algorithm. First I throw out all sat values below 41 (the device seems to generate a 40 when it's not getting a good read, and generates zeros when the finger is out.) I then calculate the basal value as the MODE of the remaining values. Then, a desat is counted if the sat value falls more than 1 point below the mode before rising to 1 point below the mode again within 100 seconds. Finally, I calculate a "severity index" that is the average sat deficit compared to the mode, over the time span of the desat. I output counts of all desats and of "severe" events that have an index more than 2. And I output the number of desats and "severe" desats per hour OF VALID DATA. It doesn't make sense to include the time you had the device off your finger. The CMS50E software and SleepyHead don't seem able to make this important correction.

(an aside: Originally I thought that the total time below the basal sat, or below some fixed sat value like 93, would be a good, stable indicator of sleep disruption. But if you think about it, you could have sats of 89 all day long and Medicare wouldn't even give you oxygen therapy. So having a desat like dropping to 85 for 40 seconds does not seem to be harmful in itself. The real significance of a single desat event is that it may indicate an apneic event that disrupts your sleep - which appears to be the real harm. I am neither a doctor nor a biophysicist so treat this as speculation.)

Using my "below-mode" method I get event counts that are stable from night to night under the same conditions. But the important thing is that I know exactly how they're counted.

The board won't let me attach my script, but you can probably reproduce what I did with minimal skills. Obviously, this information is only for rough comparisons or fun. Do not use these guidelines to diagnose or treat any disease...

Post Reply Post Reply
#2
RE: Analyzing CMS50E Raw Data
(12-22-2016, 12:57 PM)TubeJockey Wrote: ...The board won't let me attach my script...

If you wanted to put it in a Google Doc, or similar, you could then share the link to that.
                                                                                                                          
Note: I'm an epidemiologist, not a medical provider. 
Post Reply Post Reply
#3
RE: Analyzing CMS50E Raw Data
That is one heck of a first post! Welcome to the Apnea Board.

In case you have not seen it, this may be of interest:
https://github.com/airikka/spo2cms50dplus

I am on a Mac, so that or SleepyHead is my only way of getting the data.
Post Reply Post Reply
#4
RE: Analyzing CMS50E Raw Data
as far as it comes to SleepyHead: thank god, no let me rephrase that: thank jedimark - it's open source:

I believe your loader would be that: https://gitlab.com/sleepyhead/sleepyhead...loader.cpp

as a bit of a warning if you want to build sleepyhead on windows: stick to jedimarks requirements to the letter! (using VS 2015 is not a wise idea! and make sure you really get the right QT library)

Post Reply Post Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Viatom/WellUE data is different than OSCAR displayed data GordK 3 268 02-23-2024, 04:48 PM
Last Post: GordK
  Data structure / data definition of AirSense 11 CD, CMSd50+ or OSCAR?hing obvious, … Perickson 4 1,605 02-18-2024, 01:49 PM
Last Post: Perickson
  Changed data directory from OneDrive, Now can't read data Rich66 9 983 08-24-2023, 11:32 PM
Last Post: Rich66
  analyzing OSCAR snore chart cberistain 1 880 12-18-2021, 01:50 PM
Last Post: sheepless
  Import CSV data file without matching SD card sleep data 2SleepBetta 4 1,248 09-30-2021, 05:55 AM
Last Post: Neelix
  Bug: Viatom data reappearing in OSCAR after deleting oximetry data Ratchick 2 945 04-19-2021, 10:10 PM
Last Post: Ratchick
  Oscar Error there is no data to graph summary data only u4ea 2 1,423 02-05-2021, 10:02 PM
Last Post: u4ea


New Posts   Today's Posts


About Apnea Board

Apnea Board is an educational web site designed to empower Sleep Apnea patients.