Generate URLs to open FAFB CATMAID in browser at a given XYZ location

open_fafb(
x,
s = rgl::select3d(),
mirror = FALSE,
sample = elmr::FAFB,
rowwise = NA,
open = interactive() & !rowwise,
zoom = 1,
active_skeleton_id = NULL,
active_node_id = NULL,
server = NULL,
...
)

## Arguments

x A numeric vector or any object compatible with xyzmatrix (see details) Optional selection function of the type returned by select3d Whether to mirror the point to the opposite side of the brain The template brain space associated with the coordinates in x When rowwise=TRUE each point in x is converted to a separate URL. Whether to open the url in the browser or simply return it. Defaults to TRUE when R is running in interactive mode. The CATMAID zoom factor (defaults to 1) Set highlighted skeleton and node in CATMAID. Optional string or catmaid_connection that specifies the server URL (otherwise a hardcoded URL will be used). Additional arguments to be added to URL.

## Details

Note that the default behaviour is that if object x contains exactly one point then a single URL will be generated and by default CATMAID will be opened immediately at that location. If there is more than 1 point, by default the function will stop and wait for the user to make an interactive selection in a rgl window.

You can control this behaviour by using the open and rowwise arguments. When open=FALSE, then the URLs will be returned but not opened in a web browser. If rowwise=TRUE (i.e. multiple URLs are being generated) then open will be set to FALSE.

When rowwise=TRUE each point in x is converted to a separate URL. As a special case, if x is a data.frame generated by catmaid_get_treenodes_detail then URLs will be generated for every row (i.e. each treenode). See examples for details.

xform_brain, catmaid_get_treenodes_detail

## Examples

open_fafb(c(316, 143, 26), sample=JFRC2013, open=FALSE)#> [1] "https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=61259&yp=291206&xp=580356&tool=tracingtool&sid0=5&s0=1.000000"library(nat)
if (FALSE) {
open3d()
plot3d(kcs20)
# waits for user to draw a selection rectangle
open_fafb(kcs20, sample=FCWB)
# same but mirrors selected points to opposite hemisphere
open_fafb(kcs20, sample=FCWB, mirror=TRUE)

open_fafb(kcs20, sample=FCWB, server="https://bigbrain.org/tracing")
# Uses last CATMAID connection to specify URL to open
}

# \donttest{
# make one URL for each row of the input
open_fafb(matrix(runif(n=6, max=1000), ncol = 3), rowwise=TRUE)#> [1] "https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=7&yp=601&xp=81&tool=tracingtool&sid0=5&s0=1.000000"
#> [2] "https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=466&yp=157&xp=834&tool=tracingtool&sid0=5&s0=1.000000"# }

# \donttest{
## Special case using catmaid_get_treenodes_detail() as input
# fetch a neuron and extract the node ids for a given tag
tagged = n$tags[['TODO']] tagged_details <- catmaid_get_treenodes_detail(tagged) # now find FAFB URLs tagged_details$url <- open_fafb(tagged_details)
# take a look at results
#> 1     3068665   3068660 466369 232377 41360          5     -1   16   1459444379
#> 2     3068677   3068676 466173 234685 40000          5     -1   16   1459444409
#> 3     3068690   3068688 466322 231543 40080          5     32   16   1568560341
#> 4     3068757   3068753 464086 240916 39280          5     32   16   1568560345
#> 5     3068829   3068826 465499 244391 35480          5     81   16   1568560341
#> 6     3073189   3073187 463304 248051 33320          5    198   16   1568560341
#>   user_id
#> 1      26
#> 2      26
#> 3      26
#> 4      26
#> 5      26
#> 6      61
#>                                                                                                                                                                  url
#> 1 https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=41360&yp=232377&xp=466369&tool=tracingtool&sid0=5&s0=1.000000&active_skeleton_id=16&active_node_id=3068665
#> 2 https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=40000&yp=234685&xp=466173&tool=tracingtool&sid0=5&s0=1.000000&active_skeleton_id=16&active_node_id=3068677
#> 3 https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=40080&yp=231543&xp=466322&tool=tracingtool&sid0=5&s0=1.000000&active_skeleton_id=16&active_node_id=3068690
#> 4 https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=39280&yp=240916&xp=464086&tool=tracingtool&sid0=5&s0=1.000000&active_skeleton_id=16&active_node_id=3068757
#> 5 https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=35480&yp=244391&xp=465499&tool=tracingtool&sid0=5&s0=1.000000&active_skeleton_id=16&active_node_id=3068829
#> 6 https://neuropil.janelia.org/tracing/fafb/v14/?pid=1&zp=33320&yp=248051&xp=463304&tool=tracingtool&sid0=5&s0=1.000000&active_skeleton_id=16&active_node_id=3073189# }

if (FALSE) {
# copy results to clipboard e.g. to paste into a spreadsheet
library(clipr)
write_clip(tagged_details)
}