Installing

devtools::install_github("Sage-Bionetworks/mhealthannotator")

Load Library

Configuring Synapseclient using Reticulate

Many functions in mhealthannotator use reticulate and the Synapse Python client. See the reticulate documentation for information on how to set R to use a specific version of Python if you don’t want to use the default Python installation on your machine. Whichever Python installation you choose should have synapseclient installed.Because mhealthannotator uses reticulate, it is not compatible with the synapser package.

Documentation for installation can be found here

How-to’s:

Create Your own Visualization Function:

To create a visualization function, expected input is any parse-able data json, jpeg etc. And output will a filepath to the processed files.

## a good and simple example is to make a function that takes in filepath
## and convert to jpeg if image is png format
visualize_photo <- function(filepath){
    if(tools::file_ext(filepath) == "png"){
        new_filepath <- sub('\\.png$', '.jpg', filepath)
        png_mat <- png::readPNG(filepath)
        jpeg::writeJPEG(png_mat, target = new_filepath, quality = 1)
        file.remove(filepath)
        return(new_filepath)
    }else{
        return(filepath)
    }
}

Run your App using the config and visualization function:

To run the app, you will only require two parameters, which is the configurations file and your desired function.

You can refer to Schema Configuration to customize each of the parameter of the configuration file. To check whether you are using the correct and available parameters you can run mhealthannotator::validate_config_file(<path_to_config>).

Afterwards, you will be able to run the app by invoking:

mhealthannotator::run_app(config = "config.yml",
                          funs = visualize_photo)

Additional Notes:

To choose config options other than default, you can run:

before running the app. More documentation here