Skip to main content

SNT

PySNT

Python wrapper for SNT, the framework for quantification of neuronal anatomy

Please read the installation instructions before installing PySNT.

PySNT is not a regular Python package: it runs SNT, a Java application, inside your Python process. Besides the Python package, it needs a Java JDK (21+) and a properly configured environment, and the first call to pysnt.initialize() downloads SNT (this may take several minutes). A bare pip install pysnt into an existing environment could fail or conflict with other packages.

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 Java Object PySNT Python Object
    SNTChart matplotlib Figure
    SNTGraph NetworkX graph
    SNTTable xarray Dataset; pandas DataFrame
    ImagePlus xarray; numpy (via ScyJava)
    Collections lists/dicts, etc. (via ScyJava)

Limitations

Early Stage Software with limited community validation. Please report anything unexpected

Getting Started for Users

Read the install instructions first (PySNT needs a JDK, and a dedicated environment is strongly recommended). The easiest route is pixi, which sets up Python, a JDK and cairo (optional, for SVG chart conversion) for you:

pixi init pysnt-project
cd pysnt-project
pixi add python=3.12 openjdk=21 pip cairo jupyterlab
pixi run pip install "pysnt[all]"
pixi shell

Or, from an existing fresh environment with Python 3.11+ and JDK 21+ (cairo needs a separate install, see the docs):

python -m pip install "pysnt[all]"
import pysnt
pysnt.initialize()  # First run downloads SNT: this may take several minutes

Something not working? Run pysnt doctor in a terminal for a report of your setup, with a hint for each problem found.

Getting Started for Developers

Environment Setup

# 1. Clone the repository
git clone https://github.com/morphonets/pysnt.git
cd pysnt

# 2. Create and activate a virtual environment (Python 3.11+, JDK 21 available)
python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate

# 3. Install PySNT in development mode, with all optional and dev dependencies
pip install -e ".[dev]"

# 4. Verify the setup
python -c "import pysnt; print(pysnt.version())"
python -m pytest tests -q

# 5. Have a look at ./dev/README.md for common workflows

Prefer pixi? The repository ships a workspace (JDK 21, Python 3.12, cairo; see pixi.lock), so no manual setup is needed:

pixi run -e test pytest tests -q   # tests
pixi run -e dev python             # everything, incl. napari (needs macOS 14+ on Apple Silicon)
pixi shell -e docs                 # docs tools; use any extra name as environment (all, display, gui, ...)

Prefer conda/mamba? mamba env create -f environment-dev.yml && mamba activate pysnt-dev && pip install -e .[dev] does the same. Select the resulting interpreter in your IDE (see the install docs).

IDEs like PyCharm may only install core dependencies on project import. In that case tun pip install -e ".[dev]" in its terminal (with the project interpreter active) to get pytest and the other dev tools.

Project Structure

pysnt/
├── src/pysnt/           # main package source (one subpackage per curated SNT package)
├── tests/               # test suite (JVM-dependent tests skip themselves if SNT cannot be resolved)
├── docs/                # documentation source (Sphinx/MyST) and tutorial notebooks
├── dev/                 # development utilities and templates (see dev/README.md)
├── dev/scripts/         # SNT sync, stub generation, and documentation scripts
├── .github/workflows/   # CI: tests, lowest-dependency tests, docs build
├── pyproject.toml       # packaging metadata, dependency floors, extras, and pixi workspace
├── pixi.lock            # locked pixi environments (osx-arm64, linux-64, win-64)
├── requirements*.txt    # pip equivalents (core, optional features, development)
└── environment*.yml     # conda-compatible equivalents (min, full, development)

Dependencies

pyproject.toml contains all details: core dependencies are listed under dependencies, and optional features under extras (display, gui, java, info, all, dev, docs). The requirements*.txt and environment*.yml files mirror it. The floors are verified by the "lowest declared dependencies" CI job.

Versioning and SNT

PySNT's major.minor version matches the SNT release it targets (PySNT 5.1.x targets SNT 5.1.x); the patch number is independent, so PySNT can ship fixes without a new SNT release. By default, pysnt.initialize() downloads SNT from Maven at DEFAULT_SNT_VERSION (see src/pysnt/_endpoints.py). Users can override it with initialize(snt_version=...) or SNT_VERSION, or use a local Fiji instead. PySNT warns when the loaded SNT differs in major.minor. See dev/README.md for the update workflow.

Need Help?

Metadata

Release files for pysnt 5.0.90

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysnt 5.0.90
File Size Uploaded Provenance Actions
pysnt-5.0.90.tar.gz 260.1 kB Without provenance Details for pysnt-5.0.90.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysnt 5.0.90
File Interpreter ABI Platform Actions
pysnt-5.0.90-py3-none-any.whl Python 3 none any Details for pysnt-5.0.90-py3-none-any.whl

Total release size: 521.7 kB

Release files / pysnt-5.0.90.tar.gz

Download URL pysnt-5.0.90.tar.gz
Size 260.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e1dde73897730e697cc9906c80b89f1344cf45a420a489bded70a28677974337
BLAKE2b-256 checksum
How to use checksums
8f3ce6c9d529136e8c467b5c38276e59a551ff5543eff875446fef238134c553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / pysnt-5.0.90-py3-none-any.whl

Download URL pysnt-5.0.90-py3-none-any.whl
Size 261.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d7342a60cb745a9422d482cd9646200c5818672e73d4ab35c62dd1de673f3cc
BLAKE2b-256 checksum
How to use checksums
548ab3b40aaf7cfbcaf891f3d32dbd8cb02a6fc20973cb056eb373ca3277aa09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for pysnt 5.0.90

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.

Release history Release notifications | RSS feed

This release

5.0.90 This release

2 release files No provenance

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