Skip to content

Commit 2e1bb36

Browse files
committed
Make catmaid_neuronnames work for NA skids
* helped with a bug in catnat (jefferislab/catnat#6)
1 parent 7dea1ce commit 2e1bb36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/catmaid_metadata.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#' @seealso \code{\link{catmaid_fetch}}, \code{\link{catmaid_skids}}
1515
catmaid_get_neuronnames<-function(skids, pid=1, conn=NULL, ...) {
1616
skids=catmaid_skids(skids, conn = conn, pid=pid)
17+
# -1 indicates a bad skid but does not trigger an error like an NA value
18+
skids[is.na(skids)]=-1L
1719
post_data=list(pid=pid)
1820
post_data[sprintf("skids[%d]", seq_along(skids))]=as.list(skids)
1921
path=sprintf("/%d/skeleton/neuronnames", pid)
@@ -24,7 +26,9 @@ catmaid_get_neuronnames<-function(skids, pid=1, conn=NULL, ...) {
2426
if(length(missing_names))
2527
res[missing_names]=NA_character_
2628
# ensure that return values are in order that was passed in
27-
res[as.character(skids)]
29+
res=res[as.character(skids)]
30+
names(res)[names(res)=="-1"]="NA"
31+
res
2832
}
2933

3034

0 commit comments

Comments
 (0)