fafbseg.google.find_fragments#

fafbseg.google.find_fragments(x, remote_instance, min_node_overlap=3, min_nodes=1, mesh=None)[source]#

Find manual tracings overlapping with given autoseg neuron.

This function is a generalization of find_autoseg_fragments and is designed to not require overlapping neurons to have references (e.g. in their name) to segmentation IDs:

  1. Traverse neurites of x search within 2.5 microns radius for potentially overlapping fragments.

  2. Either collect segmentation IDs for the input neuron and all potentially overlapping fragments or (if provided) use the mesh to check if the candidates are inside that mesh.

  3. Return fragments that overlap with at least min_overlap nodes with input neuron.

Parameters:
  • x (pymaid.CatmaidNeuron | navis.TreeNeuron) – Neuron to collect fragments for.

  • remote_instance (pymaid.CatmaidInstance) – Catmaid instance in which to search for fragments.

  • min_node_overlap (int, optional) – Minimal overlap between x and a fragment in nodes. If the fragment has less total nodes than min_overlap, the threshold will be lowered to: min_overlap = min(min_overlap, fragment.n_nodes)

  • min_nodes (int, optional) – Minimum node count for returned neurons.

  • mesh (navis.Volume | trimesh.Trimesh | navis.MeshNeuron, optional) – Mesh representation of x. If provided will use the mesh instead of querying the segmentation to determine if fragments overlap. This is generally the faster.

Returns:

CatmaidNeurons of the overlapping fragments. Overlap scores are attached to each neuron as .overlap_score attribute.

Return type:

pymaid.CatmaidNeuronList

Examples

Setup:

>>> import pymaid                                                   
>>> import fafbseg                                                  
>>> manual = pymaid.CatmaidInstance('MANUAL_SERVER_URL', 'HTTP_USER', 'HTTP_PW', 'API_TOKEN')       
>>> auto = pymaid.CatmaidInstance('AUTO_SERVER_URL', 'HTTP_USER', 'HTTP_PW', 'API_TOKEN')           
>>> # Set a source for segmentation data
>>> fafbseg.google.use_google_storage("https://storage.googleapis.com/fafb-ffn1-20190805/segmentation") 

Find manually traced fragments overlapping with an autoseg neuron:

>>> x = pymaid.get_neuron(204064470, remote_instance=auto)                  
>>> frags_of_x = fafbseg.google.find_fragments(x, remote_instance=manual)   

See also

fafbseg.google.find_autoseg_fragments

Use this function if you are looking for autoseg fragments overlapping with a given neuron. Because we can use the reference to segment IDs (via names & annotations), this function is much faster than find_fragments.