crantpy.viz.l2 module#
Visualization module for CRANTBpy.
- crantpy.viz.l2.chunks_to_nm(xyz_ch, vol, voxel_resolution=None)[source]#
Map a chunk location to Euclidean space.
- 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. If None, use SCALE_X, SCALE_Y, SCALE_Z.
- Returns:
(N, 3) array of spatial points.
- Return type:
np.array
- crantpy.viz.l2.find_anchor_loc(neurons, dataset=None, max_threads=4, progress=True)[source]#
Find a representative coordinate for neuron(s) using the L2 cache.
This works by querying the L2 cache and using the representative coordinate for the largest L2 chunk for each neuron.
- Parameters:
neurons (int, str, list, np.ndarray, or NeuronCriteria) β Root ID(s) to get coordinate for. Can be a single root ID, a list of root IDs, or an instance of NeuronCriteria.
dataset (str, optional) β Dataset to query. If None, will use the default dataset.
max_threads (int) β Number of parallel threads to use for batch queries.
progress (bool) β Whether to show a progress bar.
- Returns:
DataFrame with columns: root_id, x, y, z.
- Return type:
- crantpy.viz.l2.get_l2_chunk_info(neurons, dataset=None, progress=True, chunk_size=2000)[source]#
Fetch info for L2 chunks associated with given neuron(s).
- Parameters:
neurons (int, str, list, np.ndarray, or NeuronCriteria) β Neurons to fetch L2 chunk info for. Can be a single root ID, a list of root IDs, or an instance of NeuronCriteria.
dataset (str, optional) β Dataset to fetch info from.
progress (bool) β Whether to show a progress bar.
chunk_size (int) β Number of L2 IDs per query.
- Returns:
DataFrame with L2 chunk info (coordinates, vectors, size).
- Return type:
- crantpy.viz.l2.get_l2_dotprops(root_ids, min_size=None, sample=False, omit_failures=None, progress=True, max_threads=10, dataset=None, **kwargs)[source]#
Generate dotprops from L2 chunks for given neuron(s).
- Parameters:
root_ids (int, str, list, np.ndarray, or NeuronCriteria) β Root ID(s) of the FlyWire neuron(s) to generate dotprops for.
min_size (int, optional) β Minimum size (in nm^3) for the L2 chunks. Smaller chunks will be ignored.
sample (float (0 < sample < 1), optional) β If float, will create Dotprops based on a fractional sample of the L2 chunks.
omit_failures (bool, optional) β Behaviour when dotprops generation fails. None (default) raises, True skips, False returns empty Dotprops.
progress (bool) β Whether to show a progress bar.
max_threads (int) β Number of parallel requests to make when fetching the L2 IDs.
dataset (str, optional) β Against which FlyWire dataset to query. If None, will use the default dataset.
**kwargs β Additional keyword arguments passed to Dotprops initialization.
- Returns:
List of Dotprops.
- Return type:
navis.NeuronList
- crantpy.viz.l2.get_l2_graph(root_ids, dataset=None, progress=True, max_threads=4)[source]#
Fetch L2 graph(s) for given neuron(s).
- Parameters:
root_ids (int, str, list, np.ndarray, or NeuronCriteria) β FlyWire root ID(s) for which to fetch the L2 graphs.
dataset (str, optional) β Against which FlyWire dataset to query. If None, will use the default dataset.
progress (bool) β Whether to show a progress bar.
max_threads (int) β Number of parallel threads to use for batch queries.
- Returns:
The L2 graph or list thereof.
- Return type:
networkx.Graph or list of networkx.Graph
- crantpy.viz.l2.get_l2_info(neurons, dataset=None, progress=True, max_threads=4)[source]#
Fetch basic info for given neuron(s) using the L2 cache.
- Parameters:
neurons (int, str, list or NeuronCriteria) β Neurons to fetch info for. Can be a single root ID, a list of root IDs, or an instance of NeuronCriteria.
dataset (str, optional) β Dataset to fetch info from.
progress (bool) β Whether to show a progress bar.
max_threads (int) β Number of parallel requests to make.
- Returns:
DataFrame with basic L2 information for the given neuron(s). - length_um is the underestimated sum of the max diameter across all L2 chunks - bounds_nm is the rough bounding box based on the representative coordinates of the L2 chunks - chunks_missing is the number of L2 chunks not present in the L2 cache.
- Return type:
- crantpy.viz.l2.get_l2_meshes(x, threads=10, progress=True, dataset=None)[source]#
Fetch L2 meshes for a single neuron or NeuronCriteria in CRANTb.
- crantpy.viz.l2.get_l2_skeleton(root_ids, refine=True, drop_missing=True, l2_node_ids=False, omit_failures=None, progress=True, max_threads=4, dataset=None, **kwargs)[source]#
Generate skeleton(s) from L2 graph(s) for given neuron(s).
- Parameters:
root_ids (int, str, list, np.ndarray, or NeuronCriteria) β Root ID(s) of the CRANTb neuron(s) to skeletonize.
refine (bool) β If True, refine skeleton nodes by moving them to the center of their corresponding chunk meshes using the L2 cache.
drop_missing (bool) β Only relevant if
refine=True
: If True, drop chunks that donβt exist in the L2 cache.l2_node_ids (bool) β If True, use the L2 IDs as node IDs.
omit_failures (bool, optional) β Behaviour when skeleton generation fails. None (default) raises, True skips, False returns empty TreeNeuron.
progress (bool) β Whether to show a progress bar.
max_threads (int) β Number of parallel requests to make when fetching the L2 skeletons.
dataset (str, optional) β Against which CRANTb dataset to query. If None, will use the default dataset.
**kwargs β Additional keyword arguments passed to TreeNeuron initialization.
- Returns:
The extracted L2 skeleton(s).
- Return type:
navis.TreeNeuron or navis.NeuronList