Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an argument to bypass roi checks #103

Merged
merged 15 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions R/info.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,25 @@ neuprint_version <- function(conn = NULL, ...){
#' @description Get the regions of interest (ROIs) used in a neuPrint project
#' @param superLevel whether not to show 'superlevel' ROIs - ROIs composed of other ROIs.
#' If set to NULL, both low-level and superlevel ROIs are returned.
#' @param fromNeuronFields : Whether to use fields of :Neuron nodes to fetch the ROIs. If
#' FALSE (the default), use the dataset metadata instead. If TRUE, the \code{superLevel} argument
#' is ignored
#' @param ... methods passed to \code{neuprint_login}
#' @inheritParams neuprint_fetch_custom
#' @seealso \code{\link{neuprint_login}}, \code{\link{neuprint_datasets}}
#' @export
neuprint_ROIs <- function(superLevel = FALSE, dataset = NULL, conn = NULL, ...){
neuprint_ROIs <- function(superLevel = FALSE, dataset = NULL, fromNeuronFields= FALSE,conn = NULL, ...){
if (fromNeuronFields){
rois <- neuprint_get_fields(possibleFields = c("bodyId", "pre", "post",
"upstream", "downstream",
"status", "statusLabel",
"cropped", "instance", "name",
"size", "type", "cellBodyFiber",
"somaLocation", "somaRadius","roiInfo"),
limit=200,
negateFields=TRUE,
dataset = NULL, conn = NULL, ...)
}else{
ds = neuprint_datasets(conn=conn, ...)
conn=neuprint_login(conn)
dataset = check_dataset(dataset, conn=conn)
Expand All @@ -77,7 +91,7 @@ neuprint_ROIs <- function(superLevel = FALSE, dataset = NULL, conn = NULL, ...){
if(is.null(rois)){
rois = ds[[1]]$ROIs
}
}
}}
sort(rois)
}

Expand Down
7 changes: 6 additions & 1 deletion R/name.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ neuprint_ids <- function(x, mustWork=TRUE, unique=TRUE, fixed=TRUE, conn=NULL, d
#' @title Get available metadata fields for Neuron nodes
#' @return a vector of available fields
#' @param possibleFields : field names to choose from
#' @param limit : Max length of the server's response (used to speed up the query/adapt to different scenarios)
#' @param negateFields : Whether to include (FALSE, the default) or exclude \code{possibleFields}
#' @inheritParams neuprint_ROI_hierarchy
#' @export
#' @examples
Expand All @@ -368,9 +370,12 @@ neuprint_get_fields <- function(possibleFields = c("bodyId", "pre", "post",
"cropped", "instance", "name",
"size", "type", "cellBodyFiber",
"somaLocation", "somaRadius"),
limit=20,
negateFields=FALSE,
dataset = NULL, conn = NULL, ...){
cypher <- sprintf("MATCH (n :`Neuron`) UNWIND KEYS(n) AS k RETURN DISTINCT k AS neuron_fields LIMIT 20")
cypher <- sprintf("MATCH (n :`Neuron`) UNWIND KEYS(n) AS k RETURN DISTINCT k AS neuron_fields LIMIT %s",limit)
fields <- unlist(neuprint_fetch_custom(cypher=cypher, cache=TRUE, conn=conn, dataset = dataset, ...)$data)
if (negateFields){return(fields[!(fields %in% possibleFields)])}
return(fields[fields %in% possibleFields])
}

Expand Down
4 changes: 2 additions & 2 deletions R/roi.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ neuprint_ROI_mesh <- function(roi, dataset = NULL, conn = NULL, ...){
}

# hidden
neuprint_check_roi <- function(rois, superLevel = NULL, dataset = NULL, conn = NULL, ...){
possible.rois = neuprint_ROIs(dataset=dataset,conn=conn, superLevel = superLevel, ...)
neuprint_check_roi <- function(rois, superLevel = NULL, fromNeuronFields = TRUE,dataset = NULL, conn = NULL, ...){
possible.rois = neuprint_ROIs(dataset=dataset,conn=conn, fromNeuronFields = fromNeuronFields, superLevel = superLevel, ...)
if(!all(rois%in%possible.rois)){
stop("Regions of interest provided that are not demarcated in dataset ", dataset, " for server ", neuprint_login(conn)$server,
". Please call neuprint_ROIs(superLevel = NULL) to see the available ROIs.")
Expand Down
12 changes: 11 additions & 1 deletion man/neuprint_ROIs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/neuprint_get_fields.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.