ngl_encode_url: Encode scene information into a neuroglancer URL

View source: R/urls.R

ngl_encode_urlR Documentation

Encode scene information into a neuroglancer URL

Description

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.

Usage

ngl_encode_url(body, baseurl = NULL, auto_unbox = TRUE, ...)

## S3 method for class 'ngscene'
as.character(x, ...)

Arguments

body

A text file or character vector with JSON data or an R list object of class ngscene.

baseurl

A URL specifying the neuroglancer server (if missing, uses the URL from which body was decoded if that was recorded or, failing that, options("fafbseg.sampleurl")). You can use any neuroglancer URL as will be appropriately truncated if it encodes scene information.

auto_unbox

For expert use only. See toJSON for details.

...

Additional arguments for toJSON

x

the ngscene object to be converted to a URL

Details

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.

Value

Character vector containing encoded URL

See Also

URLencode, open_fafb_ngl, toJSON

Other neuroglancer-urls: flywire_ids(), flywire_scene(), ngl_blank_scene(), ngl_decode_scene(), ngl_segments(), open_fafb_ngl()

Examples


# 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)

natverse/fafbseg documentation built on Nov. 11, 2024, 9:50 p.m.