crantpy.viz package#
Submodules#
Module contents#
- crantpy.viz.chunks_to_nm(xyz_ch, vol, voxel_resolution=[4, 4, 40])[source]#
Map a chunk location to Euclidean space. CV workaround Implemented here after Giacomoβs suggestion
- Parameters:
xyz_ch (array-like) β (N, 3) array of chunk indices.
vol (cloudvolume.CloudVolume) β CloudVolume object associated with the chunked space.
voxel_resolution (list, optional) β Voxel resolution.
- Returns:
(N, 3) array of spatial points.
- Return type:
np.array
- crantpy.viz.configure_urllib3_warning_suppression(enable=None)[source]#
Enable suppression of known cosmetic urllib3 warnings.
Trade-offs: Hiding warnings can make it harder to notice real connectivity issues. When enabled, only the specific connection pool message is filtered; other warnings remain visible. Does not call urllib3.disable_warnings().
Control via enable or environment variable CRANTPY_SUPPRESS_URLLIB3_WARNINGS.
Returns True if suppression is enabled, False otherwise.
- crantpy.viz.detect_soma_mesh(mesh)[source]#
Try detecting the soma based on vertex clusters.
Identifies dense vertex clusters that likely represent the soma.
- Parameters:
mesh (trimesh.Trimesh) β Coordinates in nanometers. Mesh must not be downsampled for accurate detection.
- Returns:
Array of vertex indices that belong to the detected soma region. Returns empty array if no soma is detected.
- Return type:
np.ndarray
- crantpy.viz.detect_soma_skeleton(s, min_rad=800, N=3)[source]#
Try detecting the soma based on radii.
Looks for consecutive nodes with large radii to identify soma. Includes additional checks to ensure the skeleton is valid.
- Parameters:
- Returns:
Node ID of the detected soma, or None if no soma found.
- Return type:
int or None
- crantpy.viz.divide_local_neighbourhood(mesh, radius)[source]#
Divide the mesh into locally connected patches of a given size (overlapping).
- crantpy.viz.get_skeletons(root_ids, dataset='latest', progress=True, omit_failures=None, max_threads=6, **kwargs)[source]#
Fetch skeletons for multiple neurons.
Tries to get precomputed skeletons first, then falls back to on-demand skeletonization if needed. if id more than one root_id, it will use the parallel skeletonization function.
- Parameters:
root_ids (list of int or np.ndarray) β Root IDs of neurons to fetch skeletons for.
dataset (str, default 'latest') β Dataset to query against.
progress (bool, default True) β Show progress during fetching.
omit_failures (bool, optional) β None: raise exception on failures True: skip failed neurons False: return empty TreeNeuron for failed cases
max_threads (int, default 6) β Number of parallel threads for fetching skeletons.
**kwargs β Additional arguments passed to skeletonization if needed.
- Returns:
List of successfully fetched/generated skeletons.
- Return type:
navis.NeuronList
- crantpy.viz.get_soma_from_annotations(root_id, client, dataset=None)[source]#
Try to get soma location from nucleus annotations.
- Parameters:
- Returns:
(x, y, z) coordinates of the soma in nanometers, or None if not found.
- Return type:
tuple or None
- crantpy.viz.skeletonize_neuron(client, root_id, shave_skeleton=True, remove_soma_hairball=False, assert_id_match=False, threads=2, save_to=None, progress=True, use_pcg_skel=False, **kwargs)[source]#
Skeletonize a neuron the main function.
- Parameters:
client (CAVEclient) β CAVE client for data access.
root_id (int) β Root ID of the neuron to skeletonize.
shave_skeleton (bool, default True) β Remove small protrusions and bristles from skeleton (from my understanding).
remove_soma_hairball (bool, default False) β Remove the hairball mesh from the soma
assert_id_match (bool, default False) β Verify skeleton nodes map to correct segment ID.
threads (int, default 2) β Number of parallel threads for mesh processing.
save_to (str, optional) β Save skeleton as SWC file to this path.
progress (bool, default True) β Show progress bars during processing.
use_pcg_skel (bool, default False) β Try pcg_skel first before skeletor (CAVE-client skeletonization).
**kwargs β Additional arguments for skeletonization algorithms.
- Returns:
navis.TreeNeuron β The skeletonized neuron.
# TODOs from fafbseg
# - Use synapse locations as constraints
# - Mesh preprocessing options
# - Chunked skeletonization for large meshes
# - Use soma annotations from external sources
# - Better error handling/logging
# - Allow user-supplied soma location/radius
# - Option to return intermediate results
# - Support more skeletonization algorithms
# - Merge disconnected skeletons
# - Custom node/edge attributes
- Return type:
navis.TreeNeuron | navis.NeuronList
- crantpy.viz.skeletonize_neurons_parallel(client, root_ids, n_cores=None, progress=True, color_map=None, **kwargs)[source]#
Skeletonize multiple neurons in parallel.
- Parameters:
client (CAVEclient) β CAVE client for data access.
root_ids (list of int or np.ndarray) β Root IDs of neurons to skeletonize.
n_cores (int, optional) β Number of cores to use. If None, uses half of available cores.
progress (bool, default True) β Show progress bars during processing.
color_map (str, optional) β Generate colors for each neuron using this colormap. Returns tuple of (neurons, colors) instead of just neurons.
**kwargs β Additional arguments passed to skeletonize_neuron.
- Returns:
NeuronList of skeletonized neurons, or tuple of (NeuronList, colors) if color_map is specified.
- Return type:
navis.NeuronList or tuple