TAPS
TAPS deploys a trained prostate MRI segmentation model as a Python package and command-line application. It accepts a NIfTI image and writes a binary NIfTI mask aligned with the original input image.
See https://github.com/laviolette-lab/TAPS-Training-Code for the original training code used to create this model and write the paper.
Install
pip install lavlab-taps
The installation includes PyTorch, MONAI, NumPy, and NiBabel. Install a CUDA-compatible PyTorch build first when GPU inference is required.
CLI
taps segment input_image.nii.gz prostate_mask.nii.gz
TAPS uses the bundled checkpoint by default and selects CUDA automatically when it is available. Override either with --checkpoint and --device:
taps segment input_image.nii.gz prostate_mask.nii.gz \
--checkpoint best_segresnet_model.onnx --device cpu
The output is checked for volume, geometry, border contact, slice continuity, enclosed holes, and connected components. Abnormal results are written with an _abnormal suffix. Use --exact to keep the requested output name. Slices with multiple 2D components also produce a _cleaned mask with those slices blanked.
If the inferred mask is completely blank, TAPS does not write an output and exits with status 1.
The package applies the validation preprocessing pipeline, performs sliding-window inference, then restores the prediction to the source image's voxel space before saving it.
Python API
from taps import segment
segment(
"input_image.nii.gz",
"prostate_mask.nii.gz",
checkpoint=None, # use the bundled model
)
Project Structure
taps/
├── src/
│ └── taps/
│ ├── __init__.py # Public API & version export
│ ├── __about__.py # Version string
│ ├── cli.py # CLI entry point (thin wrapper)
│ ├── inference.py # Preprocessing, model loading & segmentation
│ ├── py.typed # PEP 561 marker
│ └── resources/
│ └── model_v1.onnx # Bundled checkpoint
├── tests/
├── docs/ # MkDocs source files
└── pyproject.toml
Development
Prerequisites: Python 3.9+ and Hatch.
git clone https://github.com/laviolette-lab/taps.git
cd taps
pip install hatch
| Task | Command |
|---|---|
| Run tests | hatch run test:test |
| Tests + coverage | hatch run test:cov |
| Lint | hatch run lint:check |
| Format | hatch run lint:format |
| Auto-fix lint | hatch run lint:fix |
| Type check | hatch run types:check |
| Build docs | hatch run docs:build-docs |
| Serve docs | hatch run docs:serve-docs |
| Build wheel | hatch build |
Or via the Makefile: make test, make lint, make build, etc.
Docker
# Run tests via Docker
docker build --target hatch -t taps:hatch .
docker run --rm -e HATCH_ENV=test taps:hatch cov
# Production image (just the installed wheel)
docker build --target prod -t taps:prod .
Contributing
See CONTRIBUTING.md for development guidelines.
License
taps is distributed under the terms of the MIT license.
Metadata
Release files for lavlab-taps 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lavlab_taps-1.1.2.tar.gz | 73.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lavlab_taps-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 147.6 MB
Release files / lavlab_taps-1.1.2.tar.gz
| Download URL | lavlab_taps-1.1.2.tar.gz |
|---|---|
| Size | 73.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ed92e6a4ebe210c7981d1e1eb981061ed71eb14c976f76f7648e797dd42aa10
|
|
BLAKE2b-256 checksum How to use checksums |
14d26834b87b72bf9e289536b8731fe4807568a31185aae211a4702e89c15fe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / lavlab_taps-1.1.2-py3-none-any.whl
| Download URL | lavlab_taps-1.1.2-py3-none-any.whl |
|---|---|
| Size | 73.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e938361febacadbfd70995bee23c4a56219de6cb302eff3b24f34ff4b9bd790a
|
|
BLAKE2b-256 checksum How to use checksums |
ce926c6edef6c7129d817c620b4a28405fc789eb8d2996313eb2fa53462ff806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency log