fafbseg.move.merge_into_catmaid¶
-
fafbseg.move.
merge_into_catmaid
(x, target_instance, tag, min_node_overlap=4, min_overlap_size=1, merge_limit=1, min_upload_size=0, min_upload_nodes=1, update_radii=True, import_tags=False, label_joins=True, sid_from_nodes=True, mesh=None)[source]¶ Merge neuron into target CATMAID instance.
This function will attempt to:
Find fragments in
target_instance
that overlap withx
using whatever segmentation data source you have set usingfafbseg.use_...
.Generate a union of these fragments and
x
.Make a differential upload of the union leaving existing nodes untouched.
Join uploaded and existing tracings into a single continuous neuron. This will also upload connectors but no node tags.
- Parameters
x (pymaid.CatmaidNeuron/List | navis.TreeNeuron/List) – Neuron(s)/fragment(s) to commit to
target_instance
.target_instance (pymaid.CatmaidInstance) – Target Catmaid instance to commit the neuron to.
tag (str) – A tag to be added as part of a
{URL} upload {tag}
annotation. This should be something identifying your group - e.g.tag='WTCam'
for the Cambridge Wellcome Trust group.min_node_overlap (int, optional) – Minimal overlap between x and a potentially overlapping neuron in
target_instance
. 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_overlap_size (int, optional) – Minimum node count for potentially overlapping neurons in
target_instance
. Use this to e.g. exclude single-node synapse orphans.merge_limit (int, optional) – Distance threshold [um] for collapsing nodes of
x
into overlapping fragments in target instance. Decreasing this will help if your neuron has complicated branching patterns (e.g. uPN dendrites) at the cost of potentially creating duplicate parallel tracings in the neuron’s backbone.min_upload_size (float, optional) – Minimum size in microns for upload of new branches: branches found in
x
but not in the overlapping neuron(s) intarget_instance
are uploaded in fragments. Use this parameter to exclude small branches that might not be worth the additional review time.min_upload_nodes (int, optional) – As
min_upload_size
but for number of nodes instead of cable length.update_radii (bool, optional) – If True, will use radii in
x
to update radii of overlapping fragments if (and only if) the nodes do not currently have a radius (i.e. radius<=0).import_tags (bool, optional) – If True, will import node tags. Please note that this will NOT import tags of nodes that have been collapsed into manual tracings.
label_joins (bool, optional) – If True, will label nodes at which old and new tracings have been joined with tags (“Joined from …” and “Joined with …”) and with a lower confidence of 1.
sid_from_nodes (bool, optional) – If True and the to-be-merged neuron has a “skeleton_id” column it will be used to set the
source_id
upon uploading new branches. This is relevant if your neuron is a virtual chimera of several neurons: in order to preserve provenance (i.e. correctly associating each node with asource_id
origin).mesh (Volume | MeshNeuron | mesh-like object | list thereof) – Mesh representation of
x
. If provided, will use to improve merging. Ifx
is a list of neurons, must provide a mesh for each of them.
- Returns
Nothing – If all went well.
dict – If something failed, returns server responses with error logs.
Examples
Setup
>>> import fafbseg >>> import pymaid
>>> # Set up connections to manual and autoseg CATMAID >>> manual = pymaid.CatmaidInstance('URL', 'HTTP_USER', 'HTTP_PW', 'API_TOKEN') >>> auto = pymaid.CatmaidInstance('URL', 'HTTP_USER', 'HTTP_PW', 'API_TOKEN')
>>> # Set a segmentation data source >>> fafbseg.use_google_storage("https://storage.googleapis.com/fafb-ffn1-20190805/segmentation")
Merge a neuron from autoseg into v14
>>> # Fetch the autoseg neuron to transfer to v14 >>> x = pymaid.get_neuron(267355161, remote_instance=auto)
>>> # Get the neuron's annotations so that they can be merged too >>> x.get_annotations(remote_instance=auto)
>>> # Start the commit >>> # See online documentation for video of merge process >>> resp = fafbseg.merge_neuron(x, target_instance=manual)