Neuropil meshes (connectomekg.neuropil_meshes)¶
connectomekg.neuropil_meshes
¶
Neuropil surface meshes: fetched once from FlyWire's public bucket, cached per dataset.
FAFB v783 synapses are assigned to neuropils by volumes mapped from the JFRC2
template brain into FlyWire space (Ito et al. 2014, Neuron 81, 755-765). The
surfaces of those volumes are published as legacy Neuroglancer precomputed
meshes at gs://flywire_neuropil_meshes/neuropils/neuropil_mesh_v141_v6:
one manifest and one binary fragment per integer id, with no names.
:data:FAFB_783_MESH_NAMES names them. It was derived by matching every v6
fragment, vertex set for vertex set, against the named PLY copies fafbseg
packages from the same source (fafbseg/data/JFRC2NP.surf.fw.zip, whose
README records the v6 origin): 78 of 78 exact, 78 distinct names. The one
v783 neuropil without a mesh is UNASGD, the synapses no volume claimed.
Do not substitute fafbseg/data/volume_name_dict.json: it numbers the
synapse-assignment volume, not these meshes, and matches none of them.
Vertices are nanometres in FlyWire (FAFB14.1) space, the same frame as the
graph's neuron coordinates, so a mesh goes through
:meth:connectomekg.scene.WorldFrame.to_world unchanged.
decode_fragment(data)
¶
Decode one legacy Neuroglancer precomputed mesh fragment.
The format is a little-endian uint32 vertex count, that many float32
x y z triples, then uint32 vertex-index triangles to the end.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
The fragment's bytes. |
required |
Returns:
| Type | Description |
|---|---|
Mesh
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the bytes are not a well-formed fragment. |
Source code in src/connectomekg/neuropil_meshes.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
fetch_neuropil_meshes(dataset_id, dest, *, fetch=_http_get, progress=None)
¶
Download a dataset's neuropil meshes and cache them as one .npz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
Dataset id, e.g. |
required |
dest
|
str | Path
|
The cache file to write, usually
|
required |
fetch
|
Callable[[str], bytes]
|
Returns the bytes at a URL; the default is a plain HTTPS GET. |
_http_get
|
progress
|
Callable[[str], None] | None
|
Called with a short message every 20 meshes. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dataset has no mesh source or a fragment is malformed. |
Source code in src/connectomekg/neuropil_meshes.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
has_mesh_source(dataset_id)
¶
Whether a dataset has published neuropil meshes to fetch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
Dataset id, e.g. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/connectomekg/neuropil_meshes.py
75 76 77 78 79 80 81 | |
load_neuropil_meshes(path)
¶
Read a cache written by :func:fetch_neuropil_meshes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Mesh]
|
|
Source code in src/connectomekg/neuropil_meshes.py
160 161 162 163 164 165 166 167 168 | |
neuropil_mesh_path(db_path)
¶
Where a dataset's neuropil mesh cache lives: beside its graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_path
|
str | Path
|
The dataset's |
required |
Returns:
| Type | Description |
|---|---|
Path
|
|
Source code in src/connectomekg/neuropil_meshes.py
84 85 86 87 88 89 90 | |