Skip to content

Commit

Permalink
Add "get_nearest_node" call.
Browse files Browse the repository at this point in the history
  • Loading branch information
perlman committed May 4, 2023
1 parent fb76708 commit 05fe378
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pymaid/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,10 @@ def _get_node_labels_url(self, **GET):
"""Generate url for retrieving node infos (POST)."""
return self.make_url(self.project_id, 'labels-for-nodes', **GET)

def _get_nearest_node_url(self, **GET):
"""Generate url for retrieving nearest node."""
return self.make_url(self.project_id, 'nodes', 'nearest', **GET)

def _get_skeleton_nodes_url(self, skid, **GET):
"""Generate url for retrieving skeleton nodes.
Expand Down
39 changes: 39 additions & 0 deletions pymaid/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'get_landmarks',
'get_landmark_groups',
'get_skeleton_ids',
'get_nearest_node'
]

# Set up logging
Expand Down Expand Up @@ -4909,3 +4910,41 @@ def get_skeleton_change(x, chunk_size=50, remote_instance=None):
pbar.update(len(ch))

return change




@cache.undo_on_error
def get_nearest_node(x, y, z, skeleton_id=None, neuron_id=None, remote_instance=None):
"""Get split and merge history of skeletons.
Parameters
----------
x : X coordinate of query location.
y : Y coordinate of query location.
z : Z coordinate of query location.
skeleton_id : Result treenode has to be in this skeleton. (optional)
neuron_id : Result treenode has to be in this neuron. (optional, altenrate to skeleton_id)
remote_instance : CatmaidInstance, optional
If not passed directly, will try using global.
Returns
-------
node
Nearest node.
"""
remote_instance = utils._eval_remote_instance(remote_instance)

GET = {'x': x, 'y': y, 'z': z}

if skeleton_id:
GET['skeleton_id'] = skeleton_id
if neuron_id:
GET['neuron_id'] = neuron_id

url = remote_instance._get_nearest_node_url(**GET)

resp = remote_instance.fetch(url, disable_pbar=True)

return resp

0 comments on commit 05fe378

Please sign in to comment.