diff --git a/R/otherfunc.R b/R/otherfunc.R index ccfc1e6..efaf0a1 100644 --- a/R/otherfunc.R +++ b/R/otherfunc.R @@ -683,12 +683,13 @@ surf_to_vol=function(surf_data, filename) #' #' @description Correlates the significant clusters of an earlier vertex-wise analysis with a database of task-based fMRI and voxel-based morphometric statistical maps and associate them with relevant key words #' -#' @details The \href{https://nimare.readthedocs.io/en/stable/index.html}{NiMARE} python module is used for the imaging decoding and is imported via the reticulate package. The function also downloads the \href{https://github.com/neurosynth/neurosynth-data}{neurosynth} database in the package's inst/extdata direcotry (~8 Mb) for the analysis. +#' @details The \href{https://nimare.readthedocs.io/en/stable/index.html}{NiMARE} python module is used for the imaging decoding and is imported via the reticulate package. The function needs the \href{https://github.com/neurosynth/neurosynth-data}{neurosynth} database in the package's inst/extdata directory to be downloaded (~8 Mb) for the analysis. To maximise the speed of processing, keywords were excluded from the original database if they were: the name of an anatomical brain region, protocol-specific descriptive words that are not meaningful out of context (e.g., “studied”, “clips”, “engaged”), and broad categories that do not specifically point to a content (“disorder”, “psychological”, “cognitive”). A full list can be obtained with the keyword_list argument. #' #' @param surf_data a numeric vector with a length of 20484 #' @param contrast A string object indicating whether to decode the positive or negative mask ('positive' or 'negative') +#' @param keywords_list A boolean stating whether to return the full list of keywords in the imported neurosynth database #' -#' @returns A data.frame object listing the keywords and their Pearson's R values +#' @returns A data.frame object listing the keywords and their Pearson's R values. If keywords_list is TRUE, a list containing the same data.frame object and the list of all the database keywords. #' @examples #' CTv = rbinom(20484, 1, 0.001) #' decode_surf_data(CTv, 'positive') @@ -696,7 +697,7 @@ surf_to_vol=function(surf_data, filename) #' @export ##CT image decoding -decode_surf_data=function(surf_data,contrast="positive") +decode_surf_data=function(surf_data,contrast="positive", keywords_list=F) { #Check if required python dependencies and neurosynth are present, nothing will happen if absent VWRfirstrun("neurosynth") @@ -751,7 +752,18 @@ decode_surf_data=function(surf_data,contrast="positive") colnames(result)=c("keyword","r") result=result[order(-result$r),] - return(result) + if (keywords_list==T) { + neurosynth_dset = nimare.dataset$Dataset$load(system.file("extdata/neurosynth_dataset.pkl.gz", package='VertexWiseR')) + keywords=colnames(neurosynth_dset$annotations) + keywords=sapply(strsplit(keywords, '__'),"[", 2)[-c(1:3)] + result=list(result,keywords) + } + else + { + return(result) + } + + } } diff --git a/man/decode_surf_data.Rd b/man/decode_surf_data.Rd index 5112228..a6d7f14 100644 --- a/man/decode_surf_data.Rd +++ b/man/decode_surf_data.Rd @@ -4,12 +4,14 @@ \alias{decode_surf_data} \title{Decode surface data} \usage{ -decode_surf_data(surf_data, contrast = "positive") +decode_surf_data(surf_data, contrast = "positive", keyword_list = F) } \arguments{ \item{surf_data}{a numeric vector with a length of 20484} \item{contrast}{A string object indicating whether to decode the positive or negative mask ('positive' or 'negative')} + +\item{keyword_list}{A boolean stating whether to return the full list of keywords in the imported neurosynth database} } \value{ A data.frame object listing the keywords and their Pearson's R values @@ -18,7 +20,7 @@ A data.frame object listing the keywords and their Pearson's R values Correlates the significant clusters of an earlier vertex-wise analysis with a database of task-based fMRI and voxel-based morphometric statistical maps and associate them with relevant key words } \details{ -The \href{https://nimare.readthedocs.io/en/stable/index.html}{NiMARE} python module is used for the imaging decoding and is imported via the reticulate package. The function also downloads the \href{https://github.com/neurosynth/neurosynth-data}{neurosynth} database in the package's inst/extdata direcotry (~8 Mb) for the analysis. +The \href{https://nimare.readthedocs.io/en/stable/index.html}{NiMARE} python module is used for the imaging decoding and is imported via the reticulate package. The function needs the \href{https://github.com/neurosynth/neurosynth-data}{neurosynth} database in the package's inst/extdata directory to be downloaded (~8 Mb) for the analysis. To maximise the speed of processing, keywords were excluded from the original database if they were: the name of an anatomical brain region, protocol-specific descriptive words that are not meaningful out of context (e.g., “studied”, “clips”, “engaged”), and broad categories that do not specifically point to a content (“disorder”, “psychological”, “cognitive”). A full list can be obtained with the keyword_list argument. } \examples{ CTv = rbinom(20484, 1, 0.001)