Skip to content

Commit

Permalink
Fix bug in neuprint_get_synapses(progress=T)
Browse files Browse the repository at this point in the history
* NULL roi was not being handled correctly
* tryCatch was masking a programming logic error again (see #84)
* progress on #90
  • Loading branch information
jefferis committed Feb 29, 2020
1 parent f708aa8 commit 78f65eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/synapses.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
neuprint_get_synapses <- function(bodyids, roi = NULL, progress = FALSE, dataset = NULL, conn = NULL, ...){
conn = neuprint_login(conn)
bodyids = neuprint_ids(bodyids, conn = conn, dataset = dataset)
if (is.null(roi)) {
roi = ""
} else{
if (!is.null(roi)) {
possible.rois = neuprint_ROIs(dataset = dataset, conn = conn, ...)
if (sum(!roi %in% possible.rois) > 0) {
stop(
Expand All @@ -51,9 +49,11 @@ neuprint_get_synapses <- function(bodyids, roi = NULL, progress = FALSE, dataset
progress = FALSE,
dataset = dataset,
conn = conn, ...),
error = function(e) NULL)))
error = function(e) {warning(e); NULL})))

This comment has been minimized.

Copy link
@jefferis

jefferis Feb 29, 2020

Author Contributor

@alexanderbates: I think this is the approach one should generally take to error handling. Errors are converted to warnings. This is not too intrusive, because if >10 warnings pile up, a single warning is displayed and you can go and see the first 50 with warnings().

This comment has been minimized.

Copy link
@jefferis

jefferis Feb 29, 2020

Author Contributor

See #84

return(d)
}
if(is.null(roi)) roi <- ""

cypher.post = sprintf(paste("WITH %s AS bodyIds UNWIND bodyIds AS bodyId",
"MATCH (a:`%s`)-[:Contains]->(c:SynapseSet)-[:Contains]->(s:Synapse)<-[:SynapsesTo]-(:Synapse)<-[:Contains]-(:SynapseSet)<-[:Contains]-(b:`%s`)",
"WHERE a.bodyId=bodyId AND (s.type='post') %s",
Expand Down

0 comments on commit 78f65eb

Please sign in to comment.