Skip to main content

TAPS

Build Tests Lint PyPI - Version PyPI - Python Version

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.0

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

Source distribution (sdist)

Source distribution for lavlab-taps 1.1.0
File Size Uploaded
lavlab_taps-1.1.0.tar.gz 73.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for lavlab-taps 1.1.0
File Interpreter ABI Platform
lavlab_taps-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 147.6 MB

Release files / lavlab_taps-1.1.0.tar.gz

Download URL lavlab_taps-1.1.0.tar.gz
Size 73.8 MB
Tags Source
SHA-256 checksum
How to use checksums
cbf92621f5530a4aa01029f2a100e09aa57b234e8183c59288bcb02d81c4e778
BLAKE2b-256 checksum
How to use checksums
aeb580a6c3f74f6f7323b4f26a680cd9cddead0cb84fc2ce616ccf63a43d64a6
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 Aug 18, 2026.

Transparency log

Release files / lavlab_taps-1.1.0-py3-none-any.whl

Download URL lavlab_taps-1.1.0-py3-none-any.whl
Size 73.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
f28844bf01c70494ae48cfa7e880a3d41c02ef882f51b05dd86dfd64450f965e
BLAKE2b-256 checksum
How to use checksums
2dc8eb48a447262e95691bb6f526fa3ae70d7390b5bb8bb471854fcb180cec7f
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 Aug 18, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

This release

1.1.0 This release

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