Wednesday, May 08, 2013

Analysing my sleep

The SD card reader which I ordered a few weeks ago finally arrived. I was not surprised when it didn't work with my home computer (probably because I haven't gotten around to installing SP3 on XP) but the reader did work with my mobile computer. I extracted the SD card from the CPAP machine then inserted it into the reader. There are three files stored on the card, of which only one interests me.

Although this file has the csv extension, internally it's not really a csv. A single line looks like this
;4 ;4 ;2013;498 ;0 ; 9,1 ; 0,2 ; 8,9 ; 7,0 ; 0,0
Yesterday I didn't know what to do with this file but this morning I realised that it was probably a 'continental' csv file - the commas should be replaced by dots and the semicolons replaced by commas. Thus 8,9 is probably the continental representation of 8.9. Once I had this straight in my mind, I could understand the structure. Fortunately the data in the file has fixed positions within reason (the dates are left justified as opposed to right justified which would be easier to read) making the parse not too difficult. The above structure would have problems with someone who has more than 99.9 apnea per hour (such a person would have extremely serious sleep apnea; I had 60 per hour before starting treatment).

The above line shows the data stored for 04/04/2013, which was the first night that I slept with this machine. I slept (or at least, had the machine turned on) for 498 minutes (8 hours, 18 minutes), 0 minutes with the humidifier (not surprising as there is no humidifier attached), 9.1 apnea per hour of which 0.2 were obstructive apnea and 8.9 central apnea. The pressure was 7 psi and there was no leakage (this occurs when the mask does not fit one's face properly).

I wrote a program in Delphi to store the data in an SQL database so that I can query it as much as I want and however I want. At the moment, I've only written a query to display the average number of apnea/hour on a weekly basis - after the first week, the average is about 7 per hour (very good). I think I'll write another query which will show the average number of apnea/hour per weekday - I wonder if there is a difference between workdays and Friday.

To give an example of what I look like when connected to the CPAP machine, I have downloaded and cropped a picture from the machine's vendor. Obviously it's not my wife and I in the picture (and anyway, she sleeps on my left).

No comments: