Fetch position and other information for arbitrary treenode ids

catmaid_get_treenodes_detail(
  tnids = NULL,
  labels = NULL,
  skids = NULL,
  pid = 1,
  conn = NULL,
  raw = FALSE,
  ...
)

Arguments

tnids

One or more (integer) treenode ids

labels

One or more (character) labels with which nodes must be tagged

skids

One or more skeleton ids or an expression compatible with catmaid_skids (see Details for advice re many skids)

pid

project id (default 1)

conn

the catmaid_connection object

raw

Whether to return completely unprocessed data (when TRUE) or to convert the nodes and connectors lists into processed data.frames (when FALSE, the default)

...

Additional arguments passed to the catmaid_fetch function.

Value

  • treenode_id,

  • parent_id,

  • x,

  • y,

  • z,

  • confidence,

  • radius,

  • skid,

  • edition_time,

  • user_id

Details

The key feature of this function is that allows you to fetch information for arbitrary tree nodes that do not need to be from the same skeleton. Furthermore the nodes can be defined by the presence of labels (tags) or by a skeleton id. labels and skids specifiers can be combined in order e.g. to find details for the somata for a given set of skeleton ids. However these queries are slow for more than a few hundred skids, at which point it is better to fetch using the label and then filter by skid post hoc in R.

Examples

# \donttest{
# details for 3 nodes from two different skeletons
catmaid_get_treenodes_detail(c(9943214L, 25069047L, 12829015L))
#>   treenode_id parent_id       x       y     z confidence radius     skid
#> 1     9943214        NA 65439.8 20611.2 41250          5   1911  4453485
#> 2    25069047  10983327 53296.5 14791.1 42650          5     -1  4453485
#> 3    12829015  12829014 59222.2 65869.2 51150          5     -1 10418394
#>   edition_time user_id
#> 1   1625302974      18
#> 2   1625302974      71
#> 3   1625302974      18

# example label search
tosoma=catmaid_get_treenodes_detail(labels="to soma")
# }

if (FALSE) {
# If you have a lot of skids to query you will need to break up your queries
# into smaller chunks. You could do this like so:
catmaid_get_treenodes_detail_chunked <- function(skids, chunksize=300, chunkstoread=NULL, ...) {
  nchunks=ceiling(length(skids)/chunksize)
  chunks=rep(seq_len(nchunks), rep(chunksize, nchunks))[seq_along(skids)]
  
  l=list()
  if(is.null(chunkstoread)) chunkstoread=seq_len(nchunks)
  pb <- progress::progress_bar$new(total = length(skids),
                                   format = "  :current/:total [:bar]  eta: :eta",
                                   show_after=1)
  
  for(i in chunkstoread) {
    pb$tick(len = sum(chunks==i))
    l[[length(l)+1]]=catmaid_get_treenodes_detail(skids=skids[chunks==i], ...)
  }
  dplyr::bind_rows(l)
}

}