TmapSlide
Pure Python reader for UNIC TMAP whole-slide images (WSI) with an OpenSlide-compatible API — the companion library to kfbslide (KFB format).
import tmapslide
slide = tmapslide.OpenSlide("sample.TMAP")
print(slide.dimensions) # (71424, 72704)
print(slide.level_count) # 10
print(slide.level_downsamples) # (1.0, 2.0, 4.0, ...)
region = slide.read_region((512, 512), 0, (1024, 1024)) # RGBA PIL image
thumb = slide.get_thumbnail((512, 512))
macro = slide.associated_images["macro"]
Features
- Pure Python — no vendor SDK, no native dependencies; only Pillow.
- OpenSlide-compatible API — drop-in for code written against
openslide/kfbslide:read_region,get_thumbnail,dimensions,level_count,level_dimensions,level_downsamples,properties,associated_images. - Both known TMAP variants:
TMAP06(single pixel level, 612x512 overlapping tiles) andTMAP07(full pyramid, up to 10 levels, 256x256 tiles). - Fork-safe file handles — safe to use from PyTorch
DataLoaderworkers. - LRU tile cache for fast repeated reads.
Installation
pip install tmapslide
# or from source
pip install git+https://github.com/yifanfeng97/tmapslide.git
Supported formats
| Format | Extension | Vendor | Backend |
|---|---|---|---|
| TMAP 06 | .TMAP |
UNIC (United Imaging) | Pure Python |
| TMAP 07 | .TMAP |
UNIC (United Imaging) | Pure Python |
API
tmapslide.OpenSlide(filename)
| Member | Description |
|---|---|
dimensions |
(width, height) at level 0 |
level_count |
number of pyramid levels |
level_dimensions |
(w, h) per level |
level_downsamples |
downsample factor per level |
properties |
read-only metadata mapping (openslide.vendor=unic, tmap.*) |
associated_images |
lazy mapping, typically macro / label |
read_region(loc, level, size) |
PIL.Image (RGBA) of the region |
get_thumbnail(size) |
thumbnail from the lowest resolution level |
get_best_level_for_downsample(ds) |
best level for a downsample factor |
close() / context manager |
release resources |
tmapslide.open_slide(filename)
Alias of OpenSlide(filename).
Format notes (reverse-engineered)
TMAP is an undocumented proprietary format. This reader is built from binary analysis of real scanner output, cross-validated against ASlide. In short: both variants store plain JPEG tiles with a small binary header and index tables; there is no encryption.
- TMAP06 stores 3 pyramid levels (40x / 10x / 2.5x); TMAP07 stores up to 10 levels (40x down to 0.078x, halving each level).
- TMAP06 level-2 previews come from pre-rendered
ShrinkTileentries and are JPEG-compressed at that scale (slightly softer than downsampling level 0 yourself). iter_tiles()exposes the stored tile grid directly, useful for tile-based ML pipelines.
Testing
Tests run against real TMAP samples when the scce_external_center data
directory (or TAPSLIDE_TEST_DATA) is present next to the repo, and are
skipped otherwise.
pip install -e .[dev]
pytest
License
MIT — see LICENSE.
Acknowledgments
- kfbslide — the KFB reader this project is modelled after.
- OpenSlide — the API this library mimics.
- ASlide — its independent reverse-engineering of the TMAP06 layer/block structures (from decompiled vendor SDK) was used to cross-validate this implementation. tmapslide is an independent MIT-licensed implementation and ships no ASlide code.
Release files for tmapslide 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tmapslide-0.2.0.tar.gz | 21.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tmapslide-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.3 kB
Release files / tmapslide-0.2.0.tar.gz
| Download URL | tmapslide-0.2.0.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cf3156832c28ad01e96eaed6add201b74b2785ee8969a330d394306c295c520
|
|
BLAKE2b-256 checksum How to use checksums |
575318df051d58acb791dda31661940540a26b678dc1c3c512c6a840d749dacf
|
| 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 logRelease files / tmapslide-0.2.0-py3-none-any.whl
| Download URL | tmapslide-0.2.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcdbb65e84a94074b8f65765f6e9b8bda35f1c4827547f629f5fa3eb4025fd1d
|
|
BLAKE2b-256 checksum How to use checksums |
6b198eacff57214e2a08443a88f67734ffe8c738c9121fa59d6682e8ed6a40db
|
| 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