dvid.tip.detect_tips¶
- dvid.tip.detect_tips(x, use_clf=False, psd_dist=False, done_dist=False, checked_dist=50, tip_dist=False, pos_filter=None, save_to=None, verbose=True, snap=True, server=None, node=None)[source]¶
Detect potential open ends on a given neuron.
- In brief, the workflow is as follows:
Extract tips from the neuron’s skeleton
Snap tip positions back to mesh (see
snap
)Apply filters (see
_dist
parameters)Remove tips close to a previously checked assignment (see
checked_dist
)(Optionally) Try to prioritize tips (
use_clf
)Save to a json file (see
save_to
) that can be opened in neuTu
- Parameters
x (single body ID) –
use_clf (bool, optional) – If True, will use a pre-trained classifier to try to predict whether a tip needs human interaction or not. The returned list of tips will contain and be ordered by “confidence” values from -1 (unimportant) to +1 (important). THIS IS NOT A MAGIC BULLET! If you need to be certain you have completed a neuron, you will actually have to look at all tips regardless of confidence!
psd_dist (int | None, optional) – Minimum distance (in raw units) to a postsynaptic density (PSD) for a tip to be considered “done”.
done_dist (int | None,) – Minimum distance (in raw units) to a DONE tag for a tip to be considered “done”.
checked_dist (int | None, optional) – Minimum distance (in raw units) to a bookmark that has previously been “Set Checked” in the “Assigned bookmarks” table in Neutu.
tip_dist (int | None, optional) – If a given pair of tips is closer than this distance they will be considered duplicates and one of them will be dropped.
pos_filter (function, optional) – Function to fitler tips by position. Must accept numpy array (N, 3) and return array of [True, False, …].
save_to (filepath, optional) – If provided will save open ends to JSON file that can be imported as assigmnents.
snap (bool, optional) – If True, will make sure that tips positions are within the mesh.
server (str, optional) – If not provided, will try reading from global.
node (str, optional) – If not provided, will try reading from global.
- Returns
List of potential open ends.
- Return type
pandas.DataFrame
Examples
The usual setting up:
>>> import dvidtools as dt >>> dt.set_param('https://your.server.com:8000', 'node', 'user')
By default,
detect_tips
will simply return all end nodes of the skeleton that have not previously been “Set checked” in NeuTu:>>> # Generate list of tips and save to json file >>> tips = dt.detect_tips(883338122, save_to='~/Documents/883338122.json')
A more advanced example is using a pre-trained classifier to include “confidence” values. These confidence range from -1 to +1 and give some indication whether a tip needs to be extended or not. This requires sciki-learn to be installed. In a terminal run:
pip install scikit-learn
Once scikit-learn is installed, you can run the tip detector with classifier confidences:
>>> tips = dt.detect_tips(883338122, use_clf=True, ... save_to='~/Documents/883338122.json')