#' @title Extract Brain Structures from CIFTI Brain Models
#' @description Extracts the \code{BrainStructure} attribute from a
#' \code{BrainModel} in a \code{cifti} object
#'
#' @param file \code{cifti} object
#'
#' @return A vector of brain structure names
#' @export
cifti_brain_structs = function(file) {
if (is.cifti(file)) {
cii = file
} else {
cii = read_cifti(file)
}
struct_names = sapply(cii$BrainModel, function(x) {
if (is.list(x)) {
return(sapply(x, attr, "BrainStructure"))
}
attr(x, "BrainStructure")
})
struct_names = unlist(struct_names)
return(struct_names)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.