Skip to main content

Neuro-SAM

Foundation Model for Dendrite and Dendritic Spine Segmentation

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

Made with ♥️ at Anki Lab 🧠✨

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)

Source distribution for neuro-sam 0.1.18
File Size Uploaded
neuro_sam-0.1.18.tar.gz 199.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neuro-sam 0.1.18
File Interpreter ABI Platform
neuro_sam-0.1.18-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.18 This release

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page