crantpy.utils.cave package#
Submodules#
Module contents#
- crantpy.utils.cave.clear_cave_client_cache()[source]#
Clears the CAVE client cache.
- Return type:
None
- crantpy.utils.cave.clear_cloudvolume_cache()[source]#
Clears the cloudvolume cache.
- Return type:
None
- crantpy.utils.cave.generate_cave_token(save=False)[source]#
Generates a token for the CAVE client. If save is True, the token will be saved (overwriting any existing token).
- Parameters:
save (bool, default False) β Whether to save the token after generation.
- Return type:
None
- crantpy.utils.cave.get_cave_client(dataset=None, clear_cache=False, check_stale=True)[source]#
Returns a CAVE client instance. If a token is already set, it will be used for authentication. Otherwise, a new token will be generated.
- Parameters:
clear_cache (bool, default False) β If True, bypasses the cache and fetches a new client.
check_stale (bool, default True) β If True, checks if the cached client is stale based on materialization and maximum cache duration.
dataset (str, optional) β The dataset to use. If not provided, uses the default dataset.
- Returns:
A CAVE client instance authenticated with the token.
- Return type:
CAVEclient
- Raises:
ValueError β If no token is found after attempting to generate one.
- crantpy.utils.cave.get_cloudvolume(dataset=None, clear_cache=False, check_stale=True, **kwargs)[source]#
Returns a cloudvolume instance.
- crantpy.utils.cave.get_current_cave_token()[source]#
Retrieves the current token from the CAVE client.
- Returns:
The current CAVE token.
- Return type:
- Raises:
ValueError β If no token is found.
- crantpy.utils.cave.get_dataset_segmentation_source(dataset)[source]#
Get segmentation source for given dataset.
- crantpy.utils.cave.get_datastack_segmentation_source(datastack)[source]#
Get segmentation source for given CAVE datastack.
- Return type:
- crantpy.utils.cave.is_latest_roots(x, timestamp=None, dataset=None, progress=True, batch_size=100000, validate_ids=True, use_http_session=True)[source]#
Check if the given root IDs are the latest based on the timestamp.
- Parameters:
x (IDs = str | int | np.int64) β The root IDs to check.
timestamp (Timestamp = str | int | np.int64 | datetime | np.datetime64 | pd.Timestamp) β The timestamp to compare against. Can also be βmatβ for the latest materialization timestamp.
dataset (str, optional) β The dataset to use.
progress (bool, default True) β Whether to show progress bar for large batches.
batch_size (int, default 100_000) β Batch size for processing large numbers of IDs.
validate_ids (bool, default True) β Whether to validate root IDs before processing.
use_http_session (bool, default True) β Whether to use direct HTTP session for better performance.
- Returns:
A boolean array indicating whether each root ID is the latest.
- Return type:
np.ndarray
Examples
>>> from crantpy.utils.cave.helpers import is_latest_roots >>> is_latest_roots([123456789, 987654321]) array([ True, False])
>>> # Check against latest materialization >>> is_latest_roots([123456789], timestamp="mat") array([ True])
- crantpy.utils.cave.is_valid_root(x, dataset=None, raise_exc=False)[source]#
Check if ID is (potentially) valid root ID.
- Parameters:
- Returns:
A boolean array indicating whether each root ID is valid.
- Return type:
np.ndarray
- Raises:
ValueError β If raise_exc is True and invalid IDs are found.
- crantpy.utils.cave.is_valid_supervoxel(x, dataset=None, raise_exc=False)[source]#
Check if ID is (potentially) valid supervoxel ID.
- Parameters:
- Returns:
If x is a single ID, returns bool. If x is iterable, returns array.
- Return type:
bool or np.ndarray
- Raises:
ValueError β If raise_exc is True and invalid IDs are found.
See also
is_valid_rootUse this function to check if a root ID is valid.
- crantpy.utils.cave.parse_root_ids(x)[source]#
Parse root IDs from various input formats to a list of np.int64.
- Parameters:
x (Neurons = str | int | np.int64 | navis.BaseNeuron | Iterables of previous types | navis.NeuronList | NeuronCriteria) β The input to parse. Can be a single ID, a list of IDs, or a navis neuron object.
- Returns:
A numpy array of root IDs as np.int64.
- Return type:
np.ndarray