#' Loads files associated with QDECR projects
#'
#' @param path Either the path to the directory, or a direct path to the associated .rds file
#' @param reload If TRUE, also reloads the vertex-wise matrix (which is HUGE!); default is FALSE
#' @return Object of class "vw" that was generated by the respective analysis.
#' @export
qdecr_load <- function(path, reload = FALSE) {
if (!file.exists(path)) stop("Provided path does not exist.")
if (dir.exists(path)) {
nc <- nchar(path)
end <- substring(path, nc, nc)
if (end == "/") path <- substring(path, 1, nc - 1)
path <- paste0(path, "/", basename(path), ".rds")
}
x <- readRDS(path)
if (reload) x <- reload(x)
x
}
#' Reloads vertex-wise data for an "vw" object
#'
#' @param vw An object of class "vw"
#' @param verbose If TRUE, displays all information related to the reloading; default is TRUE
#' @return Object of class "vw" where vw$mgh is populated.
#' @export
reload <- function(vw, verbose = TRUE) {
vw$mgh <- qdecr_prep_mgh(vw$paths$dir_subj, vw$input$mgh_ids, vw$mask,
vw$input$hemi, vw$input$measure, vw$input$fwhmc, vw$input$target,
vw$input$n_cores, vw$paths$dir_tmp, vw$input$project,
backing = vw$paths$backing_mgh, verbose = verbose)
vw
}
#' Removes vertex-wise data from an "vw" object
#'
#' @param vw An object of class "vw" where vw$mgh is populated
#' @return Object of class "vw" where vw$mgh is empty
#' @export
unload <- function(vw) {
if (!is.null(vw$mgh)) {
unlink(vw$mgh$bk)
unlink(vw$mgh$rds)
vw$mgh <- NULL
}
vw
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.