View source: R/cloudvolume-reticulate.R
save_cloudvolume_meshes | R Documentation |
save_cloudvolume_meshes
saves meshes to disk.
read_cloudvolume_meshes
uses
save_cloudvolume_meshes
internally to save meshes to disk and then
reads them into memory as a neuronlist
.
save_cloudvolume_meshes(
segments,
savedir = tempfile(),
OmitFailures = TRUE,
Force = FALSE,
format = c("obj", "ply"),
...,
cloudvolume.url = getOption("fafbseg.cloudvolume.url")
)
read_cloudvolume_meshes(
segments,
savedir = NULL,
...,
cloudvolume.url = getOption("fafbseg.cloudvolume.url")
)
segments |
The segment ids to fetch (probably as a character vector) |
savedir |
Optional path to a directory in which obj format files will be stored. If not specified, a temporary directory will be created and removed at the end of the call. |
OmitFailures |
Whether to omit neurons for which |
Force |
whether to overwrite a downloaded mesh of the same name |
format |
whether to save meshes in Wavefront obj or Stanford poly format. obj is the default but ply is a simpler and more compact format. |
... |
Additional arguments passed to |
cloudvolume.url |
Optional url from which to fetch meshes normally
specified by the |
You may to use this to fetch meshes from https://flywire.ai
among other sources. You may need to select your preferred remote data
source using choose_segmentation
(see examples). Under the
hood, it uses the
CloudVolume serverless
Python client for reading data in
Neuroglancer compatible
formats. You will therefore need to have a working python3 install of
CloudVolume.
Please install the Python CloudVolume module as described at:
https://github.com/seung-lab/cloud-volume#setup. You must ensure that
you are using python3 (implicitly or explicitly) as mesh fetching from
graphene servers depends on this. This should normally work: pip3
install cloud-volume
. If you have already installed CloudVolume but it is
not found, then I recommend editing your Renviron
file to set
an environment variable pointing to the correct Python. You can do this
with usethis::edit_r_environ()
and then setting e.g.
RETICULATE_PYTHON="/usr/local/bin/python3"
.
You will normally need to set up some kind of authentication in order to
fetch data. For flywire, we recommend the function
flywire_set_token
. For other data sources or more details,
see https://github.com/seung-lab/cloud-volume#chunkedgraph-secretjson
for how to get a token and where to save it. You can either save a json
snippet to ~/.cloudvolume/secrets/cave-secret.json
or set an
environment variable (CHUNKEDGRAPH_SECRET="XXXX"
.
Finally you will also need to set an option pointing to your server. This
is most conveniently achieved using e.g.
choose_segmentation('flywire31')
, which is now the default, but for
sources without built-in support, you can also specify a full source URL,
which might look something like
options(fafbseg.cloudvolume.url='graphene://https://xxx.dynamicannotationframework.com/segmentation/xxx/xxx')
You can easily add this to your startup Rprofile
with
usethis::edit_r_profile()
.
A rgl::shapelist3d
list containing one or more mesh3d
objects named by the segment id.
choose_segmentation
. See simple_python
for installation of the necessary Python packages.
## Not run:
kcmesh=save_cloudvolume_meshes("720575940623755722", savedir=".")
kc=read.neurons(kcmesh)
## End(Not run)
## Not run:
# The very first time you access FlyWire data you need to get/store a token
flywire_set_token()
# Each R session, you should choose the default segmentation you want
choose_segmentation('flywire31')
pmn1.flywire=read_cloudvolume_meshes("720575940623979522")
pmn1.fafb=read.neuron.catmaid(5321581)
# Read and plot sample KCs from a FlyWire (short) URL
u="https://ngl.flywire.ai/?json_url=https://globalv1.flywire-daf.com/nglstate/6230669436911616"
kcs=read_cloudvolume_meshes(u)
kcs
plot3d(kcs)
nclear3d()
plot3d(pmn1.fafb, col='red', lwd=2, WithNodes = F)
wire3d(pmn1.flywire)
# you can select specific locations like so
library(elmr)
# CATMAID URL
open_fafb(pmn1.flywire[[1]], open=F)
# CATMAID coords to paste into PIN location box
cat(xyzmatrix(catmaid::catmaid_parse_url(open_fafb(pmn1.flywire[[1]], open=F))), sep=',')
# Neuroglancer coords (raw pixels not nm)
open_fafb_ngl(pmn1.flywire[[1]], open=F, coords.only = T)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.