Skip to content

Commit 70c7dfd

Browse files
committed
Add "get_nearest_node" call.
1 parent 2a452c3 commit 70c7dfd

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

pymaid/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,10 @@ def _get_node_labels_url(self, **GET):
692692
"""Generate url for retrieving node infos (POST)."""
693693
return self.make_url(self.project_id, 'labels-for-nodes', **GET)
694694

695+
def _get_nearest_node_url(self, **GET):
696+
"""Generate url for retrieving nearest node."""
697+
return self.make_url(self.project_id, 'nodes', 'nearest', **GET)
698+
695699
def _get_skeleton_nodes_url(self, skid, **GET):
696700
"""Generate url for retrieving skeleton nodes.
697701

pymaid/fetch/__init__.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
'get_landmarks',
9494
'get_landmark_groups',
9595
'get_skeleton_ids',
96+
'get_nearest_node'
9697
]
9798

9899
# Set up logging
@@ -4726,3 +4727,41 @@ def get_skeleton_change(x, chunk_size=50, remote_instance=None):
47264727
pbar.update(len(ch))
47274728

47284729
return change
4730+
4731+
4732+
4733+
4734+
@cache.undo_on_error
4735+
def get_nearest_node(x, y, z, skeleton_id=None, neuron_id=None, remote_instance=None):
4736+
"""Get split and merge history of skeletons.
4737+
4738+
Parameters
4739+
----------
4740+
x : X coordinate of query location.
4741+
y : Y coordinate of query location.
4742+
z : Z coordinate of query location.
4743+
skeleton_id : Result treenode has to be in this skeleton. (optional)
4744+
neuron_id : Result treenode has to be in this neuron. (optional, altenrate to skeleton_id)
4745+
remote_instance : CatmaidInstance, optional
4746+
If not passed directly, will try using global.
4747+
4748+
Returns
4749+
-------
4750+
node
4751+
Nearest node.
4752+
4753+
"""
4754+
remote_instance = utils._eval_remote_instance(remote_instance)
4755+
4756+
GET = {'x': x, 'y': y, 'z': z}
4757+
4758+
if skeleton_id:
4759+
GET['skeleton_id'] = skeleton_id
4760+
if neuron_id:
4761+
GET['neuron_id'] = neuron_id
4762+
4763+
url = remote_instance._get_nearest_node_url(**GET)
4764+
4765+
resp = remote_instance.fetch(url, disable_pbar=True)
4766+
4767+
return resp

0 commit comments

Comments
 (0)