Skip to main content

ahcore

ahcore is the AI for Oncology core toolkit for computational-pathology pipelines: the reusable building blocks that sit between whole-slide images and a training run. It is a pure-Python library, meant to be composed inside a larger pipeline rather than run on its own.

This repository is automatically synced from the AI for Oncology monorepo.

What ahcore offers

ahcore is a toolkit of composable building blocks for whole-slide-image deep learning, not an end-to-end application. A consumer pipeline assembles these pieces and owns the experiment logic. It decides how data is split, whether to cross-validate, and how runs are orchestrated. ahcore provides the parts.

  • A data catalog. A SQLAlchemy-backed manifest of patients, slides, masks, labels, and named splits, queried through a DataManager. ahcore stores and serves splits (e.g. fit/validate/test membership, or membership supplied in memory). How you draw them is up to you.
  • Views and adapters. Lazy per-slide and per-tile accessors over the catalog, plus an adapter seam (view → AdapterBundle) that turns them into named, model-ready tensors. Ships adapters for foundation-model tile features, patient labels, bulk RNA expression, and image+mask pairs. Adapters are the main extension point.
  • Feature extraction and caching. Run a packaged foundation-model encoder over a slide's tiles and persist the per-slide features to HDF5, keyed deterministically. This is a distinct precompute step: at training time the feature adapters read from that cache, they do not extract on the fly (doing so would be too slow for a realistic training run).
  • Datamodules and models. PyTorch Lightning datamodules that assemble batches from adapters (single- or multi-modal), plus model heads: attention-based MIL (ABMIL), mean-pool MIL (MeanMIL), encoders, a concatenation fusion head, and segmentation wrappers.
  • Task and training scaffolding. A Task protocol (choose inputs and targets, compute loss and metrics) and a thin MultiModalLightningModule that runs training/validation/test by delegating to the task. You supply the concrete tasks.
  • Slide-sized raster I/O. Stream model outputs (segmentation masks, attention or probability maps) tile-by-tile into a chunked Zarr store, then read arbitrary regions back like a slide, to stitch, overlay, or export to a pyramidal TIFF.
  • Transforms and augmentations. Tile transforms (including polygon-to-mask) and feature-space augmentations.

ahcore ships no end-to-end command-line application; it is a library.

Installation

pip install ahcore

Requires Python ≥ 3.11. The training stack (PyTorch Lightning) is a core dependency. ahcore is a training-scaffolding library, not an optional add-on.

Manifests that read slides with OpenSlide (reader OPENSLIDE) need dlup's OpenSlide backend:

pip install "ahcore[openslide]"

Development

ahcore is developed in the AI for Oncology monorepo and synced to this repository. To work on it here, standalone:

pip install -e ".[dev]"
pytest

Inside the monorepo it is built and tested with Bazel (bazelisk test //aifo/ahcore/tests/...).

License

Apache 2.0 — see LICENSE.

Metadata

Release files for ahcore 0.3.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 ahcore 0.3.0
File Size Uploaded
ahcore-0.3.0.tar.gz 127.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ahcore 0.3.0
File Interpreter ABI Platform
ahcore-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 273.8 kB

Release files / ahcore-0.3.0.tar.gz

Download URL ahcore-0.3.0.tar.gz
Size 127.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b7b503aa2977c9f489ca5a3e5dd4cbcf8565c422f4b8859083aec36312afaef4
BLAKE2b-256 checksum
How to use checksums
4d484f0848121d241d902a4e3437c5a6c8d79b971b037e2a7ac8b4ee73968e5b
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 18, 2026.

Transparency log

Release files / ahcore-0.3.0-py3-none-any.whl

Download URL ahcore-0.3.0-py3-none-any.whl
Size 146.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ec5836d10fd95d49a6a5d5371fff4f4774454ce112b16ba59df1f0fc4b0c884
BLAKE2b-256 checksum
How to use checksums
6340b6f03e6e6fad7def5c83f3f47a88697f38a386b1e3b5a40c04ea062dc33c
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 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

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