Neuro-SAM is a napari plugin for analysing dendritic morphology in 3D fluorescence microscopy stacks. It enables you to:
- Trace individual dendrites in a 3D volume using waypoint-guided brightest-path search
- Segment traced dendrites using a fine-tuned SAM2 model
- Detect dendritic spines along each traced path
- Segment individual spines using a dedicated fine-tuned SAM2 model
Neuro-SAM works across imaging modalities including two-photon, confocal, and STED microscopy.
Neuro-SAM requires Python 3.10+. We recommend using Conda/Miniconda for environment management.
pip install neuro-samModels are downloaded automatically on first use and stored in src/neuro_sam/checkpoints/ — easy to find and delete.
To pre-download all models and the sample dataset:
neuro-sam-downloadGPU acceleration is supported via CUDA and MPS (Apple Silicon).
# Launch with the built-in benchmark dataset
neuro-sam
# Launch with your own dataset
neuro-sam --image-path /path/to/your/image.tifsrc/neuro_sam/
├── checkpoints/ # model weights (auto-downloaded on first use)
├── napari_utils/ # UI widgets and inference modules
│ ├── main_widget.py # top-level plugin widget
│ ├── path_tracing_module.py # waypoint path tracing
│ ├── segmentation_module.py # dendrite segmentation
│ ├── segmentation_model.py # SAM2 dendrite model wrapper
│ ├── spine_detection_module.py # spine detection
│ ├── spine_segmentation_module.py # spine segmentation UI
│ ├── spine_segmentation_model.py # SAM2 spine model wrapper
│ └── anisotropic_scaling.py # voxel spacing / scaling
├── brightest_path_lib/ # waypoint A* path tracing algorithm
├── training/ # training scripts for fine-tuning
├── plugin.py # napari entry point
└── utils.py # model download and shared utilities
In the Path Tracing tab, set accurate X, Y, Z voxel spacing (nm) for your acquisition. This ensures correct anisotropic scaling throughout the pipeline.
- Click waypoints along dendrite structures in the viewer
- Use Load Dataset to switch datasets without restarting
- The algorithm finds the optimal brightest path between waypoints
- Go to the Segmentation tab
- Load the pre-trained SAM2 dendrite model
- Run segmentation on individual traced paths
- Go to the Spine Detection tab
- Select a segmented path
- Run automatic spine detection using tubular view analysis
- Go to the Spine Segmentation tab
- Load the pre-trained SAM2 spine model
- Run spine segmentation on detected spine positions
- Export spine masks as TIFF files
| Model | Description |
|---|---|
sam2.1_hiera_small.pt |
SAM2 base checkpoint |
dendrite_model.torch |
Fine-tuned weights for dendrite segmentation |
spine_model.torch |
Fine-tuned weights for spine segmentation |
All models are downloaded from the GitHub release on first use.
- Nipun Arora — [email protected]