Apnea Board Forum - CPAP | Sleep Apnea
How export all days for oximeter (O2 Ring) data only (no CPAP) ? - 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: How export all days for oximeter (O2 Ring) data only (no CPAP) ? (/Thread-How-export-all-days-for-oximeter-O2-Ring-data-only-no-CPAP)

Pages: 1 2


How export all days for oximeter (O2 Ring) data only (no CPAP) ? - DavidEsp - 06-05-2023

Is there a way, via O2 Insight or OSCAR, to export (eg as CSV) all oximeter (only) data ever recorded/imported?

My oximeter is an O2Ring, I import from it daily into O2 Insight and (then) OSCAR.
I see OSCAR has a CSV Export Wizard but when I use it, all I get is headings, no data (maybe only works when there is CPAP data?)

Reason for wanting to export the data:
To quickly/easily experiment with making my own prototype metrics (for oxygen deprivation) and predictors (of energy, mood and headaches)
I am aware of conventional metrics like SpO2 levels and ODI (3% & 4%) but consider these too crude - more "easy to measure" than targeted.
BTW if anyone has interest/opinions/links regarding such metrics/predictord, please let me know.


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - Jeff8356 - 06-05-2023

Export the oximeter data as csv from the O2 Insight Pro app on your computer.


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - DavidEsp - 06-08-2023

(06-05-2023, 06:48 AM)Jeff8356 Wrote: Export the oximeter data as csv from the O2 Insight Pro app on your computer.

Thanks Jeff,

