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

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.1
File Size Uploaded
lavlab_taps-1.1.1.tar.gz 73.8 MB Details

Built distribution (wheel)

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

Total release size: 147.6 MB

Release files / lavlab_taps-1.1.1.tar.gz

Download URL lavlab_taps-1.1.1.tar.gz
Size 73.8 MB
Tags Source
SHA-256 checksum
How to use checksums
64d9bc5978d4ece62aeeda9f70ada75c59f8c26e5f7a9c3f77633e906c843562
BLAKE2b-256 checksum
How to use checksums
f4678fcef1408f1bb5a5bc0c4472ba4d9a22f8c6d742d2be34efd32a1a713186
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 Sep 11, 2026.

Transparency log

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

Download URL lavlab_taps-1.1.1-py3-none-any.whl
Size 73.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
064d04c497a97efb9633ac73a24ceb5228033b59ba9ab8259b185ab37307206e
BLAKE2b-256 checksum
How to use checksums
7e281e70905c9f06d5040a3cef4fdd80ca5f3609363b3c332196014829c0309f
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 Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.2

2 release files

This release

1.1.1 This release

2 release files

1.1.0

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