Low level access to the Flywire CAVE annotation system
Usage
flywire_cave_client(
datastack_name = getOption("fafbseg.cave.datastack_name", "flywire_fafb_production")
)Arguments
- datastack_name
defaults to the value selected by
choose_segmentationand to "flywire_fafb_production" when that is missing. See https://global.daf-apis.com/info/ for other options.
Details
This depends on installation of the Python caveclient library. See
flywire_cave_query for more details.
The (relatively expensive) Python caveclient object is memoised for
12h per session, but its materialisation version is kept current
independently. caveclient pins the version at first use and never refreshes
it, so a long-lived client could otherwise drift onto a version that later
expires server-side, at which point queries silently return no rows.
flywire_cave_client therefore re-checks the latest version at most
once every 15 minutes and updates the client in place when it advances,
printing a message when it does. Tune the interval with
options(fafbseg.cave.version.ttl = <seconds>) and the client
lifetime with options(fafbseg.cave.client.ttl = <seconds>).
By default the caveclient logger level is set to "WARNING", to
suppress routine INFO that might otherwise be captured by R side
functions. Genuine caveclient WARNING / ERROR records still
propagate. Override via options(fafbseg.caveclient.loglevel =
"INFO") (or any other Python logging level name).
Examples
# \donttest{
fac <- flywire_cave_client()
fac$annotation$get_tables()
#> [1] "synapses_v3"
#> [2] "synaptic_clefts"
#> [3] "hierarchical_neuron_annotations"
#> [4] "fly_synapses_neuropil_v6"
#> [5] "neuron_information_v2"
#> [6] "neuron_information_vtest"
#> [7] "synapses_nt_v1"
#> [8] "proofreading_review_public_vtest"
#> [9] "braincircuits_annotation_test"
#> [10] "valid_synapses_nt_vtest"
#> [11] "neuron_information_v1"
#> [12] "nuclei_v1"
#> [13] "valid_synapses_nt_v2"
#> [14] "synapses_v3_neuropil_v6"
#> [15] "hemilineages"
#> [16] "cambridge_celltypes_v2"
#> [17] "braincircuits_annotation_test2"
#> [18] "hemibrain_matched_types"
#> [19] "neuron_representative_coordinates_v1"
#> [20] "hierarchical_cell_types_v1"
#> [21] "cambridge_celltypes"
#> [22] "proofreading_status_public_v1"
#> [23] "proofreading_review_public_v1"
#> [24] "proofread_neurons"
fac$annotation$get_table_metadata('nuclei_v1')
#> $id
#> [1] 8
#>
#> $schema_type
#> [1] "nucleus_detection"
#>
#> $table_name
#> [1] "nuclei_v1__fly_v31"
#>
#> $valid
#> [1] TRUE
#>
#> $created
#> [1] "2021-08-13T18:01:55.211016"
#>
#> $deleted
#> NULL
#>
#> $user_id
#> [1] "2"
#>
#> $description
#> [1] "\nFlyWire nucleus description\nNucleus version: 20210322\n\nNuclei in this table consist of center points (in nm), volume (in μm3), and bounding boxes (in nm).\n\nThe nucleus segmentation was generated by Shang Mu (smu@princeton.edu, Seung Lab at Princeton University) using a 2D convolutional neural network (CNN) and heuristic interpolations. The training data was assembled from annotations by Selden Koolman, Merlin Moore, Sarah Morejohn, Ben Silverman, Kyle Willie, Ryan Willie, Szi-chieh Yu and Shang Mu.\n\nAs this data was generated using a 2D, rather than 3D, neural network, defects are present in the detected nuclei, particularly where there are large defects in section alignment or a number of consecutive missing sections.\n\nFalse positive fragments, nucleus fragments and partial nuclei are the most common type of defects. A simple, rudimentary method for cleaning up is to disregard small fragments by thresholding by segment size or by the z-dimension of the bounding boxes. A size threshold of 2000 voxels (0.08 μm3) was already applied in producing this segmentation.\n\nA minimal number of nucleus merger instances have been observed, caused by section alignment defects or close nuclei appositions in certain non-neuronal cell clusters.\n\nWhen using the nucleus annotations, please acknowledge Shang Mu and let him know about your use case.\n\nWe encourage making (and using) improvements to this data based on the information provided (for example, utilizing bounding box dimensions and/or the segmentation to find and merge incorrectly split partial nuclei), and such improvements should be discussed with Shang. Data derived solely from this work should be similarly made available on this platform at the time of use in any publication.\n"
#>
#> $notice_text
#> NULL
#>
#> $reference_table
#> NULL
#>
#> $flat_segmentation_source
#> [1] "precomputed://gs://neuroglancer/drosophila_v0/nucleus/v5_z_intp_intp/seg"
#>
#> $write_permission
#> [1] "PRIVATE"
#>
#> $read_permission
#> [1] "PUBLIC"
#>
#> $last_modified
#> [1] "2022-10-25T19:49:21.621037"
#>
#> $segmentation_source
#> [1] ""
#>
#> $pcg_table_name
#> [1] "fly_v31"
#>
#> $last_updated
#> [1] "2026-10-02T19:00:00.094369"
#>
#> $annotation_table
#> [1] "nuclei_v1"
#>
#> $voxel_resolution
#> [1] 1 1 1
#>
# annotation tables that have been materialised in order to map XYZ
# points onto current root ids (and immutable supervoxel ids)
# typically the same as fac$annotation$get_tables()
fac$materialize$get_tables()
#> [1] "synapses_v3"
#> [2] "synaptic_clefts"
#> [3] "fly_synapses_neuropil_v6"
#> [4] "hierarchical_neuron_annotations"
#> [5] "neuron_information_v2"
#> [6] "neuron_information_vtest"
#> [7] "synapses_nt_v1"
#> [8] "proofreading_review_public_vtest"
#> [9] "braincircuits_annotation_test"
#> [10] "valid_synapses_nt_vtest"
#> [11] "nuclei_v1"
#> [12] "valid_synapses_nt_v2"
#> [13] "synapses_v3_neuropil_v6"
#> [14] "hemilineages"
#> [15] "cambridge_celltypes_v2"
#> [16] "neuron_representative_coordinates_v1"
#> [17] "cambridge_celltypes"
#> [18] "proofreading_status_public_v1"
#> [19] "proofreading_review_public_v1"
#> [20] "proofread_neurons"
info=fac$info$get_datastack_info()
# the default synapse table for the dataset
info$synapse_table
#> [1] "synapses_nt_v1"
# }
if (FALSE) { # \dontrun{
# get help on python cave client
reticulate::py_help(fac$info$get_datastack_info)
} # }