Write a Python analysis once. Use it in napari, Fiji, QuPath, a notebook or the command line.
A LabConstrictor app can offer tools: Python functions with typed inputs and outputs. LabConstrictor Tools is the small Python package every app carries. It describes each tool so that a plugin can build a form for it, run it in the app's own Python environment, and put the results back into your image software.
Guides for people who use apps: https://cellmigrationlab.github.io/LabConstrictor-Site/ · Developer reference: https://cellmigrationlab.github.io/LabConstrictor-Tools/
- You use an app and want its tools inside napari, Fiji or QuPath. Start with Use apps in napari, Fiji and QuPath and What works where.
- You make an app and want its functions to appear in every host without writing interface code. Start with Writing tools.
You do not install this package yourself to use an app: the app's installer brings it.
- Install the LabConstrictor Playground app, as Install an app says. It makes its own test image, so you need no data.
- Install the plugin for your software. Each guide has the steps: napari, Fiji or QuPath.
- Open the plugin, pick Playground and run Feature tour. It returns a label image, outlines, points, a table and a message.
from typing import Annotated
from labconstrictor_tools import Image, ImageOut, Min, tool
@tool("Gaussian blur")
def blur(image: Image, sigma: Annotated[float, Min(0)] = 2.0) -> ImageOut:
from skimage.filters import gaussian
return gaussian(image, sigma, preserve_range=True)That is the whole declaration: an image input, a number that cannot be negative, and an image result. Every host builds its form from it. Check and test your tools with:
labconstrictor-tools check --module myapp_lc_tools --pythonpath .
labconstrictor-tools test --module myapp_lc_tools --pythonpath .Tools run from the command line too:
labconstrictor-tools list
labconstrictor-tools run myapp blur image=cells.tif sigma=3 --out results/- An app declares tools. Its installer registers them on your computer.
- A plugin reads the registered descriptions and builds a form. It never imports the app's packages.
- When you press Run, the tool runs in a separate process, in the app's own Python. Apps with conflicting packages can sit side by side.
- Results come back as files (TIFF, CSV, GeoJSON) and the plugin shows them.
The separate process is not a security sandbox. Install and run only apps you trust.
Alpha. The newest release of Tools is on the Releases page; each plugin has its own Releases page. Automated tests run on Linux, Windows and macOS; people have also tested it on Windows and macOS. The details are in What works where.
Found a problem? Open an issue with the host, the operating system, the app and the steps.
Only needed for development, or to add Tools to an environment by hand. Nothing is on PyPI yet: install the source archive of a release tag, as Install LabConstrictor Tools says.
python -m pip install -e ".[test]" black ruff mypy
black --check .
ruff check .
python scripts/check_annotations.py
mypy
cd tests && python -m unittest discover -p "test_*.py"The test suites are described in tests/README.md and in Automated testing.
License: MIT.
