1

I am trying to pull images from an SQLite database from a cell phone application (used to perform personal spirometry: lung function testing).

I have been able to access all the numerical data I need, but cannot access the image data showing the flow curves (air volume is plotted and shown over the duration a person exhales). Based on the shape of the flow curve, a clinician can determine if the test is valid. My goal is to create an R package to view the numerical data and flow curves so the data can be reviewed by a clinician.

The data structure:

> str(s_blobs)
'data.frame':   6 obs. of  2 variables:
 $ Z_PK               : int  1 2 3 4 5 6
 $ ZFVCCURVECOMPRESSED: blob [1:6] 
  ..$ : raw  62 70 6c 69 ...
  ..$ : raw  62 70 6c 69 ...
  ..$ : raw  62 70 6c 69 ...
  ..$ : raw  62 70 6c 69 ...
  ..$ : raw  62 70 6c 69 ...
  ..$ : raw  62 70 6c 69 ...
  ..@ ptype: raw 
> 

My issue is very similar to this. However, I am unable to open the exported file because it says it is empty. I can open the database with DB Browser and view/export the binary data. When I upload the binary to an online tool, an image is not created. I could not open the file with ImageJ either.

I have the option to view the file as 'binary' or 'image' in DB Browser. When I select the mode as 'image,' no image appears. Is it possible to pull the image?

Session info:

R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5.1

I am using RSQLite and DBI to connect and read the database.

UPDATE

A sample dataset (xb) has been uploaded to my R package: https://github.com/wolfeclw/spirobankR.

Here is the script I am working with using @MrFlick's package myphone.

library(spirobankR)
library(myphone)

ex_blob <- xb[[1]]

decode_binary_plist(ex_blob)

Trying to use decode_binary_plist throws me the following error: Error in expanded_values[[i]] : subscript out of bounds.

  • According to [this reference](https://www.garykessler.net/library/file_sigs.html) the values in `ZFVCCURVECOMPRESSED` appear to be "Binary property list (plist)" values, not image values themselves. I previously wrote [some R code to parse binary plists](https://github.com/MrFlick/myphone/blob/master/R/plist.R). It's not clear if the image itself is in that blob or not. In other iOS app data I've seen it's not always in there. But try the parser and maybe that will tell you what's in there. – MrFlick Sep 06 '22 at 13:13
  • Thank you! @MrFlick I didn't consider this being an iOS issue too, but that makes sense. I can get `decode_binary_plist()` to work on the example data, but not my data. When running the function on my data, I receive the message `Error in expanded_values[[i]] : subscript out of bounds.` Any ideas? – Chris Wolfe Sep 07 '22 at 05:20
  • It's probably a problem with my code. I was only testing with data I had access to. Are the blobs large? Is it possible to include one in the question itself. Something like the output of `s_blobs$ZFVCCURVECOMPRESSED[[1]]`. It's hard to guess at what's going on with out a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) or some kind. – MrFlick Sep 07 '22 at 12:54
  • @MrFlick storage-wise they are not that bit, but wouldn't be very pretty to paste here. I included a sample on the Github page: https://github.com/wolfeclw/spirobankR. I amended the question to include code to pull in the data. – Chris Wolfe Sep 09 '22 at 07:53
  • Thanks for the reproducible example. It helped me find a bug in the `decode_binary_plist` function. I've pushed updated code to the repo. It can now decode the data, but there is no image data inside that object. The images must be stored elsewhere. – MrFlick Sep 09 '22 at 15:26
  • @MrFlick I got it to work as well. Thank you for putting the time and effort into this! – Chris Wolfe Sep 12 '22 at 01:55

0 Answers0