Skeletons¶
Convert SWC files and Neuroglancer precomputed skeleton layers to skeleton
stores, join synapse tables to them, and export back. A skeleton store holds
trees: vertices joined by parent edges. Chunk shape, --overwrite and the
export options are in Converting files.
Format |
In / out |
Extra |
Units |
|---|---|---|---|
|
in, out |
— |
the file’s, usually µm |
|
in, out |
|
nm |
zvtools convert neuron.swc neuron.zv --chunk-shape 50,50,50
from zarr_vectors_tools.convert.ingest.swc import ingest_swc
ingest_swc("neuron.swc", "neuron.zv", (50.0, 50.0, 50.0),
compute_strahler=True) # also compute_topological_depth, compute_node_kind
What the store holds¶
One object per tree, numbered from 0 in root order. A node whose parent is not in the file is a root.
object_attributes/segment_id: the precomputed segment id, or 1 to N for SWC trees (Neuroglancer treats segment 0 as background).Vertex attributes: SWC
radiusandcompartment(the SWC type); a layer’s declared vertex attributes; Python metrics such asstrahler.A plain layer’s segment properties as object attributes.
SWC
#comment lines, in the store’s SWC header.
Every name: Headers and attributes. Pyramids keep each tree one tree at every level; see Pyramids.
Neuroglancer precomputed skeleton layers¶
INPUT is the skeleton layer: a URL (gs://, s3://, https://, file://) or
a local directory holding its info. A segmentation layer is refused.
zvtools convert https://storage.googleapis.com/flywire_v141_m783/skeletons_mip_1 flywire.zv \
--anchor 17398,10448,3088 --counts 1,1,1 --coarsen 4,4 --sparsity 2,2 --chunk-scale 2,2
Layer |
Level-0 chunks |
Options |
|---|---|---|
with a |
one per |
|
without one |
|
|
The pyramid is built inside the ingest. --drop-interior-below N drops, at
coarser levels, objects of at most N vertices that touch no chunk boundary.
In Python, ingest_precomputed(source, out_store, chunk_shape=None, ...) takes
the same options as keywords (anchor, counts, segment_ids, strides for
--coarsen, …).
Synapses¶
zvtools synapses TABLE SKELETONS OUTPUT joins a CAVE-style synapse table
(.csv, .tsv or .parquet) to a skeleton store by segment_id. It writes a
point store with the skeleton store’s object ids, and adds
synapse_pre_count and synapse_post_count to the skeleton store.
zvtools synapses synapses.csv flywire.zv synapses.zv --resolution 4,4,40
Option |
Default |
Effect |
|---|---|---|
|
|
Whose segment owns each synapse. |
|
|
One column of |
|
|
nm per voxel. FlyWire and MICrONS tables are |
|
none |
A further numeric column to keep (repeatable). |
|
|
Synapses on segments the skeleton store lacks. |
|
off |
Leave the skeleton store unchanged. |
Export to SWC and precomputed¶
zvtools convert neuron.zv neuron_out.swc
SWC. One file, one tree per object. With
--object-id, OUTPUT is a directory of one file per object, named by segment id. Each tree is written from its root (parent-1) in depth-first order, node ids 1, 2, … in that order, so every parent comes before its children. Withoutradiusandcompartmentevery node gets radius 1.0 and type 3.Precomputed. A segmentation layer with
skeletons/and itssegment_properties, in nm. Segment ids come fromsegment_id, else object id + 1. Pass--unit micrometerif the store records no unit and is not in nm. Integer vertex attributes wider than 32 bits are skipped.