DVIDtools ========= `dvidtools `_ allows you to read and write data from `DVID `_ servers. Install ------- Make sure you have `Python 3 `_, `pip `_ and `git `_ installed. Then run this in terminal: :: pip install git+https://github.com/flyconnectome/dvid_tools@master If you plan to use the :func:`tip detector ` with classifier-derived confidence, you will also need `sciki-learn `_: :: pip install scikit-learn What can ``dvidtools`` do for you? ---------------------------------- - :func:`get `/ :func:`set ` user bookmarks - :func:`get `/:func:`set ` neuron annotations (names) - download precomputed :func:`meshes `, :func:`skeletons ` (SWCs) and :func:`ROIs ` - get basic neuron info (# of :func:`voxels `/:func:`info `) - get :func:`synapses ` - get connectivity (:func:`adjacency matrix `, :func:`connectivity table `) - retrieve :func:`info ` (TODO, to split, etc) - map :func:`position ` to body IDs - :func:`skeletonize ` and :func:`mesh ` sparsevols - detect potential open :func:`ends ` (based on a script by `Stephen Plaza `_) Check out the full :doc:`API ` for more. Examples -------- Setting up :: import dvid as dv # You can pass these parameters explicitly to each function # but defining them globally is more convenient server = 'http://127.0.0.1:8000' node = '54f7' user = 'schlegelp' dv.setup(server, node, user) Get user bookmarks and add annotations :: # Get bookmarks bm = dv.get_user_bookmarks() # Add column with neuron name (if available) bm['body name'] = bm['body ID'].map(lambda x: dv.get_annotation(x).get('name', None)) Fetch precomputed skeleton for a single neuron and save as SWC :: body_id = '1700937093' swc = dv.get_skeletons(body_id) # Alternatively, save straight to disk _ = dv.get_skeletons(body_id, save_to=body_id + '.swc') Get table of synapse locations :: body_id = '1700937093' syn = dv.get_synapses(body_id) Get synaptic partners of a neuron :: body_id = '1700937093' partners = dv.get_connectivity(body_id) Get connectivity in given ROI using `navis `_ :: import navis # Get the LH ROI lh = navis.Volume(*dv.get_roi('LH')) # Fetch connectivity but use filter function lh_partners = dv.get_connectivity(body_id, pos_filter=lambda x: navis.in_volume(x, lh)) Detect potential open ends and write them to ``.json`` file that can be imported into `neutu `_. :: body_id = '1700937093' tips = dv.detect_tips(body_id, save_to='~/Documents/{}.json'.format(body_id)) You can do the same but weight potential open ends using a pre-trained classifier that provides "confidence" values. These confidence range from -1 to +1 and give some indication whether a tip needs human attention 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 = dv.detect_tips(body_id, use_clf=True, save_to='~/Documents/{}.json'.format(body_id))