Pysnt
Python wrapper for SNT, the framework for quantification of neuronal anatomy
Install / Use
/learn @morphonets/PysntREADME
Technical Features
-
Complete Java Bridge: Full programmatic access to SNT's neuroanatomy toolkit from Python (via JPype and ScyJava), enabling integration of advanced tracing, analysis, and visualization capabilities into Python workflows
-
Consistent API: 1:1 correspondence with SNT's Java API while maintaining Python conventions, allowing developers familiar with either language to work efficiently
-
Full Type Annotation: Type hints for all methods and classes, enabling static type checking with mypy and improved code reliability
-
IDE Integration: Autocomplete, inline documentation, and parameter hints in VS Code, PyCharm, Spyder, and Jupyter notebooks through type stubs and docstrings
-
Performant: Lazy class loading minimizes initialization overhead, loading only required SNT components on demand
-
Native Python Converters: Automatic conversion between SNT objects and Python-native types:
| SNT/ImgLib2 Java Object | PySNT Python Object | |-------------------------|----------------------------------| | SNTChart | matplotlib Figure | | SNTGraph | NetworkX graph | | SNTTable | xarray Dataset; pandas DataFrame | | ImgPlus/RAI | xarray; numpy | | ImagePlus | xarray; numpy (via ScyJava) | | Collections | lists/dicts, etc. (via ScyJava) |
Limitations
-
Bleeding Edge: Requires building SNT from the main branch (stable release integration planned for SNT v5.0)
-
Early Stage Software: Limited test coverage and community validation: Expect potential bugs and breaking API changes
Getting Started for Users
See Install instructions.
Getting Started for Developers
Environment Setup
# 1. Clone the repository
git clone https://github.com/morphonets/pysnt.git
cd pysnt
# 2. Set up conda/mamba (if not already configured)
mamba config append channels conda-forge
mamba config set channel_priority strict
# 3. Create and activate the development environment
mamba env create -f environment-dev.yml
mamba activate pysnt-dev
# 4. Install PySNT in development mode
pip install -e .[dev]
# 5. Verify the setup
python -c "import pysnt; print('PySNT imported successfully!')"
# 6. Have a look at ./dev/README.md for common workflows
IDE Configuration
PyCharm
- Open this folder as a project in PyCharm
- Go to File → Settings → Project → Python Interpreter
- Select the 'pysnt' environment
VS Code
- Open this folder in VS Code
- Install recommended extensions when prompted
- Select the 'pysnt' Python interpreter when prompted
Spyder
- Make sure Spyder is installed in the 'pysnt' environment:
mamba activate pysnt mamba install spyder mamba install spyder-notebook -c conda-forge # Optional: support for tutorials notebooks - Launch Spyder from the activated environment
- Open this folder as a project: Projects → New Project... → Existing Directory
Project Structure
pysnt/
├── src/pysnt/ # main package source
├── tests/ # test suite
├── dev/scripts/ # development scripts
├── docs/ # documentation source
├── dev/ # development utilities and templates
├── pyproject.toml # packaging metadata and dependency groups
├── requirements.txt # pip core runtime dependencies
├── requirements-gui.txt # pip optional runtime extras (display/gui/java/zarr)
├── requirements-dev.txt # pip development stack (extends requirements-gui.txt)
├── environment-min.yml # minimal conda-compatible runtime environment
├── environment.yml # full-featured conda-compatible runtime environment
└── environment-dev.yml # full-featured conda-compatible development environment
Dependency Files and Scope
pyproject.toml: canonical dependency definitions for packaging and extrasrequirements.txt: core pip runtime set onlyrequirements-gui.txt: optional runtime features layered on top of core (display,gui,java,zarr)requirements-dev.txt: development/test/docs tools layered on top ofrequirements-gui.txtenvironment-min.yml: smallest conda-compatible runtime setupenvironment.yml: full runtime conda-compatible setup with optional user-facing featuresenvironment-dev.yml: full runtime plus development/test/docs tools
Dependencies
Core Dependencies (Required)
- JPype1 - Python/JVM bridge used by runtime utilities
- matplotlib - Used extensively for plotting and figure creation
- numpy - Used throughout for array operations
- pyimagej - ImageJ integration
- scyjava - Core Java integration
- xarray - Dataset operations
Optional Dependencies (Display/Conversion Features)
- cairosvg - SNTChart SVG to matplotlib conversion
- install-jdk - Automatic OpenJDK installation helper
- ipykernel - Notebook kernel support
- pandas - DataFrame operations and SNTTable conversion
- pandasgui - Interactive DataFrame display
- networkx - SNTGraph to NetworkX graph conversion
- pyobjc-core (macOS only) - Required by PyImageJ GUI mode on macOS
- pyobjc-framework-cocoa (macOS only) - Required by PyImageJ GUI mode on macOS
- PyMuPDF - SNTChart PDF to matplotlib conversion
Optional Dependencies (OME-ZARR)
- fsspec - Remote filesystem access (HTTP/HTTPS/S3)
- zarr - OME-ZARR format support for local and remote data
Install examples:
pip install -e .(core)pip install -e .[display]pip install -e .[gui]pip install -e .[all]pip install -e .[dev]
macOS users: PyImageJ GUI mode requires
pyobjc-coreandpyobjc-framework-cocoa(orpyobjc). These are included in the GUI-focused dependency files.
Need Help?
- 📖 Documentation: pysnt.readthedocs.io
- 💬 Forum: forum.image.sc/tag/snt
- 🐛 Issues: GitHub Issues
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
96.8kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
344.1kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
