Truncate an SPO2 file

General Discussion on any topic relating to CPAP and/or Sleep Apnea.
ragnar33
Posts: 21
Joined: Sun Mar 01, 2015 11:52 am

Truncate an SPO2 file

Post by ragnar33 » Wed Jun 24, 2015 3:24 pm

Hello, I must not have stopped the CMS50+ recording this morning, so now I have several hours more oximeter data than what was stored by the CPAP machine. Is there a simple way to get rid of the excess? When I import it into SleepyHead I get the whole recording. If I knew the format of the SPO2 file I might be able to edit it.

JDS74
Posts: 3397
Joined: Sun Jan 23, 2011 2:57 pm
Location: South Carolina

Re: Truncate an SPO2 file

Post by JDS74 » Wed Jun 24, 2015 7:03 pm

ragnar33 wrote:Hello, I must not have stopped the CMS50+ recording this morning, so now I have several hours more oximeter data than what was stored by the CPAP machine. Is there a simple way to get rid of the excess? When I import it into SleepyHead I get the whole recording. If I knew the format of the SPO2 file I might be able to edit it.
Here is a note from Mark on the file structure that I found in some debug discussions.
I've gotten to the bottom of the .spo2 file structure.

The basic file format for anyone who's interested is as follows..
(This ignores any user specified record fields, just the bits needed to read into sleepyhead)
First two bytes contain starting position of the second header.
Second header starts with 200 (decimal) bytes of cruft
Followed by a list of 32bit integers containing
year, month, day, hour, minute, second,
followed by 32bit integer containing number of samples,
followed by a list of 8bit pairs containing SpO2 and pulse rate till the end of file.
I've modified the CMS50 file importer so it can work with these files, the next test build will have this code in it for you to try... But I've got to tinker a bit more first to resolve a CPAP importer crash..
Not sure if this covers the CMS50+.

Notice that the length of the file is included in the header information. Changing that 32 bit integer to a smaller number effectively truncates the file without altering the actual file size. You can use a HEX editor to make the change.

_________________
Mask: Oracle HC452 Oral CPAP Mask
Humidifier: DreamStation Heated Humidifier
Additional Comments: EverFlo Q 3.0 Liters O2 PR DSX900 ASV
Last edited by JDS74 on Wed Jun 24, 2015 7:56 pm, edited 1 time in total.
Oracle 452 Lessons Learned Updated
DSX900 AutoSV with HC150 extra humidifier and Hibernite heated hose
Settings: EPAP Min-10.0, EPAP Max-17, PS Min-3, PS Max-10, Max Pressure-20, Rate-Auto, Biflex-1.
Sleepyhead and Encore Pro 2.21.

ragnar33
Posts: 21
Joined: Sun Mar 01, 2015 11:52 am

Re: Truncate an SPO2 file

Post by ragnar33 » Wed Jun 24, 2015 7:44 pm

Thanks, I will try to play with the length. Alternately I could look for 0 ox level.

JDS74
Posts: 3397
Joined: Sun Jan 23, 2011 2:57 pm
Location: South Carolina

Re: Truncate an SPO2 file

Post by JDS74 » Wed Jun 24, 2015 8:09 pm

If SleepyHead SpO2 data import is looking at the length value, then it will try to read the amount of data specified. If you just truncate the file, SleepyHead will try to read the data beyond the end you set to end of the physical sector at the end of the file and then try to read the next, non-existant sector. I'd guess that would result in some unspecified error condition.

Be careful.

_________________
Mask: Oracle HC452 Oral CPAP Mask
Humidifier: DreamStation Heated Humidifier
Additional Comments: EverFlo Q 3.0 Liters O2 PR DSX900 ASV
Oracle 452 Lessons Learned Updated
DSX900 AutoSV with HC150 extra humidifier and Hibernite heated hose
Settings: EPAP Min-10.0, EPAP Max-17, PS Min-3, PS Max-10, Max Pressure-20, Rate-Auto, Biflex-1.
Sleepyhead and Encore Pro 2.21.