The napari hub is transitioning to a community-run implementation due to launch in June 2025.
Since October 1, 2024, this version is no longer actively maintained and will not be updated. New plugins and plugin updates will continue to be listed.

neurofly

neurofly

A framework to annotate single neurons at whole-brain scale

    This package provides tools for semi-automatic neuron reconstruction. Features based on deep learning, like image segmentation and deconvolution are implemented in tinygrad, which can run on almost any GPU (NVIDIA, AMD, Apple, Qualcomm, Intel).

    Installation

    Install the latest version

    pip install --upgrade git+https://github.com/beanli161514/neurofly.git

    or

    pip install neurofly

    Dataset

    We provide several expert-proofread reconstruction results for testing, model training, and evaluation. Zenodo Link

    Content of samples

    namesizespecieslabel typeimaging
    rm009_labeled629MBmacaqueskeletonVISoR
    mouse_labeled260MBmouseskeletonVISoR
    z002_labeled204MBmouseskeletonVISoR
    fmost_labeled370MBmouseskeletonfMOST
    RM009_noisy_165MBmacaquemorphologyVISoR
    RM009_noisy_265MBmacaquemorphologyVISoR
    fmost_test65MBmousemorphologyfMOST
    z002_dendrites768MBmousemorphologyVISoR
    RM009_arbor_1288MBmacaquemorphologyVISoR
    RM009_axons_1600MBmacaquemorphologyVISoR
    RM009_axons_2600MBmacaquemorphologyVISoR
    z0028.92Gmousemorphology*VISoR

    $*$ annotation in progress

    Label format

    Morphology labels are graphs saved in SQLite database with 3 tables:

    segmentsnodesedges
    sidnidsrc
    pointscoorddes
    sampled_pointscreatordate
    statuscreator
    type
    date
    checked

    Segments are results of the segmentation stage, they are used to generate initial nodes and edges.

    Basic usage example

    NeuroFly packaged 4 napari plugins for image browsing, image segmentation, and data annotation.

    Segmentation

    NeuroFly supports whole brain image saved in hierarchical data structures(ims, h5, and zarr) in Imaris File Format and small image volumes saved in single-channel tiff format. Here we use a mouse brain in our dataset named z002.zarr.zip as example.

    This brain is sparsely labeled, which means only a tiny puny part of neurons are lighted and imaged. To extract these foreground singals, you can use the provided command line interface 'seg'. We provide a default weight trained on images captured by VISoR and fMOST.

    seg -i z002.zarr.zip -vis -d z002.db

    or use the graphical interface

    This process may take about 10 hours depending on your you hardware configuration. When finished, you should see the extracted segments and a database file named z002.db in your working dictionary.

    An image block with severe contamination and the segmentation result

    Manual connection and proofreading

    Launch annotation tool from napari menu, Plugin -> neurofly -> Segs Annotator

    Load data

    Load image file (z002.zarr.zip) and database file (z002.db), then click refresh panorama button to show the panorama view.

    Select one node as start point of annotation

    In panorama mode, you can easily identify sparse, bright signals that are promising for reconstruction. The silde bars 'short segs filter', 'length thres', and 'point size' can be adjusted to hide noise and short segments.

    If you can clearly identify foreground segments, click on one of the conspicuous segments to select it as start point of annotation. Once selected, the id of picked node will be displayed at node selection. Then click 'switch mode' to switch to labeling mode, and the tasks will be generated automatically.

    Task generation

    Given a selected node, task generator analyses its connected component and extract all unchecked terminal nodes. The tasks are designed very simple: Connect the center node with the surrounding nodes if there should be an edge. The criterion is whether the edge aligns well with the imaged neuron fibers.

    Node operations

    In each task, a center node and nearby segments are rendered, you can add/remove nodes and edges to get a reasonable local structure.

    Left click on nodes to add/remove an edge between it and the center node

    Right click to remove a node

    Press 'g' or use left panel to switch to 'image' layer, then right click to add points

    Use dropdown selection in right panel to add type label for center node.

    Deconvolution

    Press 'i' or click on 'deconvolution' to deconvolve the image

    Proofreading

    If you find something wrong when labeling, for example, two somas are connected together. You can use proofreading mode to check the neuron branch by branch.

    Performance

    NeuroFly supports rendering of more than ten million points. (tested on M3 Macbook Air and RTX 3090 workstation)

    Export as swc file

    Switch to panorama mode, adjust 'length_thres' to filter out short segments and keep only complete neurons. Then press 'export swc files', each neuron will be saved as one .swc file in your working dictionary.

    Version:

    • 0.1.3

    Last updated:

    • 13 November 2024

    First released:

    • 30 October 2024

    License:

    Supported data:

    • Information not submitted

    Plugin type:

    • Information not submitted

    GitHub activity:

    • Stars: 27
    • Forks: 3
    • Issues + PRs: 0

    Python versions supported:

    Operating system:

    • Information not submitted

    Requirements:

    • PyQt5
    • napari
    • Rtree
    • networkx
    • tqdm
    • magicgui
    • brightest-path-lib
    • tifffile
    • scikit-image
    • scipy
    • torch
    • tinygrad>=0.9.2
    • pathlib
    • h5py
    • zarr