Apnea Board Forum - CPAP | Sleep Apnea
OSCAR SpO2 CSV import - Printable Version

+- Apnea Board Forum - CPAP | Sleep Apnea (https://www.apneaboard.com/forums)
+-- Forum: Public Area (https://www.apneaboard.com/forums/Forum-Public-Area)
+--- Forum: Software Support Forum (https://www.apneaboard.com/forums/Forum-Software-Support-Forum)
+--- Thread: OSCAR SpO2 CSV import (/Thread-OSCAR-SpO2-CSV-import)

Pages: 1 2 3


OSCAR SpO2 CSV import - ST Dog - 12-16-2021

So I found a little SpO2 recorder and while it's phone app based, it will export data in a CSV file.
Emay Sleep2 https://www.amazon.com/gp/product/B08XPH8H7X
The price increased a bit since I bought it.

I've saw there clip-on meter mentioned back in March but there was no response to it.


Should be a simple import filter, just have to manually export the files.

Attached is a 1 hr test log.
Here's a snippet from the beginning. 

Date,Time,SpO2(%),PR(bpm)
2021/12/10,11:32:14,98,85
2021/12/10,11:32:15,98,85
2021/12/10,11:32:16,98,85
2021/12/10,11:32:17,98,85


My coding skills has atrophied in the last decade and I know nothing about the code base.
But a CSV import should be pretty simple for someone that knows the code.


RE: OSCAR SpO2 CSV import - Crimson Nape - 12-16-2021

Both the Zeo and Dream device listings import their data using a .csv file. Maybe, studying their format may allow you to format your device's file and use an existing importer. That would save a lot of time and energy.

OSCAR's source code is here:
https://www.sleepfiles.com/OSCAR/source-code/


RE: OSCAR SpO2 CSV import - ST Dog - 12-17-2021

(12-16-2021, 01:51 PM)Crimson Nape Wrote: Both the Zeo and Dream device listings import their data using a .csv file.  Maybe, studying their format may allow you to format your device's file and use an existing importer.  That would save a lot of time and energy.

OSCAR's source code is here:
https://www.sleepfiles.com/OSCAR/source-code/


I'll see what I can figure out. Both Zeo and Dreem seem to be far more advanced.

And as if my rusty coding wasn't enough, OSCAR is OO, not a strong suit.
I glanced at the code for Dreem and wasn't following it very well.

It does seem both use 30 second data points, while the Emay is every second.
That might be problematic using either.

And some mention of EDF, but that would take a good bit of work to make a conversion script.

Or SomnoPose importer as a baseline (I followed it a little better). It has a timestamp per line (though using Unix time) instead of just incrementing a fixed time. But the data structure it fills is not pulse or oxygen data.

And of course I don't even have a Windows complier set up.
I think I have a Linux install with a compiler, but it would  still be a few years old. I doubt I have all the needed dev libraries either.

Hopefully a coder like @sawinglogz will come along. They could probably do it in an hour since they already understand the data structures in OSCAR and the CSV library.


RE: OSCAR SpO2 CSV import - Crimson Nape - 12-17-2021

I was thinking that you format your device's csv file to mimic one of the ones already used.


RE: OSCAR SpO2 CSV import - ST Dog - 12-17-2021

(12-17-2021, 03:20 PM)Crimson Nape Wrote: I was thinking that you format your device's csv file to mimic one of the ones already used.

If I can find example data files I'll try, but the importers imply a lot more than what I have.

And at least one appears to expect the filename to have a specific format.


RE: OSCAR SpO2 CSV import - 2SleepBetta - 12-18-2021

It looks to me like a relatively simple task to restructure your file to conform to the structure linked below. Once done, you can import the SpO2 and PR data into OSCAR via the Somnopose import. I have done this for accelerometer data. Your log time column must be GMT time in seconds after some date long past. After long non-use I expect to revisit such files tonight to prepare some imports of other data and will see if it is easy to hand off the necessities to you. 

Don't be put off by the fact OSCAR will place the results in its viewing windows labeled for Inclination and Orientation. And note that one of the other import features might be more friendly, though this one is not that difficult.

attachment.php (596×586) (apneaboard.com)


RE: OSCAR SpO2 CSV import - ST Dog - 12-18-2021

(12-18-2021, 01:39 AM)2SleepBetta Wrote: Your log time column must be GMT time in seconds after some date long past.
...
Don't be put off by the fact OSCAR will place the results in its viewing windows labeled for Inclination and Orientation.

I did glance at the Somnopose importer. Looked to be using Unix time (seconds since Jan 1, 1970)

The fact it was dealing with sleep positions didn't look like what I wanted.

Any help would be appreciated.
The Emay device looks like a nice slim alternative to ConTec stuff and comes with a comfortable silicon sensor instead of a clip on sensor.

Guess I need to talk to my Python programming son. Last I did data reformating like this was in Perl 15 years ago. But I haven't written a regular expression in a decade. And Perl on Windows never went well.


RE: OSCAR SpO2 CSV import - 2SleepBetta - 12-18-2021

Shamelessly I offer this mere Excel prototype I've adapted and long used to import various kinds of data into OSCAR. Obviously, it's not ready for prime time and use by others and it's no harm no foul if you don't care to use it. 

It does show key elements that can be used to generate the necessary input and format for OSCAR Somnopose imports. I send it only because I remember my false steps with this simple task; it may help. (Perhaps this cobble-together will induce someone to step up with a clean and simple conversion file for you.)

My actual sheet is too large with lots of vacancies after changes, so I just snipped and presented the relevant matter.

The attachment shows where its numbers came from via formulae. Data from a CSV file produced by a device like your oximeter is pasted in the A to C columns. Time column, as it has been used, begins as zero seconds. For you column A would be 0, 1, 2, 3 . . .  seconds, as I recall the formatting. (I haven't used the spreadsheet recently but will use it tomorrow.) 

You need to adjust for your time zone at 3600 sec/hr; everything is in seconds or appropriate decimal fractions thereof.

I expect your raw heart data will be accommodated as is given those comply with the ranges Somnopose demands. But it must be and will be converted to have ".00 accuracy".

The green-boxed element holds the magic 2001 Somnopose starting date as a constant number of days.

The OSCAR-Somnopose combination is rigid and fussy about exact compliance with formatting requirements as in the linked item I posted.

The bottom right image shows what I paste into the CSV file that will be imported. As you see, it complies with that image I posted.

If you don't have Excel, then I think the free Open Office software is still available and should do the job.

[attachment=38059]


RE: OSCAR SpO2 CSV import - ST Dog - 12-18-2021

Thanks. I'll look at it tonight or Sunday. I have a busy day away grom home with family.


RE: OSCAR SpO2 CSV import - joeblough - 12-02-2023

here is a small python script that converts an EMAY oximeter CSV file to a somnopose CSV that can be imported into OSCAR. it takes as a single argument the name of an EMAY csv file and outputs the new CSV file to standard out, so you'll have to use redirection to create the new CSV file.