dvid
dvid copied to clipboard
Add 'upstream' and 'downstream' options to labelsz
[This is a low-priority request, but it might be relatively easy to implement.]
In addition to returning the number of PreSyn
or PostSyn
on a body, it would be good to know how many "relationships" those PreSyn
or PostSyn
have. For PreSyn
, the number of relationships indicates the total downstream synapse partners. The number of relationships on the PostSyn
indicates the total upstream synapse partners.
(Okay, in our data, every PostSyn
has only one relationship, so technically upstream
will be redundant with the PostSyn count itself. But for PreSyn
, it's not redundant -- typically downstream
will be much larger than the PreSyn
count. And it's nice to have both for symmetry's sake.)
FWIW, neuprint includes downstream
and upstream
counts, too.
Edit: Maybe instead of upstream
and downstream
, you should just pluck the keys from the JSON: PreSynTo
and PostSynTo
.
Just for illustration, here's a sample of synapse annotation data. Counting the items in the Rels
list gives you the downstream
count or upstream
count, depending on whether the annotation kind is PreSyn
or PostSyn
.
[
{"Pos":[5750,20489,20542], "Kind":"PostSyn", "Tags":[], "Prop":{"conf":"0.473165","user":"$fpl"}, "Rels":[{"Rel":"PostSynTo","To":[5751,20450,20556]}]},
{"Pos":[5940,20510,20517], "Kind":"PostSyn", "Tags":[], "Prop":{"conf":"0.594747","user":"$fpl"}, "Rels":[{"Rel":"PostSynTo","To":[5941,20486,20536]}]},
{"Pos":[5951,20504,20540], "Kind":"PostSyn", "Tags":[], "Prop":{"conf":"0.741894","user":"$fpl"}, "Rels":[{"Rel":"PostSynTo","To":[5941,20486,20536]}]},
{"Pos":[5941,20486,20536], "Kind":"PreSyn", "Tags":[], "Prop":{"conf":"0.99","user":"$fpl"},
"Rels":[
{"Rel":"PreSynTo","To":[5952,20499,20517]},{"Rel":"PreSynTo","To":[5960,20466,20517]},
{"Rel":"PreSynTo","To":[5963,20490,20517]},{"Rel":"PreSynTo","To":[5940,20510,20517]},
{"Rel":"PreSynTo","To":[5967,20484,20540]},{"Rel":"PreSynTo","To":[5951,20504,20540]},
{"Rel":"PreSynTo","To":[5973,20453,20553]}]
},
{"Pos":[5952,20499,20517], "Kind":"PostSyn", "Tags":[], "Prop":{"conf":"0.858438","user":"$fpl"}, "Rels":[{"Rel":"PostSynTo","To":[5941,20486,20536]}]},
]
To be a little more explicit, here's the documentation for GET .../count
. I want addtional options for the <index type>
argument. And so on for the other labelsz endpoints.
GET <api URL>/node/<UUID>/<data name>/count/<label>/<index type>
Returns the count of the given annotation element type for the given label.
The index type may be any annotation element type ("PostSyn", "PreSyn", "Gap", "Note"),
the catch-all for synapses "AllSyn", or the number of voxels "Voxels".
For synapse indexing, the labelsz data instance must be synced with an annotations instance.
(future) For # voxel indexing, the labelsz data instance must be synced with a labelvol instance.
Example:
GET <api URL>/node/3f8c/labelrankings/size/21847/PreSyn
Returns:
{ "Label": 21847, "PreSyn": 81 }
Might be nice to have synweight
, too (upstream + downstream
).
Here's a pure-python function that achieves the same thing, but with the full synapse list from the synapses
instance.