ngl_encode_url | R Documentation |
ngl_encode_url
converts an R list containing a
neuroglancer scene into a URL that you can open in your browser.
as.character.ngscene
is another way to convert a
neuroglancer scene object to a URL.
ngl_encode_url(body, baseurl = NULL, auto_unbox = TRUE, ...)
## S3 method for class 'ngscene'
as.character(x, ...)
body |
A text file or character vector with JSON data or an R list
object of class |
baseurl |
A URL specifying the neuroglancer server (if missing, uses the
URL from which |
auto_unbox |
For expert use only. See |
... |
Additional arguments for |
x |
the |
We take pains to ensure that entries that neuroglancer expects to be
JSON arrays are (including segments
and hiddenSegments
) are
always mapped to a JSON array (even when length 1).
The default baseurl depends on the current segmentation chosen by
choose_segmentation
.
Character vector containing encoded URL
URLencode
, open_fafb_ngl
,
toJSON
Other neuroglancer-urls:
flywire_ids()
,
flywire_scene()
,
ngl_blank_scene()
,
ngl_decode_scene()
,
ngl_segments()
,
open_fafb_ngl()
# get sample FlyWire URL
fw_url=with_segmentation('flywire31', getOption('fafbseg.sampleurl'))
# only a 0 (dummy) segment id present
ngl_segments(fw_url)
#
fw_sc=ngl_decode_scene(fw_url)
# add a segment
fw_sc$layers[[2]]$segments=union(fw_sc$layers[[2]]$segments,
"720575940626877799")
# convert back to a URL, nb this depends on choose_segmentation
ngl_encode_url(fw_sc)
# another way to do this, which long time R users may find more intuitive
as.character(fw_sc)
## Not run:
# open in your default browser
browseURL(ngl_encode_url(fw_sc))
# ... or
browseURL(as.character(fw_sc))
## End(Not run)
## Not run:
# copy JSON scene information from {} symbol at top right of neuroglancer
# now make a permanent URL for the scene
ngl_encode_url(clipr::read_clip())
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.