AFMdata S4 images can be read from an SQL database using their unique ID.
Since the database can only store tables, the image is split into two tables,
one for the data and one for the metadata that contains the description, units
and size of the image. This function puts the image back together using specific
tables in the database; this function only works with AFM.writeDB
AFM.readDB(mydb, ID = NA, verbose = TRUE)
database connection from DBI package
unique object file ID, if not provided, will return all available IDs in database
if TRUE
outputs verbose comments
S4 AFM object from nanoAFMr package
fname = file.path(tempdir(), "afm.sqlite")
mydb <- DBI::dbConnect(RSQLite::SQLite(), fname)
afmFile = AFM.getSampleImages(type='tiff')[1]
a = AFM.import(afmFile)
AFM.writeDB(a, mydb, 45, verbose=FALSE)
cat("Available IDs in database: ",AFM.readDB(mydb))
#> Available IDs in database: 45
b = AFM.readDB(mydb, 45)
DBI::dbDisconnect(mydb)
plot(b)
#> Graphing: Topography