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.
pip install lavlab-tapsThe installation includes PyTorch, MONAI, NumPy, and NiBabel. Install a CUDA-compatible PyTorch build first when GPU inference is required.
taps segment input_image.nii.gz prostate_mask.nii.gzTAPS 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 cpuThe 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.
from taps import segment
segment(
"input_image.nii.gz",
"prostate_mask.nii.gz",
checkpoint=None, # use the bundled model
)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
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.
# 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 .See CONTRIBUTING.md for development guidelines.
taps is distributed under the terms of the MIT license.