ngl_layers | R Documentation |
ngl_layers
extract the neuroglancer layers with
convenience options for selecting layers by characteristics such as
visibility, type etc.
ngl_layers<-
sets the layers element of a
ngscene
object, taking care of name/class details.
+.ngscene
adds segments or layers to a neuroglancer scene
-.ngscene
removes segments or whole layers from a
neuroglancer scene. It does not complain if the segment is not present.
ngl_layers(x, subset = NULL)
ngl_layers(x) <- value
## S3 method for class 'ngscene'
x + y
## S3 method for class 'ngscene'
x - y
x |
a neuroglancer scene object (see |
subset |
an expression (evaluated in the style of subset.dataframe) which defined |
value |
a list specifying one or more neuroglancer layers. This will usually come from a json fragment or another parsed neuroglancer scene. See examples. |
y |
Segments or layers to add or remove from a neuroglancer scene.
Segments are provided as character vectors or by applying
|
A list of layers with additional class nglayers
There are shortcut methods that allow you to add or subtract segments or layers from neuroglancer scenes. These are designed for convenience in interactive use, but may be a bit fragile for unusual inputs.
ngl_decode_scene
, ngl_layers
,
ngl_segments
, ngl_encode_url
u="https://ngl.flywire.ai/?json_url=https://globalv1.flywire-daf.com/nglstate/5409525645443072"
sc=ngl_decode_scene(u)
sc
names(ngl_layers(sc))
str(ngl_layers(sc))
str(ngl_layers(sc, nsegs>0))
str(ngl_layers(sc, visible==TRUE))
str(ngl_layers(sc, !visible))
# flywire segmentation
str(ngl_layers(sc, type=="segmentation_with_graph"))
# image or segmentation
str(ngl_layers(sc, type %in% c("image", "segmentation_with_graph")))
# get a sample flywire neuroglancer scene
sc=ngl_decode_scene(system.file("flywire-annotations.json" ,
package = 'fafbseg'))
sc
# save a copy
sc.orig <- sc
# remove a layer
ngl_layers(sc)=ngl_layers(sc)[-3]
# or using convenient - notation
sc.noann <- sc.orig - "annotation"
# reverse layer order
ngl_layers(sc)=ngl_layers(sc)[2:1]
# keep visible only
ngl_layers(sc) <- ngl_layers(sc, visible)
# visible + multiple segments
ngl_layers(sc) <- ngl_layers(sc, visible & nsegs>0)
# flywire segmentation
ngl_layers(sc) <- ngl_layers(sc, type=="segmentation_with_graph")
# combine layers using + convenience method
sc.noann + ngl_layers(sc.orig)['annotation']
## Not run:
# combine layers from two scenes
ngl_layers(sc) <- c(ngl_layers(sc), ngl_layers(sc2))
ngl_layers(sc) <- c(ngl_layers(sc)[-(3:4)], ngl_layers(sc2)[3:4])
ngl_layers(sc) <- c(ngl_layers(sc), ngl_layers(sc2)[-1])
ngl_layers(sc) <- c(ngl_layers(sc), ngl_layers(sc2)['annotation'])
sc
# another way to add a single scene
ngl_layers(sc)[[4]] <- ngl_layers(sc2)[[4]]
# add a new layer to a scene by parsing some JSON from the clipboard
# note the double brackets are essential here
ngl_layers(sc)[['jfrc_mesh']] <- jsonlite::fromJSON(clipr::read_clip())
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.