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.
🚀 Installation
Neuro-SAM requires Python 3.10+. We recommend using Conda/Miniconda for environment management.
pip install neuro-sam
Models 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-download
GPU acceleration is supported via CUDA and MPS (Apple Silicon).
📊 Usage
# Launch with the built-in benchmark dataset
neuro-sam
# Launch with your own dataset
neuro-sam --image-path /path/to/your/image.tif
🗃 Repository Structure
src/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
🔬 Workflow
1. Configure Voxel Spacing
In the Path Tracing tab, set accurate X, Y, Z voxel spacing (nm) for your acquisition. This ensures correct anisotropic scaling throughout the pipeline.
2. Trace Dendritic Paths
- 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
3. Segment Dendrites
- Go to the Segmentation tab
- Load the pre-trained SAM2 dendrite model
- Run segmentation on individual traced paths
4. Detect Spines
- Go to the Spine Detection tab
- Select a segmented path
- Run automatic spine detection using tubular view analysis
5. Segment Spines
- 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
🗂 Models
| 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.
📬 Contact
- Nipun Arora — nipunarora8@yahoo.com
Metadata
Release files for neuro-sam 0.1.18
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neuro_sam-0.1.18.tar.gz | 199.4 kB | Without provenance | Details for neuro_sam-0.1.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neuro_sam-0.1.18-py3-none-any.whl | Python 3 | none | any | Details for neuro_sam-0.1.18-py3-none-any.whl |
Total release size: 454.4 kB
Release files / neuro_sam-0.1.18.tar.gz
| Download URL | neuro_sam-0.1.18.tar.gz |
|---|---|
| Size | 199.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
019aec0a6bdfa85f50ebb43cfdd18bd67b9bf910d4a0e13bfec66d40391901e9
|
|
BLAKE2b-256 checksum How to use checksums |
a7d68c5e5b53418eded66ba5825184e3cdc027e7f134839eeb7050ed737699bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Release files / neuro_sam-0.1.18-py3-none-any.whl
| Download URL | neuro_sam-0.1.18-py3-none-any.whl |
|---|---|
| Size | 255.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3dfb186345cf54bd8e0414e7d2f697dec154d95738a60ebee1f4856b67b3467a
|
|
BLAKE2b-256 checksum How to use checksums |
66aeaf531eb71ca84eaa088cdf47845250ed5f604cc6158e6e62dd2f7a652ea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Security for neuro-sam 0.1.18
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.