Skip to content

Commit

Permalink
microns interface: get CloudVolume straight from CAVEclient
Browse files Browse the repository at this point in the history
(handles secrets, etc.)
  • Loading branch information
schlegelp committed Feb 6, 2025
1 parent 4c90999 commit 86c8915
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions navis/interfaces/cave_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ def _get_cloudvol(url, cache=True):
url, cache=cache, use_https=True, parallel=10, progress=False, fill_missing=True
)

@lru_cache(None)
def _cloudvol_from_cv(client, **kwargs):
"""Get and cache CloudVolume from CAVEclient.
Parameters
----------
client : CAVEclient
**kwargs
Additional arguments passed to `cloudvolume.CloudVolume`.
"""
return client.info.segmentation_cloudvolume(**kwargs)


def _get_somas(root_ids, client, materialization="auto"):
"""Fetch somas based on nuclei segmentation for given neuron(s).
Expand Down Expand Up @@ -184,13 +197,14 @@ def fetch_neurons(
"""
x = utils.make_iterable(x, force_type=int)

vol = _get_cloudvol(client.info.segmentation_source()) # this is cached
# Let CAVEclient handle the cloudvolume (this should take care of any secrets)
vol = _cloudvol_from_cv(client)

try:
somas = _get_somas(x, client=client, materialization=materialization)
soma_pos = somas.set_index("pt_root_id").pt_position.to_dict()
except BaseException as e:
logger.warning("Failed to fetch somas via nucleus segmentation" f"(){e})")
logger.warning(f"Failed to fetch somas via nucleus segmentation(){e})")
soma_pos = {}

nl = []
Expand Down

0 comments on commit 86c8915

Please sign in to comment.