I tried that (O2 Insight's [Export as CSV] button), but it only seems to export for a single session.

Even when I selected all the sessions (nights) so far for this month (June), after I exported, the CSV file only contained data for 1 to 2 June (overnight).

Is that (one day at a time) definitely the only option here, or is there a (user-friendly or hack-y) way to get it to export over multiple sessions?
(Even if only to put my mind at rest that I'm not missing something)

I (just now) tried a more hack-y way - opening the (O2 Insight) application's (SQLite) database (db_o2.db, opened in DB Browser for SQLite), but it only contains daily aggregate/summary/score data, not down to the individual samples level.  Shame...

I see also there is code (e.g. Java) on GitHub for reading individual Viatom pulse oximeter binary files, I guess it should in principle be easy to run that (e.g. in a commandline or java for-loop) over all the files in a directory/folder.  But I would prefer "an easy route" if possible.


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - Crimson Nape - 06-08-2023

The database name is, PlusebitO2.db. The data is stored as a blob type. The path is sleepData/dataBuf. Each record is stored sequentially, and uses the date/time filename field (mFileName) for parsing. I'm sure there must be instructions on the internet to extract and format this data to your needs.

Good luck!
- Red


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - Jeff8356 - 06-08-2023

I may be wrong, but as near as I can tell the db names for Apple versions are:
  • iOS v16.3.1 - jkdb.sqlite
  • macOS v12.6.6 - db_o2.db

Both db's only hold the summary data for each session. All of the binary files are in their respective locations and hold the detailed data.


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - Crimson Nape - 06-08-2023

You're correct, Sir!

I went back and found that in some versions, Viatom had changed the database names. For the databases named, db_o2.db, this is the location to find the data: tb_check/checktime.

Good catch! Thanks

- Red


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - DavidEsp - 06-13-2023

Ok, so there is no option apart from getting/writing some custom code to go through all the binary files themselves.

I found what looks like suitable java code here: https://github.com/rileyg98/ViatomDataReader

According to its README.md file:
Code:
Reads raw binary files extracted from Viatom pulse oximeters.
Inspiration (and the header definition) was borrowed from OSCAR, over at https://gitlab.com/pholy/OSCAR-code.
This takes an input file name and an output file name. It does basic sanity checking of the file structure.
This will output a CSV formatted with the following columns: Unix Timestamp, Pulse, Heartrate.

I am on macOS
I tried downloading the above and running it on a binary file ("20230611204719") as follows, in a Terminal window:
Code:
java ViatomReader.java ~/Desktop/20230611204719 ~/Desktop/20230611204719.csv
But it failed with error message: "package com.opencsv does not exist"
So I guess I need to load that package somehow.  Anyone know the most appropriate wat to do this?
From a websearch, so far, it seems recommended to use a tool called 'maven', which (AFAICT) automatically downloads dependencies (presumably to wherever they ought to be!).
Am I on the right track, or is there some nice simple slick and friendly GUI-based java IDE I could be using instead?
Any tips welcome


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - DavidEsp - 06-13-2023

The Bing-ChatGPT language-model's recommendation was to use NetBeans as an IDE - easy to learn and quite functional, supports maven.
I found information on that here on StackOverflow.
I will try that out.

Programming in java is new to me.


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - msimon - 08-07-2023

For anyone coming across this (including OP) yes this will work. It took me quite a long time to get everything working, but it is possible. The basic steps are:

- grab binary data files (".dat") from phone. It is in "com.viatom.vihealth\files\20\host" where 20 may be different for you. They are names after the timestamp of the recording

- convert them using the tool linked by David, found at the link above (I am new and can't link). It is called "ViatomDatareader" on github. This was kind of the hard part. I downloaded the entire github repository. I then downloaded the Eclipse Java IDE and was able to get it to run. I then outputted it as an executable jar file. I can upload if anyone wants it.

If doing a lot of files, I found it best to list the entire contents of the folder with the data. I opened it in a spreadsheet app (Libreoffice) and then created a column with the following string:

=CONCATENATE("java -jar test.jar ",A1," ",A1,".csv")

where A1 was the column with the filename.

I then ran the entire list of
java -jar test.jar name.dat name.csv
in a windows Powershell. It took a while. I then merged all the .csv's into a single file using

Get-Content .\*.csv | Out-File .\Combined.csv

in Powershell. That also took quite a while.

In the end, I now have a csv with all my timestamped SpO2 and heart rate data.

Sorry this wasn't written out better, it's been a while since I've posted like this and it is getting late. I will try and help if anyone has questions that wants to do this process.

I can upload the executable jar file to save a step (not having to download and run the Eclipse thing). Of course you'd have to trust some random person on the internet in not giving you a virus.


RE: How export all days for oximeter (O2 Ring) data only (no CPAP) ? - Ernst freeman - 11-12-2023

Not sure if this answers the question, but wanted to share my experience, I wanted to download all the O2 Ring data at the end of the month in bulk and downloading them day by day was teddies so this is what I figured out, this was for an iPhone but an Android phone should have similar steps

  1. Use iTunes to download ViHealth data (Click on you Device icon in itunes -> File Sharing -> pick viHealth for the apss list -> click on O2Data -> save the file to your PC).
    Note: you may find all the shared O2 files in the root directory but this does not include all your O2 Data only the data that you saved as binary and shared from the app, so just pick O2Data directory to get the full device data.

  2. You need to rename all files by removing the .dat extension from them so OSCAR can import them, for that I used Chat-GPT to get me a script to do it on windows, if you are using mac try google or just ask Chat-GPT for some help, to rename all these files.
    * I create a file named script.bat in Folder beside my O2Data.
    * Create a new text file and past this code inside, make sure to rename the directory to what match where your files are.
    * Rename the text file to script.bat and double click on it.
    Note: This script will only work on windows pc.
    Code:
    @echo off
    setlocal enabledelayedexpansion

    rem Specify the directory where your files are located
    set "directory=C:\Users\user1\Desktop\temp\O2Data\"

    rem Loop through each .dat file in the directory
    for %%F in ("%directory%\*.dat") do (
       rem Get the file name without extension
       set "newName=%%~nF"
       
       rem Rename the file by removing the .dat extension
       ren "%%F" "!newName!"
    )

    echo All .dat files in %directory% have been renamed.



  3. Just import the stuff from OSCAR (Data -> Import Viatom/Wellue Data).

Hope this could be helpful for any one searching for downloading O2 Ring Data from ViHealth app directly in bulk.