fetch_shortest_paths intermediate_criteria

19 views
Skip to first unread message

Joel Butterwick

unread,
Nov 23, 2021, 9:07:42 AM11/23/21
to neuPrint
Dear all,

I am trying to figure out how intermediate criteria is handled by fetch_shortest_paths. I would like to specify a list of neurons and find only paths that contain those neurons, but not necessarily all of those neurons. Does anyone know how to do this?

Here is what I tried (using a Jupyter notebook, hemibrain:v1.2.1):

If I fetch paths using
fetch_shortest_paths(1734350788,707116522,min_weight=1,intermediate_criteria=NC(status="Traced"))
then I find 229 paths, the first is [1734350788,5813021452,547552266,707116522]

If I instead use
intermediate_criteria=NC(bodyId=[5813021452,547552266],status="Traced")
then it finds only one path. So far so good - it finds the only path that contains the intermediates.

I can also use
intermediate_criteria=NC(bodyId=[1796817841,5813021452,547552266],status="Traced")
and still get only one path, which does not contain 1796817841 (in fact there are no paths found that contain this neuron in the first search). So I thought that having extra neurons in intermediate criteria would be ok and just ignored as long as the path only contained other neurons in intermediate_criteria.

But if I add one more unused neuron by using
intermediate_criteria=NC(bodyId=[1796817841,5813021452,547552266,818983130],status="Traced")
then no paths are found. So having two unused neurons is a problem.

Any advice?

Thanks,
Joel

Stuart Berg

unread,
Nov 24, 2021, 8:33:16 PM11/24/21
to neuPrint
Hi Joel,

Thanks for the clear description and reproducible test case. You've uncovered a bug in fetch_shortest_paths().  It generated incorrect cypher code if the intermediate criteria listed more than 3 bodies.  (For "long" lists of bodies, we generate slightly different cypher than we do for short lists of 3 or fewer.)

I've just pushed a fix to the github repository:

The fix will be included in the next release of neuprint-python, sometime this week or next.

Best regards,
Stuart

PS -- With the fix, here is the result I see with your example:

In [36]: ic = NC(bodyId=[1796817841,5813021452,547552266,818983130], status="Traced")
    ...: fetch_shortest_paths(1734350788, 707116522, 1, ic)
Out[36]:
   path      bodyId     type  weight
0     0  1734350788  DA1_lPN       0
1     0  5813021452    KCg-m       2
2     0   547552266   MBON33       1
3     0   707116522    DNa10       1


Joel Butterwick

unread,
Nov 30, 2021, 12:38:28 PM11/30/21
to neuPrint
Thank you so much for the quick fix Stuart!

I can confirm that the updated neuprint-python (0.4.16) now finds the path with extra neurons in intermediate_criteria.

Best wishes,
Joel

Reply all
Reply to author
Forward
0 new messages