Neuro-SAM: Foundation Model for Dendrite and Dendritic Spine Segmentation
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuro_sam-0.1.18.tar.gz.
File metadata
- Download URL: neuro_sam-0.1.18.tar.gz
- Upload date:
- Size: 199.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
019aec0a6bdfa85f50ebb43cfdd18bd67b9bf910d4a0e13bfec66d40391901e9
|
|
| MD5 |
fc6c2bc65702543dc5cdbe1f5a20c3eb
|
|
| BLAKE2b-256 |
a7d68c5e5b53418eded66ba5825184e3cdc027e7f134839eeb7050ed737699bb
|
File details
Details for the file neuro_sam-0.1.18-py3-none-any.whl.
File metadata
- Download URL: neuro_sam-0.1.18-py3-none-any.whl
- Upload date:
- Size: 255.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dfb186345cf54bd8e0414e7d2f697dec154d95738a60ebee1f4856b67b3467a
|
|
| MD5 |
a470f45e6233c1e1171509464f67c93f
|
|
| BLAKE2b-256 |
66aeaf531eb71ca84eaa088cdf47845250ed5f604cc6158e6e62dd2f7a652ea8
|